All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] staging: rtl8192e: Use standard api to calculate frequency <-> channel
@ 2023-06-08  6:52 Philipp Hortmann
  2023-06-08  6:52 ` [PATCH 1/2] staging: rtl8192e: Use standard api to calculate frequency to channel Philipp Hortmann
  2023-06-08  6:52 ` [PATCH 2/2] staging: rtl8192e: Use standard api to calculate channel to frequency Philipp Hortmann
  0 siblings, 2 replies; 5+ messages in thread
From: Philipp Hortmann @ 2023-06-08  6:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-staging, linux-kernel

Use standard api to calculate frequency to channel and channel to
frequency. Usage of cfg80211 is required to merge driver into wireless
subsystem.

---
Tested with rtl8192e (WLL6130-D99)
Transferred this patch over wlan connection of rtl8192e

Philipp Hortmann (2):
  staging: rtl8192e: Use standard api to calculate frequency to channel
  staging: rtl8192e: Use standard api to calculate channel to frequency

 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c   |  6 ++++--
 drivers/staging/rtl8192e/rtllib.h            |  2 --
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 22 +++-----------------
 3 files changed, 7 insertions(+), 23 deletions(-)

-- 
2.40.1


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

* [PATCH 1/2] staging: rtl8192e: Use standard api to calculate frequency to channel
  2023-06-08  6:52 [PATCH 0/2] staging: rtl8192e: Use standard api to calculate frequency <-> channel Philipp Hortmann
@ 2023-06-08  6:52 ` Philipp Hortmann
  2023-06-15 10:46   ` Greg Kroah-Hartman
  2023-06-08  6:52 ` [PATCH 2/2] staging: rtl8192e: Use standard api to calculate channel to frequency Philipp Hortmann
  1 sibling, 1 reply; 5+ messages in thread
From: Philipp Hortmann @ 2023-06-08  6:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-staging, linux-kernel

Use ieee80211_freq_khz_to_channel() to calculate frequency to channel to
omit proprietary code.

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
---
Tested this code with separate debug code as this part is usually unused.
---
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index 78a70e5f1974..6fd2e94d5f8a 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -42,15 +42,8 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
 	if (fwrq->e == 1) {
 		if ((fwrq->m >= (int)2.412e8 &&
 		     fwrq->m <= (int)2.487e8)) {
-			int f = fwrq->m / 100000;
-			int c = 0;
-
-			while ((c < 14) && (f != rtllib_wlan_frequencies[c]))
-				c++;
-
-			/* hack to fall through */
+			fwrq->m = ieee80211_freq_khz_to_channel(fwrq->m / 100);
 			fwrq->e = 0;
-			fwrq->m = c + 1;
 		}
 	}
 
-- 
2.40.1


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

* [PATCH 2/2] staging: rtl8192e: Use standard api to calculate channel to frequency
  2023-06-08  6:52 [PATCH 0/2] staging: rtl8192e: Use standard api to calculate frequency <-> channel Philipp Hortmann
  2023-06-08  6:52 ` [PATCH 1/2] staging: rtl8192e: Use standard api to calculate frequency to channel Philipp Hortmann
@ 2023-06-08  6:52 ` Philipp Hortmann
  1 sibling, 0 replies; 5+ messages in thread
From: Philipp Hortmann @ 2023-06-08  6:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-staging, linux-kernel

Use ieee80211_channel_to_freq_khz() to calculate channel to frequency to
omit proprietary code.

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
---
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c   |  6 ++++--
 drivers/staging/rtl8192e/rtllib.h            |  2 --
 drivers/staging/rtl8192e/rtllib_softmac_wx.c | 13 ++-----------
 3 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 8b656980ee25..3346c4d72c3e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -342,9 +342,11 @@ static int _rtl92e_wx_get_range(struct net_device *dev,
 
 	for (i = 0, val = 0; i < 14; i++) {
 		if ((priv->rtllib->active_channel_map)[i + 1]) {
+			s32 freq_khz;
+
 			range->freq[val].i = i + 1;
-			range->freq[val].m = rtllib_wlan_frequencies[i] *
-					     100000;
+			freq_khz = ieee80211_channel_to_freq_khz(i + 1, NL80211_BAND_2GHZ);
+			range->freq[val].m = freq_khz * 100;
 			range->freq[val].e = 1;
 			val++;
 		}
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index cdd7fdc5befe..87e9169214f6 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -2049,8 +2049,6 @@ void TsStartAddBaProcess(struct rtllib_device *ieee,
 void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
 void RemoveAllTS(struct rtllib_device *ieee);
 
-extern const long rtllib_wlan_frequencies[];
-
 static inline const char *escape_essid(const char *essid, u8 essid_len)
 {
 	static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index 6fd2e94d5f8a..d6d90e6ba2d3 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -15,15 +15,6 @@
 
 #include "rtllib.h"
 #include "dot11d.h"
-/* FIXME: add A freqs */
-
-const long rtllib_wlan_frequencies[] = {
-	2412, 2417, 2422, 2427,
-	2432, 2437, 2442, 2447,
-	2452, 2457, 2462, 2467,
-	2472, 2484
-};
-EXPORT_SYMBOL(rtllib_wlan_frequencies);
 
 int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
 			     union iwreq_data *wrqu, char *b)
@@ -83,8 +74,8 @@ int rtllib_wx_get_freq(struct rtllib_device *ieee,
 
 	if (ieee->current_network.channel == 0)
 		return -1;
-	fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel - 1] *
-		  100000;
+	fwrq->m = ieee80211_channel_to_freq_khz(ieee->current_network.channel,
+						NL80211_BAND_2GHZ) * 100;
 	fwrq->e = 1;
 	return 0;
 }
-- 
2.40.1


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

* Re: [PATCH 1/2] staging: rtl8192e: Use standard api to calculate frequency to channel
  2023-06-08  6:52 ` [PATCH 1/2] staging: rtl8192e: Use standard api to calculate frequency to channel Philipp Hortmann
