staging: r8188eu: Use a Mutex instead of a binary Semaphore
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Fri, 22 Oct 2021 17:19:17 +0000 (19:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Oct 2021 12:31:20 +0000 (14:31 +0200)
commit7e4c7947b42c4d9af0daa8d51dc58d4f17605dd9
tree111f6e48cab80fcaa0aebeac919a846087bfa009
parent75c5e966bda45915b6e0a6549fa21b10f94ad215
staging: r8188eu: Use a Mutex instead of a binary Semaphore

Use a Mutex instead of a binary Semaphore for the purpose of enforcing
mutual exclusive access to the "pwrctrl_priv" structure.

Mutexes are sleeping locks similar to Semaphores with a 'count' of one
(like binary Semaphores), however they have a simpler interface, more
efficient performance, and additional constraints.

There is no change in the logic of the new code; however it is more
simple because it gets rid of four unnecessary wrappers:
_init_pwrlock(), _enter_pwrlock(),_exit_pwrlock(), _rtw_down_sema().

Actually, there is a change in the state in which the code waits for
acquiring locks, because it makes it in an uninterruptible state
(instead the old code used down_interruptibe()). Interruptible
waits are neither required nor wanted in this driver.

Tested with ASUSTek Computer, Inc. Realtek 8188EUS [USB-N10 Nano].

Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Link: https://lore.kernel.org/r/20211022171917.24363-1-fmdefrancesco@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_pwrctrl.c
drivers/staging/r8188eu/include/osdep_service.h
drivers/staging/r8188eu/include/rtw_pwrctrl.h
drivers/staging/r8188eu/os_dep/osdep_service.c
drivers/staging/r8188eu/os_dep/usb_intf.c