All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] clean up some code duplication
@ 2025-06-30  8:30 Michael Straube
  2025-06-30  8:30 ` [PATCH 1/3] staging: rtl8723bs: remove unused function parameter Michael Straube
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael Straube @ 2025-06-30  8:30 UTC (permalink / raw)
  To: gregkh; +Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel,
	Michael Straube

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(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] staging: rtl8723bs: remove unused function parameter
  2025-06-30  8:30 [PATCH 0/3] clean up some code duplication Michael Straube
@ 2025-06-30  8:30 ` Michael Straube
  2025-06-30  8:30 ` [PATCH 2/3] staging: rtl8723bs: remove unnesessary " Michael Straube
  2025-06-30  8:30 ` [PATCH 3/3] staging: rtl8723bs: remove redundant static function Michael Straube
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Straube @ 2025-06-30  8:30 UTC (permalink / raw)
  To: gregkh; +Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel,
	Michael Straube

The parameter 'band' of rtw_ieee80211_channel_to_frequency() in
wifi_regd.c is unused, remove it.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/rtl8723bs/os_dep/wifi_regd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
index dbd4bf531339..ac0b58a8b5d3 100644
--- a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
+++ b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
@@ -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)
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] staging: rtl8723bs: remove unnesessary function parameter
  2025-06-30  8:30 [PATCH 0/3] clean up some code duplication Michael Straube
  2025-06-30  8:30 ` [PATCH 1/3] staging: rtl8723bs: remove unused function parameter Michael Straube
@ 2025-06-30  8:30 ` Michael Straube
  2025-06-30  8:30 ` [PATCH 3/3] staging: rtl8723bs: remove redundant static function Michael Straube
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Straube @ 2025-06-30  8:30 UTC (permalink / raw)
  To: gregkh; +Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel,
	Michael Straube

The 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.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 7fcc46a0bb48..7cc1e036d2c4 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -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 *wd
 	if (!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);
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] staging: rtl8723bs: remove redundant static function
  2025-06-30  8:30 [PATCH 0/3] clean up some code duplication Michael Straube
  2025-06-30  8:30 ` [PATCH 1/3] staging: rtl8723bs: remove unused function parameter Michael Straube
  2025-06-30  8:30 ` [PATCH 2/3] staging: rtl8723bs: remove unnesessary " Michael Straube
@ 2025-06-30  8:30 ` Michael Straube
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Straube @ 2025-06-30  8:30 UTC (permalink / raw)
  To: gregkh; +Cc: hdegoede, Larry.Finger, linux-staging, linux-kernel,
	Michael Straube

Both 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.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 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(-)

diff --git a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
index 993a7b3c3d22..753009b07451 100644
--- a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
+++ b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h
@@ -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);
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 7cc1e036d2c4..eddf6da27a20 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -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)
diff --git a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
index ac0b58a8b5d3..f9c4d487badf 100644
--- a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
+++ b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c
@@ -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);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-30  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30  8:30 [PATCH 0/3] clean up some code duplication Michael Straube
2025-06-30  8:30 ` [PATCH 1/3] staging: rtl8723bs: remove unused function parameter Michael Straube
2025-06-30  8:30 ` [PATCH 2/3] staging: rtl8723bs: remove unnesessary " Michael Straube
2025-06-30  8:30 ` [PATCH 3/3] staging: rtl8723bs: remove redundant static function Michael Straube

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.