staging: rtl8192e: replace comparison to NULL by bool
Fixed Comparison to NULL can be written as '!...' by replacing it with
simpler form i.e boolean expression. This makes code more readable alternative.
Reported by checkpatch.
MSG_8192C is a private trace mechanism macro and is deactivated.
(i.e. the default behaviour is _do nothing_)
The only way to activate it is to manually define a debug
symbol.
staging: rtl8723bs: remove commented out MSG_8192C log
remove commented out MSG_8192C log.
MSG_8192C is a private trace mechanism macro and is deactivated.
(i.e. the default behaviour is _do nothing_)
The only way to activate it is to manually define a debug
symbol.
MSG_8192C is a private trace mechanism macro and is deactivated.
(i.e. the default behaviour is _do nothing_)
The only way to activate it is to manually define a debug
symbol.
staging: rtl8723bs: remove decl of unused static const variable in os_dep/ioctl_linux.c
fix following kernel test robot warning:
At top level:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:36:27:
warning: 'iw_operation_mode' defined but not used
[-Wunused-const-variable=]
36 | static const char * const iw_operation_mode[] = {
| ^~~~~~~~~~~~~~~~~
staging: rtl8723bs: remove unused variable in os_dep/ioctl_linux.c
fix following kernel test robot warning:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:
In function ‘rtw_wx_set_mlme’:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:1128:6:
warning: variable ‘reason’ set but
not used [-Wunused-but-set-variable]
u16 reason;
^~~~~~
staging: rtl8723bs: remove unused variable declaration in include/rtw_security.h
fix following kernel test robot warning:
At top level:
drivers/staging/rtl8723bs/include/rtw_security.h:336:28:
warning: 'K' defined but not used [-Wunused-const-variable=]
336 | static const unsigned long K[64] = {
| ^
staging: rtl8723bs: remove set but unused psta variable in rtw_dbg_port() in os_dep/ioctl_linux.c
remove set but unused variable. Fix W=1 compiler warning:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:
In function ‘rtw_dbg_port’:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:2443:19:
warning: variable ‘psta’ set but not used [-Wunused-but-set-variable]
struct sta_info *psta;
^~~~
Remove also the function call that sets this variable.
staging: rtl8723bs: remove unused variables and code block left unused in os_dep/ioctl_linux.c
fix following kernel test robot warnings:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:
In function ‘rtw_dbg_port’:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:2548:33:
warning: variable ‘preorder_ctrl’ set but
not used [-Wunused-but-set-variable]
struct recv_reorder_ctrl *preorder_ctrl;
^~~~~~~~~~~~~
staging: rtl8723bs: remove unused variable and empty for cycles left unused in os_dep/ioctl_linux.c
fix following kernel test robot warnings:
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:2573:33:
warning: variable ‘preorder_ctrl’ set but
not used [-Wunused-but-set-variable]
struct recv_reorder_ctrl *preorder_ctrl;
^~~~~~~~~~~~~
remove also empty for cycle left unused and counter variable.
staging: rtl8723bs: remove unused variable in core/rtw_cmd.c
fix following kernel test robot warning:
drivers/staging/rtl8723bs/core/rtw_cmd.c:
In function 'rtw_cmd_thread':
>> drivers/staging/rtl8723bs/core/rtw_cmd.c:390:16:
warning: variable 'cmd_start_time' set
but not used [-Wunused-but-set-variable]
390 | unsigned long cmd_start_time;
| ^~~~~~~~~~~~~~
Martin Kaiser [Thu, 8 Apr 2021 19:56:01 +0000 (21:56 +0200)]
staging: rtl8188eu: simplify rtw_cmd_thread's main loop
In rtw_cmd_thread's main loop, we wait until there's a command in the
queue. To skip this wait statement in subsequent iterations, the driver
uses a label and goto instead of the actual loop. We only get back to the
initial wait if the queue is empty when we read it.
Basically, all we want to do is check if there's a command in the queue.
If yes, we process it. If not, we wait until someone enqueues a command.
Martin Kaiser [Thu, 8 Apr 2021 19:55:58 +0000 (21:55 +0200)]
staging: rtl8188eu: always free cmd_obj in the cmd thread
The rtl8188 driver starts a command thread that reads commands from a queue
and processes them. Each command consists of a struct cmd_obj. The command
thread may call a function to process the current command and optionally a
post-processing function. Eventually, the command's cmd_obj must be freed.
At the moment, if there's a post-processing function for the current
command, this function has to free the cmd_obj. If there's no
post-processing function, the command thread frees cmd_obj.
It's much simpler if we always leave it to the command thread to free
cmd_obj.
Martin Kaiser [Thu, 8 Apr 2021 19:55:56 +0000 (21:55 +0200)]
staging: rtl8188eu: move static array from .h to .c
Declaring a static array in a header file is likely to cause name conflicts
if the declaration is pulled in multiple times.
The rtl8188 driver protects the declaration of the wlancmds array in
rtw_mlme_ext.h with ifdef _RTW_CMD_C_, which is defined only in rtw_cmd.c.
It makes more sense to declare the array in the .c file.
Martin Kaiser [Thu, 8 Apr 2021 19:55:50 +0000 (21:55 +0200)]
staging: rtl8188eu: remove the last urb callback macros
Both usb_read_port_complete and usb_write_port_complete have a regs
parameter that is not used.
When this parameter is removed, the functions can be used as urb
completion callbacks directly. There's no need for the macros that
strip the second parameter.
Pu Lehui [Fri, 9 Apr 2021 04:57:28 +0000 (12:57 +0800)]
staging: rtl8723bs: remove unused variable pwrctl
GCC reports the following warning with W=1:
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c:532:23: warning:
variable 'pwrctl' set but not used [-Wunused-but-set-variable]
532 | struct pwrctrl_priv *pwrctl;
| ^~~~~~
This variable is not used so remove it to fix the warning.
The same code is executed when the condition "!show_errors" is true or
false. Remove the if condition from here. The original intension of this
condition was to not to report any error logs if condition was true. But
this driver doesn't has those logs added. So this if condition can be
removed.
Ian Abbott [Wed, 7 Apr 2021 18:13:42 +0000 (19:13 +0100)]
staging: comedi: Add Kconfig options to build unit test modules
The comedi unit-test modules in "drivers/staging/comedi/drivers/tests/"
are built if the `CONFIG_COMEDI_TESTS` option is enabled, but the comedi
Kconfig file contains no code to enable the option. Add config options
to allow each of the unit-test modules to be enabled individually. The
"ni_route_tests" module depends on the "ni_routing" module, so select it
if the "ni_route_tests" module is configured to be built.
Martin Kaiser [Wed, 7 Apr 2021 17:05:31 +0000 (19:05 +0200)]
staging: rtl8188eu: make rtw_usb_if1_init return a status
Return an error status instead of the struct adapter that was allocated
and filled. This is more useful for the probe function, who calls
rtw_usb_if1_init.
Martin Kaiser [Wed, 7 Apr 2021 17:05:30 +0000 (19:05 +0200)]
staging: rtl8188eu: make usb_dvobj_init return a status
usb_dvobj_init populates a struct dvobj_priv and installs it as interface
data of the usb interface. There's no point in returning this struct to the
caller, it makes more sense to return an error status.
Martin Kaiser [Wed, 7 Apr 2021 17:05:27 +0000 (19:05 +0200)]
staging: rtl8188eu: clean up rtw_recv_entry
Change the return type to int, the function returns 0 or 1.
Remove the goto statement, we're not doing any cleanup on exit.
Summarize variable declarations and assignments.
Colin Ian King [Wed, 7 Apr 2021 15:03:08 +0000 (16:03 +0100)]
staging: rtl8192u: Fix potential infinite loop
The for-loop iterates with a u8 loop counter i and compares this
with the loop upper limit of riv->ieee80211->LinkDetectInfo.SlotNum
that is a u16 type. There is a potential infinite loop if SlotNum
is larger than the u8 loop counter. Fix this by making the loop
counter the same type as SlotNum.
Addresses-Coverity: ("Infinite loop") Fixes: 8fc8598e61f6 ("Staging: Added Realtek rtl8192u driver to staging") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210407150308.496623-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: rtl8723bs: fix comparison in if condition
fix following post-commit checkpatch issue:
WARNING: Comparisons should place the constant on the right side of the test
1833: FILE: drivers/staging/rtl8723bs/os_dep/mlme_linux.c:151:
+ if (NULL == buff)
CHECK: Comparison to NULL could be written "!p"
290: FILE: drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:978:
+ if (p == NULL)
--
CHECK: Comparison to NULL could be written "!pmgntframe"
328: FILE: drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:2016:
+ if (pmgntframe == NULL)
--
CHECK: Comparison to NULL could be written "!pmgntframe"
361: FILE: drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:2378:
+ if (pmgntframe == NULL)
--
CHECK: Comparison to NULL could be written "!pmgntframe"
391: FILE: drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:3478:
+ if (pmgntframe == NULL)
--
CHECK: Comparison to NULL could be written "!p"
427: FILE: drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:4071:
+ if (p == NULL)
--
CHECK: Comparison to NULL could be written "!BIP_AAD"
781: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:1690:
+ if (BIP_AAD == NULL)
--
CHECK: Comparison to NULL could be written "!pwep"
1773: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:3062:
+ if (pwep == NULL)
--
CHECK: Comparison to NULL could be written "!pmlmepriv->wps_beacon_ie"
1784: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:3510:
+ if (pmlmepriv->wps_beacon_ie == NULL)
--
CHECK: Comparison to NULL could be written "!pmlmepriv->wps_probe_resp_ie"
1795: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:3544:
+ if (pmlmepriv->wps_probe_resp_ie == NULL)
--
CHECK: Comparison to NULL could be written "!pmlmepriv->wps_assoc_resp_ie"
1807: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:3574:
+ if (pmlmepriv->wps_assoc_resp_ie == NULL)
--
CHECK: Comparison to NULL could be written "!pbuf"
1818: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:3928:
+ if (pbuf == NULL)
--
CHECK: Comparison to NULL could be written "!if1"
1944: FILE: drivers/staging/rtl8723bs/os_dep/sdio_intf.c:392:
+ if (if1 == NULL)
CHECK: Using comparison to false is error prone
402: FILE: drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:3890:
+ if (false == bxmitok)
--
CHECK: Using comparison to true is error prone
671: FILE: drivers/staging/rtl8723bs/core/rtw_recv.c:365:
+ if ((prxattrib->bdecrypted == true) && (brpt_micerror == true))
--
CHECK: Using comparison to true is error prone
1051: FILE: drivers/staging/rtl8723bs/core/rtw_xmit.c:1174:
+ if (padapter->securitypriv.binstallBIPkey != true)
--
CHECK: Using comparison to false is error prone
1632: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2194:
+ if (false == bMatched)
staging: rtl8723bs: put constant on the right side in if condition
fix the following post-commit hook checkpatch warning:
WARNING: Comparisons should place the constant on the right side of the test
683: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:2204:
+ if (_SUCCESS != rtw_set_chplan_cmd(padapter, channel_plan_req, 1, 1))
Remove all of the DBG_871X logs as they
currently do nothing as they require the code to be modified by
hand in order to be turned on. This obviously has not happened
since the code was merged, so just remove them as they are unused.
Remove all of the DBG_871X logs as they
currently do nothing as they require the code to be modified by
hand in order to be turned on. This obviously has not happened
since the code was merged, so just remove them as they are unused.
applied the following semantic patch script:
@@
expression a, b, c, d, e, f, g, h, i, j, k;
constant B, C, D, E;
@@
This patch prepares the application of the semantic
patch aimed to remove all DBG_871X logs.
One occurrence of the DBG_871X macro has one
repeated argument, that's not even comma separated
value with the previous one nor a format string
parameter associated.
In normal conditions this worked, for the macro
is usually not expanded (the do nothing behaviour),
but if I try to apply the sempantic patch to remove
all macro occurrences, all macros call after that
abnormal declaration are left untouched (not removed).
Remove all of the DBG_871X logs as they currently
do nothing as they require the code to be modified by
hand in order to be turned on. This obviously has not happened
since the code was merged, so just remove them as they are unused.
Ian Abbott [Wed, 7 Apr 2021 14:01:42 +0000 (15:01 +0100)]
staging: comedi: tests: Correct unittest_fptr
The definition of the `unittest_fptr` function pointer type has the
wrong function return type `void *` instead of `void`. The problem is
hidden by a bunch of unnecessary type-casts. Fix the type definition
and remove the type-casts.
The `ni_routes_test` module is not currently selectable using the
Kconfig files, but can be built by specifying `CONFIG_COMEDI_TESTS=m` on
the "make" command line. It currently fails to compile due to an extra
parameter added to the `ni_assign_device_routes` function by
commit e3b7ce73c578 ("staging: comedi: ni_routes: Allow alternate board
name for routes"). Fix it by supplying the value `NULL` for the added
`alt_board_name` parameter (which specifies that there is no alternate
board name).
Fixes: e3b7ce73c578 ("staging: comedi: ni_routes: Allow alternate board name for routes") Cc: Spencer E. Olson <olsonse@umich.edu> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Link: https://lore.kernel.org/r/20210407140142.447250-2-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Martin Kaiser [Tue, 6 Apr 2021 20:48:29 +0000 (22:48 +0200)]
staging: rtl8188eu: remove an obsolete comment
This driver does not set URB_ZERO_PACKET.
The rtl8188eu driver that's available from Realtek/Edimax has some
commented-out code that sets zero packet. It was removed from this
driver before it was imported.
Martin Kaiser [Tue, 6 Apr 2021 20:48:22 +0000 (22:48 +0200)]
staging: rtl8188eu: use actual request type as parameter
At the moment, usbctrl_vendorreq's requesttype parameter must be set to 1
for reading and 0 for writing. It's then converted to the actual
bmRequestType for the USB control request. We can simplify the code and
avoid this conversion if the caller passes the actual bmRequestType.
We already have defines for the read and write request types. Move them to
usb_ops_linux.c, they're used only inside this file. Replace the numeric
values with USB constants to make their meaning clearer.
Martin Kaiser [Tue, 6 Apr 2021 20:48:21 +0000 (22:48 +0200)]
staging: rtl8188eu: ctrl vendor req index is not used
The index for rtl8188eu's vendor-specific control requests is not used.
Remove the index parameter from usbctrl_vendorreq and pass index 0 to
usb_control_msg.
Martin Kaiser [Tue, 6 Apr 2021 20:48:20 +0000 (22:48 +0200)]
staging: rtl8188eu: ctrl vendor req value is always 0x05
The bRequest value for the vendor specific control requests sent by this
driver is always 0x05. Replace the function parameter with a define. Use
the same define as the rtlwifi driver.