clean up some code duplication
cover clean up some code duplication
This series cleans up some code duplication in the files wifi_regd.c and ioctl_cfg80211.c.
The patches have been compile tested only due to lack of hardware.
Michael Straube (3):
staging: rtl8723bs: remove unused function parameter
staging: rtl8723bs: remove unnesessary function parameter
staging: rtl8723bs: remove redundant static function
.../rtl8723bs/include/ioctl_cfg80211.h | 1 + .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 24 +++++++++---------- drivers/staging/rtl8723bs/os_dep/wifi_regd.c | 16 +------------ 3 files changed, 14 insertions(+), 27 deletions(-)
Signature · 1 line
2.49.0
PATCH 1/3 staging: rtl8723bs: remove unused function parameter
The parameter 'band' of rtw_ieee80211_channel_to_frequency() in wifi_regd.c is unused, remove it.
--- drivers/staging/rtl8723bs/os_dep/wifi_regd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/rtl8723bs/os_dep/wifi_regd.c +2 -5
@@ -41,7 +41,7 @@ static const struct ieee80211_regdomain rtw_regdom_rd = { } }; -static int rtw_ieee80211_channel_to_frequency (int chan,int band) +static int rtw_ieee80211_channel_to_frequency (int chan) {/* NL80211_BAND_2GHZ */ if (chan ==14 )
@@ -82,10 +82,7 @@ static void _rtw_reg_apply_flags(struct wiphy *wiphy)/* channels apply by channel plans. */ for (i =0 ; i < max_chan_nums; i++) { channel = channel_set[i].ChannelNum; - freq = -rtw_ieee80211_channel_to_frequency (channel, -NL80211_BAND_2GHZ ); - + freq =rtw_ieee80211_channel_to_frequency (channel); ch =ieee80211_get_channel (wiphy, freq);if (ch) {if (channel_set[i].ScanType ==SCAN_PASSIVE )
Signature · 1 line
2.49.0
PATCH 2/3 staging: rtl8723bs: remove unnesessary function parameter
In reply to Michael StraubeThe function rtw_ieee80211_channel_to_frequency() in ioctl_cfg80211.c is always called with band = NL80211_BAND_2GHZ. Remove the unnecessary band parameter from the function and adjust its code and calls.
--- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +12 -12
@@ -192,14 +192,14 @@ rtw_cfg80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = { }, }; -static int rtw_ieee80211_channel_to_frequency (int chan,int band) +static int rtw_ieee80211_channel_to_frequency (int chan) { -if (band ==NL80211_BAND_2GHZ ) { -if (chan ==14 ) -return 2484 ; -else if (chan <14 ) -return 2407 + chan *5 ; - } +/* NL80211_BAND_2GHZ */ +if (chan ==14 ) +return 2484 ; + +if (chan <14 ) +return 2407 + chan *5 ;return 0 ;/* not supported */ }
@@ -266,7 +266,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl/* spin_unlock_bh(&pwdev_priv->scan_req_lock); */ channel = pnetwork->network.configuration.ds_config; - freq =rtw_ieee80211_channel_to_frequency (channel,NL80211_BAND_2GHZ ); + freq =rtw_ieee80211_channel_to_frequency (channel); notify_channel =ieee80211_get_channel (wiphy, freq);
@@ -340,7 +340,7 @@ int rtw_cfg80211_check_bss(struct adapter *padapter)if (!(pnetwork) || !(padapter->rtw_wdev))return false; - freq =rtw_ieee80211_channel_to_frequency (pnetwork->configuration.ds_config,NL80211_BAND_2GHZ ); + freq =rtw_ieee80211_channel_to_frequency (pnetwork->configuration.ds_config); notify_channel =ieee80211_get_channel (padapter->rtw_wdev->wiphy, freq); bss = cfg80211_get_bss(padapter->rtw_wdev->wiphy, notify_channel,
@@ -440,7 +440,7 @@ void rtw_cfg80211_indicate_connect(struct adapter *padapter)u16 channel = cur_network->network.configuration.ds_config;struct cfg80211_roam_info roam_info = {}; - freq =rtw_ieee80211_channel_to_frequency (channel,NL80211_BAND_2GHZ ); + freq =rtw_ieee80211_channel_to_frequency (channel); notify_channel =ieee80211_get_channel (wiphy, freq);
@@ -1976,7 +1976,7 @@ static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdif (!channel)return -ENODATA ; - freq =rtw_ieee80211_channel_to_frequency (channel,NL80211_BAND_2GHZ ); + freq =rtw_ieee80211_channel_to_frequency (channel); chan =ieee80211_get_channel (adapter->rtw_wdev->wiphy, freq);
@@ -2456,7 +2456,7 @@ void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len,rtw_action_frame_parse (frame, frame_len, &category, &action); - freq =rtw_ieee80211_channel_to_frequency (channel,NL80211_BAND_2GHZ ); + freq =rtw_ieee80211_channel_to_frequency (channel);rtw_cfg80211_rx_mgmt (adapter, freq,0 , frame, frame_len,GFP_ATOMIC ); }
Signature · 1 line
2.49.0
PATCH 3/3 staging: rtl8723bs: remove redundant static function
In reply to Michael StraubeBoth wifi_regd.c and ioctl_cfg80211.c define a static function rtw_ieee80211_channel_to_frequency() with identical functionality. Remove the function from wifi_regd.c and make it non-static in ioctl_cfg80211.c to avoid code duplication.
--- drivers/staging/rtl8723bs/include/ioctl_cfg80211.h | 1 + drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- drivers/staging/rtl8723bs/os_dep/wifi_regd.c | 11 ----------- 3 files changed, 2 insertions(+), 12 deletions(-)
drivers/staging/rtl8723bs/include/ioctl_cfg80211.h +1 -0
@@ -94,6 +94,7 @@ void rtw_cfg80211_init_wiphy(struct adapter *padapter);void rtw_cfg80211_unlink_bss (struct adapter *padapter,struct wlan_network *pnetwork);void rtw_cfg80211_surveydone_event_callback (struct adapter *padapter); +int rtw_ieee80211_channel_to_frequency (int chan);struct cfg80211_bss *rtw_cfg80211_inform_bss (struct adapter *padapter,struct wlan_network *pnetwork);int rtw_cfg80211_check_bss (struct adapter *padapter);void rtw_cfg80211_ibss_indicate_connect (struct adapter *padapter);
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +1 -1
@@ -192,7 +192,7 @@ rtw_cfg80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = { }, }; -static int rtw_ieee80211_channel_to_frequency (int chan) +int rtw_ieee80211_channel_to_frequency (int chan) {/* NL80211_BAND_2GHZ */ if (chan ==14 )
drivers/staging/rtl8723bs/os_dep/wifi_regd.c +0 -11
@@ -41,17 +41,6 @@ static const struct ieee80211_regdomain rtw_regdom_rd = { } }; -static int rtw_ieee80211_channel_to_frequency (int chan) -{ -/* NL80211_BAND_2GHZ */ -if (chan ==14 ) -return 2484 ; -else if (chan <14 ) -return 2407 + chan *5 ; -else -return 0 ;/* not supported */ -} -static void _rtw_reg_apply_flags (struct wiphy *wiphy) {struct adapter *padapter =wiphy_to_adapter (wiphy);
Signature · 1 line
2.49.0