[1/2] staging: rtl8192e: Use standard api to calculate frequency to channel

Message ID fc332e81f6677965e9e51f1fcef9815997effcb5.1686166624.git.philipp.g.hortmann@gmail.com
State New
Headers
Series staging: rtl8192e: Use standard api to calculate frequency <-> channel |

Commit Message

Philipp Hortmann June 8, 2023, 6:52 a.m. UTC
  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(-)
  

Comments

Greg KH June 15, 2023, 10:46 a.m. UTC | #1
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
  
Greg KH June 15, 2023, 10:47 a.m. UTC | #2
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
  

Patch

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;
 		}
 	}