staging: r8188eu: use sizeof(*pvar) for allocating structs
Use sizeof(*pvar) instead of sizeof(struct var) when allocating memory.
This conforms to Linux kernel coding style, improves readability,
and decreases the opportunity for bugs if the pointer variable type is
changed. Issue found by checkpatch messages of the following format:
CHECK: Prefer kzalloc(sizeof(*pvar)...) over kzalloc(sizeof(struct var)...)
staging: r8188eu: format comments in drivers/net style
Format comments according to the Linux kernerl coding style
for drivers/net so they do not need to be reformatted after
this driver is accepted into the drivers/net tree.
Xiaoke Wang [Tue, 5 Apr 2022 04:43:07 +0000 (12:43 +0800)]
staging: rtl8712: fix a potential memory leak in r871xu_drv_init()
In r871xu_drv_init(), if r8712_init_drv_sw() fails, then the memory
allocated by r8712_alloc_io_queue() in r8712_usb_dvobj_init() is not
properly released as there is no action will be performed by
r8712_usb_dvobj_deinit().
To properly release it, we should call r8712_free_io_queue() in
r8712_usb_dvobj_deinit().
Besides, in r871xu_dev_remove(), r8712_usb_dvobj_deinit() will be called
by r871x_dev_unload() under condition `padapter->bup` and
r8712_free_io_queue() is called by r8712_free_drv_sw().
However, r8712_usb_dvobj_deinit() does not rely on `padapter->bup` and
calling r8712_free_io_queue() in r8712_free_drv_sw() is negative for
better understading the code.
So I move r8712_usb_dvobj_deinit() into r871xu_dev_remove(), and remove
r8712_free_io_queue() from r8712_free_drv_sw().
Michael Straube [Tue, 5 Apr 2022 10:49:10 +0000 (12:49 +0200)]
staging: r8188eu: remove GetHalDefVar8188EUsb()
The local variable odm_flag in rtw_dbg_port() is set but never used.
This are the last two remaining calls to GetHalDefVar8188EUsb(). Both
calls can be removed and we finally can remove GetHalDefVar8188EUsb()
itself. This is part of the ongoing effort to get rid of the unwanted
hal layer.
Michael Straube [Tue, 5 Apr 2022 10:49:09 +0000 (12:49 +0200)]
staging: r8188eu: remove HAL_DEF_CURRENT_ANTENNA
In order to get rid of the function GetHalDefVar8188EUsb(), remove
the HAL_DEF_CURRENT_ANTENNA case from it and move the functionality
into a new function. This is part of the ongoing effort to get rid of
the unwanted hal layer.
In order to get rid of the function GetHalDefVar8188EUsb(), remove
the HAL_DEF_IS_SUPPORT_ANT_DIV case from it and move the functionality
into a new function. This is part of the ongoing effort to get rid of
the unwanted hal layer.
There are some uses of ternary operator where it explicitly sets
true or false but the condition already evaluates to true or false.
In this cases the ternary operator is redundant and can be removed.
The "need to make timeout handlerOS independent" comment is incorrect.
Remove the comment to avoid misleading developers.
Additional instances found with git grep.
We simplify this code in multiple steps. First, we remove do_join_r
variable because it is only used right after it is assigned. Second,
we remove the unnecessary else statement right after break:
while (1) {
if (rtw_do_join(padapter) == _SUCCESS)
break;
rtw_dec_to_roam(padapter);
The function iterates an index from 0 to NUM_PMKID_CACHE and returns
the first index for which the condition is true. If no such index is
found, the function returns -1. Current code has a complex control
flow that obfuscates this simple task. Replace it with a loop.
Also, given the shortened function body, replace the long variable
name psecuritypriv with a short variable name p.
Reported by checkpatch:
WARNING: else is not generally useful after a break or return
The function iterates an index from 0 to NUM_PMKID_CACHE and returns
the first index for which the condition is true. If no such index is
found, the function returns -1. Current code has a complex control
flow that obfuscates this simple task. Replace it with a loop.
Also, given the shortened function body, replace the long variable
name psecuritypriv with a short variable name p.
Reported by checkpatch:
WARNING: else is not generally useful after a break or return
staging: rtl8712: Fix multiple blank lines warning from .c files
This patch fixes the checkpatch.pl warnings like:
CHECK: Please don't use multiple blank lines
+
+
from rtl871x_ioctl_rtl.c, rtl871x_ioctl_set.c, rtl871x_recv.c,
and rtl871x_security.c
staging: rtl8712: Fix multiple blank lines warning from .h files
This patch fixes the checkpatch.pl warnings like:
CHECK: Please don't use multiple blank lines
+
+
from rtl8712_*.h, rtl871x_*.h, sta_info.h, and wifi.h
The "need to make timeout handlerOS independent" comment is incorrect.
Remove the comment to avoid misleading developers.
Additional instance found with git grep.
Martin Kaiser [Sun, 3 Apr 2022 16:54:37 +0000 (18:54 +0200)]
staging: r8188eu: don't call get_hdr_bssid
Do not call get_hdr_bssid from validate_recv_data_frame.
We already distinguish between the four cases for to_ds, from_ds. Copy
the bssid address as described in the "DS bit usage" table in
include/linux/ieee80211.h.
Eventually, we should remove get_hdr_bssid (and other similar
driver-specific parsing functions).
Martin Kaiser [Sun, 3 Apr 2022 16:54:34 +0000 (18:54 +0200)]
staging: r8188eu: remove to_fr_ds from struct rx_pkt_attrib
to_fr_ds in struct rx_pkt_attrib stores the values of the to_ds and
from_ds bits of an incoming data frame. to_fr_ds is set by parsing the
frame control bytes and it's used only in validate_recv_data_frame.
Remove to_fr_ds from struct rx_pkt_attrib and use the ieee80211 helpers
to distinguish between the four different cases for to_ds, from_ds.
Martin Kaiser [Sun, 3 Apr 2022 16:54:33 +0000 (18:54 +0200)]
staging: r8188eu: don't copy ra and ta before we fail
In validate_recv_data_frame, we return an error if both to_ds and
from_ds are set in the incoming data frame. There's no need to populate
patrib->ra and ta before we return. The caller will free the received
frame, including pattrib.
Martin Kaiser [Sun, 3 Apr 2022 16:54:32 +0000 (18:54 +0200)]
staging: r8188eu: to_fr_ds cannot be 3 here
Remove two unnecessary ternary operators in validate_recv_data_frame.
pattrib->to_fr_ds cannot be 3 in these places. If it was 3, we'd already
have returned an error to the caller.
Martin Kaiser [Sun, 3 Apr 2022 16:45:26 +0000 (18:45 +0200)]
staging: r8188eu: use ieee80211 struct for aid
Remove the GetAid macro and map the frame data to a struct
ieee80211_pspoll instead. We can then read the aid component.
psta->aid is in host endianness and has a 0x3FFF mask applied. We have to
convert our read value as well and apply the mask before we compare it to
psta->aid.
Jaehee Park [Fri, 1 Apr 2022 14:53:50 +0000 (10:53 -0400)]
staging: wfx: change variable name to be consistent
Change variable name to be consistent with the naming conventions.
ssidlen was changed to ssid_len and ssidie was changed to ssid_ie to be
consistent. This makes the variables more readable. The other ssid
names in the code are separated by an underscore. For example,
bssid_filter and num_of_ssids have the ssid separated from the rest of
the words with an underscore.
Michael Straube [Sun, 3 Apr 2022 10:37:12 +0000 (12:37 +0200)]
staging: r8188eu: remove macro rtw_pwr_wakeup()
After previous cleanups the rtw_pwr_wakeup() macro is just an alias
for _rtw_pwr_wakeup(). Remove the macro and rename _rtw_pwr_wakeup()
to rtw_pwr_wakeup().
Michael Straube [Sat, 2 Apr 2022 09:23:32 +0000 (11:23 +0200)]
staging: r8188eu: remove HW_VAR_H2C_FW_P2P_PS_OFFLOAD from SetHwReg8188EU()
The HW_VAR_H2C_FW_P2P_PS_OFFLOAD case in SetHwReg8188EU() just calls a
function. Call the function directly and remove the
HW_VAR_H2C_FW_P2P_PS_OFFLOAD case from SetHwReg8188EU(). This is part
of the ongoing effort to get rid of the unwanted hal layer.
Michael Straube [Sat, 2 Apr 2022 09:23:31 +0000 (11:23 +0200)]
staging: r8188eu: remove HW_VAR_H2C_FW_JOINBSSRPT from SetHwReg8188EU()
The HW_VAR_H2C_FW_JOINBSSRPT case in SetHwReg8188EU() just calls a
function. Call the function directly and remove the
HW_VAR_H2C_FW_JOINBSSRPT case from SetHwReg8188EU(). This is part of
the ongoing effort to get rid of the unwanted hal layer.
Michael Straube [Sat, 2 Apr 2022 09:23:30 +0000 (11:23 +0200)]
staging: r8188eu: remove HW_VAR_RPT_TIMER_SETTING from SetHwReg8188EU()
Remove the HW_VAR_RPT_TIMER_SETTING case from SetHwReg8188EU() and
move its functionality to rtw_cmd.c where it is actually used. This is
part of the ongoing effort to get rid of the unwanted hal layer.
Michael Straube [Sat, 2 Apr 2022 09:23:29 +0000 (11:23 +0200)]
staging: r8188eu: remove HW_VAR_ANTENNA_DIVERSITY_SELECT from SetHwReg8188EU()
Remove the HW_VAR_ANTENNA_DIVERSITY_SELECT case from SetHwReg8188EU()
and move its functionality to rtw_cmd.c where it is actually used.
This is part of the ongoing effort to get rid of the unwanted hal
layer.
Michael Straube [Sat, 2 Apr 2022 09:23:28 +0000 (11:23 +0200)]
staging: r8188eu: remove HW_VAR_AMPDU_MIN_SPACE from SetHwReg8188EU()
Remove the HW_VAR_AMPDU_MIN_SPACE case from SetHwReg8188EU() and move
its functionality to rtw_wlan_util.c where it is actually used. This
is part of the ongoing effort to get rid of the unwanted hal layer.
Michael Straube [Sat, 2 Apr 2022 09:23:27 +0000 (11:23 +0200)]
staging: r8188eu: remove HW_VAR_ACK_PREAMBLE from SetHwReg8188EU()
Remove the HW_VAR_ACK_PREAMBLE case from SetHwReg8188EU() and move
its functionality to rtw_wlan_util.c where it is actually used. This
is part of the ongoing effort to get rid of the unwanted hal layer.
Michael Straube [Sat, 2 Apr 2022 09:23:26 +0000 (11:23 +0200)]
staging: r8188eu: remove HW_VAR_BSSID from SetHwReg8188EU()
Remove the HW_VAR_BSSID case from SetHwReg8188EU() and move its
functionality to rtw_mlme_ext.c where it is actually used. This is
part of the ongoing effort to get rid of the unwanted hal layer.
staging: sm750fb: Call iounmap() to free mapped bus memory
If ioremap_wc() fails, the code jumps to the "exit" label and forgets to
free the bus memory mapped into "sm750_dev->pvReg". Mapped bus memory must
always be freed by calling iounmap().
Call iounmap(sm750_dev->pvReg) when the above-mentioned failures happen.
The site of the missing iounmap() has been detected by Smatch.
staging: r8188eu: Remove redundant code from rtw_free_netdev()
In rtw_free_netdev() there are two redundant tests. The first checks for
a valid pointer to a "struct net_device". This pointer is the argument
of rtw_free_netdev(). The two callers of this function already test this
parameter immediatelly before the calls. The second checks for a valid
pointer to a "struct rtw_netdev_priv_indicator". This pointer is always
valid and, even if it were not, vfree() is a no-op on NULL pointers.
Therefore the above-mentioned two "if" statements are unnecessary and
redundant. For this reason, remove these two tests.
After removing these tests there is no more need of the "RETURN" label.
Therefore, remove also the "RETURN" label.
The function iterates an index from 0 to NUM_PMKID_CACHE and returns
the first index for which the condition is true. If no such index is
found, the function returns -1. Current code has a complex control
flow that obfuscates this simple task. Replace it with a loop.
Also, given the shortened function body, replace the long variable
name psecuritypriv with a short variable name p.
Reported by checkpatch:
WARNING: else is not generally useful after a break or return
staging: vc04_services: Convert kmap() to kmap_local_page()
The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible. In file interface/vchiq_arm/vchiq_arm.c,
function free_pagelist() calls kmap() / kunmap() from two places.
With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore, free_pagelist() is a function where the
use of kmap_local_page() in place of kmap() is correctly suited.
Convert to kmap_local_page() but, instead of open coding it, use the
memcpy_to_page() helper.
Michael Straube [Thu, 31 Mar 2022 21:41:46 +0000 (23:41 +0200)]
staging: rtl8723bs: refactor rtw_ch2freq()
Convert the array ch_freq_map to a simple integer array and use
the indices as channel numbers. This simplifies the code and avoids
looping through the array to get the frequency. To avoid out of
bounds array access return a default value for invalid channel values,
like the original code did.
Michael Straube [Thu, 31 Mar 2022 21:41:45 +0000 (23:41 +0200)]
staging: rtl8723bs: remove 5 GHz channels from ch_freq_map
According to the Realtek documentation the chips this driver supports
are 2.4 GHz only chips. Frequencies for 5 GHz channels can be removed
from the ch_freq_map array.
Rebecca Mckeever [Thu, 31 Mar 2022 17:16:04 +0000 (12:16 -0500)]
staging: r8188eu: use sizeof(*pvar) for allocating structs
Use sizeof(*pvar) instead of sizeof(struct var) when allocating memory.
This conforms to Linux kernel coding style, improves readability,
and decreases the opportunity for bugs if the pointer variable type is
changed. Issue found by checkpatch messages of the following format:
CHECK: Prefer kzalloc(sizeof(*pvar)...) over kzalloc(sizeof(struct var)...)
There is no need for "struct dentry *eth_debugfs_dir" which is used for
debug / sysfs directories. Therefore, remove this "struct dentry" and
everything related (i.e., creation and removal).
As a side effect of this change, the code has no more need of the
"cleanup_register_netdev" label, which can also be removed.
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Link: https://lore.kernel.org/r/20220331064751.29634-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>