@ 2023-06-15 10:46   ` Greg Kroah-Hartman
  2023-06-15 10:47     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-06-15 10:46 UTC (permalink / raw)
  To: Philipp Hortmann; +Cc: linux-staging, linux-kernel

On Thu, Jun 08, 2023 at 08:52:18AM +0200, Philipp Hortmann wrote:
> Use ieee80211_freq_khz_to_channel() to calculate frequency to channel to
> omit proprietary code.
> 
> Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
> ---
> Tested this code with separate debug code as this part is usually unused.
> ---
>  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> index 78a70e5f1974..6fd2e94d5f8a 100644
> --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> @@ -42,15 +42,8 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
>  	if (fwrq->e == 1) {
>  		if ((fwrq->m >= (int)2.412e8 &&
>  		     fwrq->m <= (int)2.487e8)) {
> -			int f = fwrq->m / 100000;
> -			int c = 0;
> -
> -			while ((c < 14) && (f != rtllib_wlan_frequencies[c]))
> -				c++;
> -
> -			/* hack to fall through */
> +			fwrq->m = ieee80211_freq_khz_to_channel(fwrq->m / 100);
>  			fwrq->e = 0;
> -			fwrq->m = c + 1;
>  		}
>  	}
>  
> -- 
> 2.40.1
> 
> 

Does not apply to my tree for some reason, can you rebase and resubmit?

thanks,

greg k-h

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

* Re: [PATCH 1/2] staging: rtl8192e: Use standard api to calculate frequency to channel
  2023-06-15 10:46   ` Greg Kroah-Hartman
@ 2023-06-15 10:47     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-06-15 10:47 UTC (permalink / raw)
  To: Philipp Hortmann; +Cc: linux-staging, linux-kernel

On Thu, Jun 15, 2023 at 12:46:05PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Jun 08, 2023 at 08:52:18AM +0200, Philipp Hortmann wrote:
> > Use ieee80211_freq_khz_to_channel() to calculate frequency to channel to
> > omit proprietary code.
> > 
> > Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
> > ---
> > Tested this code with separate debug code as this part is usually unused.
> > ---
> >  drivers/staging/rtl8192e/rtllib_softmac_wx.c | 9 +--------
> >  1 file changed, 1 insertion(+), 8 deletions(-)
> > 
> > diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> > index 78a70e5f1974..6fd2e94d5f8a 100644
> > --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> > +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> > @@ -42,15 +42,8 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
> >  	if (fwrq->e == 1) {
> >  		if ((fwrq->m >= (int)2.412e8 &&
> >  		     fwrq->m <= (int)2.487e8)) {
> > -			int f = fwrq->m / 100000;
> > -			int c = 0;
> > -
> > -			while ((c < 14) && (f != rtllib_wlan_frequencies[c]))
> > -				c++;
> > -
> > -			/* hack to fall through */
> > +			fwrq->m = ieee80211_freq_khz_to_channel(fwrq->m / 100);
> >  			fwrq->e = 0;
> > -			fwrq->m = c + 1;
> >  		}
> >  	}
> >  
> > -- 
> > 2.40.1
> > 
> > 
> 
> Does not apply to my tree for some reason, can you rebase and resubmit?

Nevermind, my fault, all is good now.

greg k-h

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

end of thread, other threads:[~2023-06-15 10:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-08  6:52 [PATCH 0/2] staging: rtl8192e: Use standard api to calculate frequency <-> channel Philipp Hortmann
2023-06-08  6:52 ` [PATCH 1/2] staging: rtl8192e: Use standard api to calculate frequency to channel Philipp Hortmann
2023-06-15 10:46   ` Greg Kroah-Hartman
2023-06-15 10:47     ` Greg Kroah-Hartman
2023-06-08  6:52 ` [PATCH 2/2] staging: rtl8192e: Use standard api to calculate channel to frequency Philipp Hortmann

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.