staging: rtl8192e: Remove constant variable channel_plan
cover staging: rtl8192e: Remove constant variable channel_plan
Remove constant variable channel_plan to increase readability of the code.
Tested with rtl8192e (WLL6130-D99) in Mode n (12.5 MB/s) Transferred this patch over wlan connection of rtl8192e. Tested on Channels: 1, 2, 10, 13
Philipp Hortmann (10):
staging: rtl8192e: Remove unused return value of rtl92e_set_channel()
staging: rtl8192e: Change parameter "ch" of set_chan() to u8
staging: rtl8192e: Unwind pointer to pointer to rtl92e_set_channel()
staging: rtl8192e: Remove equation that results in constant for
chnl_plan
staging: rtl8192e: Remove constant variable chnl_plan
staging: rtl8192e: Remove unused variable eeprom_chnl_plan
staging: rtl8192e: Remove equation to check limits of channel
staging: rtl8192e: Remove check if channel_array[channel_plan].len !=
0
staging: rtl8192e: Remove switch for a constant in
dot11d_channel_map()staging: rtl8192e: Remove constant index from channel_array[]
drivers/staging/rtl8192e/dot11d.c | 63 +++---------------- drivers/staging/rtl8192e/dot11d.h | 2 +- .../staging/rtl8192e/rtl8192e/r8192E_dev.c | 12 ---- .../staging/rtl8192e/rtl8192e/r8192E_phy.c | 12 ++-- .../staging/rtl8192e/rtl8192e/r8192E_phy.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 20 +----- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 4 -- drivers/staging/rtl8192e/rtllib.h | 2 +- 8 files changed, 21 insertions(+), 96 deletions(-)
Signature · 1 line
2.42.0
PATCH 1/10 staging: rtl8192e: Remove unused return value of rtl92e_set_channel()
Remove unused return value of rtl92e_set_channel().
--- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 12 ++++++------ drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +6 -6
@@ -671,16 +671,16 @@ static void _rtl92e_phy_switch_channel_work_item(struct net_device *dev)_rtl92e_phy_switch_channel (dev, priv->chan); } -u8 rtl92e_set_channel (struct net_device *dev,u8 channel) +void rtl92e_set_channel (struct net_device *dev,u8 channel) {struct r8192_priv *priv =rtllib_priv (dev);if (!priv->up) {netdev_err (dev,"%s(): Driver is not initialized\n" , __func__); -return false; +return ; }if (priv->sw_chnl_in_progress) -return false; +return ;switch (priv->rtllib->mode) {case WIRELESS_MODE_B :
@@ -688,7 +688,7 @@ u8 rtl92e_set_channel(struct net_device *dev, u8 channel)netdev_warn (dev,"Channel %d not available in 802.11b.\n" , channel); -return false; +return ; }break ;case WIRELESS_MODE_G :
@@ -697,7 +697,7 @@ u8 rtl92e_set_channel(struct net_device *dev, u8 channel)netdev_warn (dev,"Channel %d not available in 802.11g.\n" , channel); -return false; +return ; }break ; }
@@ -714,7 +714,7 @@ u8 rtl92e_set_channel(struct net_device *dev, u8 channel)if (priv->up)_rtl92e_phy_switch_channel_work_item (dev); priv->sw_chnl_in_progress = false; -return true; +return ; }static void _rtl92e_cck_tx_power_track_bw_switch_tssi (struct net_device *dev)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h +1 -1
@@ -41,7 +41,7 @@ void rtl92e_get_tx_power(struct net_device *dev);void rtl92e_set_tx_power (struct net_device *dev,u8 channel);u8 rtl92e_config_rf_path (struct net_device *dev,enum rf90_radio_path eRFPath); -u8 rtl92e_set_channel (struct net_device *dev,u8 channel); +void rtl92e_set_channel (struct net_device *dev,u8 channel);void rtl92e_set_bw_mode (struct net_device *dev,enum ht_channel_width bandwidth,enum ht_extchnl_offset Offset);
drivers/staging/rtl8192e/rtl8192e/rtl_core.h +1 -1
@@ -228,7 +228,7 @@ struct r8192_priv {struct rt_stats stats;struct iw_statistics wstats; -u8 (*rf_set_chan)(struct net_device *dev,u8 ch); +void (*rf_set_chan)(struct net_device *dev,u8 ch);struct rx_desc *rx_ring;struct sk_buff *rx_buf[MAX_RX_COUNT ];
Signature · 1 line
2.42.0
PATCH 2/10 staging: rtl8192e: Change parameter "ch" of set_chan() to u8
In reply to Philipp HortmannChange parameter "ch" of set_chan() to u8 to combine functions in the following patch.
--- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +1 -1
@@ -226,7 +226,7 @@ static void _rtl92e_tx_timeout(struct net_device *dev, unsigned int txqueue)netdev_info (dev,"TXTIMEOUT" ); } -static void _rtl92e_set_chan (struct net_device *dev,short ch) +static void _rtl92e_set_chan (struct net_device *dev,u8 ch) {struct r8192_priv *priv =rtllib_priv (dev);
drivers/staging/rtl8192e/rtllib.h +1 -1
@@ -1469,7 +1469,7 @@ struct rtllib_device {* This function can sleep. the driver should ensure * the radio has been switched before return. */ -void (*set_chan)(struct net_device *dev,short ch); +void (*set_chan)(struct net_device *dev,u8 ch);/* indicate the driver that the link state is changed * for example it may indicate the card is associated now.
Signature · 1 line
2.42.0
PATCH 3/10 staging: rtl8192e: Unwind pointer to pointer to rtl92e_set_channel()
In reply to Philipp HortmannReplace pointer to function to pointer to rtl92e_set_channel() with pointer to rtl92e_set_channel(). This increases readability of the code.
--- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 13 +------------ drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 -- 2 files changed, 1 insertion(+), 14 deletions(-)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +1 -12
@@ -226,16 +226,6 @@ static void _rtl92e_tx_timeout(struct net_device *dev, unsigned int txqueue)netdev_info (dev,"TXTIMEOUT" ); } -static void _rtl92e_set_chan (struct net_device *dev,u8 ch) -{ -struct r8192_priv *priv =rtllib_priv (dev); - - priv->chan = ch; - -if (priv->rf_set_chan) - priv->rf_set_chan (dev, priv->chan); -} -static void _rtl92e_update_cap (struct net_device *dev,u16 cap) {struct r8192_priv *priv =rtllib_priv (dev);
@@ -685,7 +675,7 @@ static void _rtl92e_init_priv_handler(struct net_device *dev)struct r8192_priv *priv =rtllib_priv (dev); priv->rtllib->softmac_hard_start_xmit = _rtl92e_hard_start_xmit; - priv->rtllib->set_chan = _rtl92e_set_chan; + priv->rtllib->set_chan = rtl92e_set_channel; priv->rtllib->link_change = rtl92e_link_change; priv->rtllib->softmac_data_hard_start_xmit = _rtl92e_hard_data_xmit; priv->rtllib->check_nic_enough_desc = _rtl92e_check_nic_enough_desc;
@@ -694,7 +684,6 @@ static void _rtl92e_init_priv_handler(struct net_device *dev) priv->rtllib->set_wireless_mode = rtl92e_set_wireless_mode; priv->rtllib->leisure_ps_leave = rtl92e_leisure_ps_leave; priv->rtllib->set_bw_mode_handler = rtl92e_set_bw_mode; - priv->rf_set_chan = rtl92e_set_channel; priv->rtllib->sta_wake_up = rtl92e_hw_wakeup; priv->rtllib->enter_sleep_state = rtl92e_enter_sleep;
drivers/staging/rtl8192e/rtl8192e/rtl_core.h +0 -2
@@ -228,8 +228,6 @@ struct r8192_priv {struct rt_stats stats;struct iw_statistics wstats; -void (*rf_set_chan)(struct net_device *dev,u8 ch); -struct rx_desc *rx_ring;struct sk_buff *rx_buf[MAX_RX_COUNT ];dma_addr_t rx_ring_dma;
Signature · 1 line
2.42.0
PATCH 4/10 staging: rtl8192e: Remove equation that results in constant for chnl_plan
In reply to Philipp HortmannRemove equation for chnl_plan as the last line sets chnl_plan to a constant.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +0 -8
@@ -387,23 +387,15 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev)rtl92e_init_adaptive_rate (dev); - priv->chnl_plan = priv->eeprom_chnl_plan; -switch (priv->eeprom_customer_id) {case EEPROM_CID_NetCore: priv->customer_id =RT_CID_819X_NETCORE ;break ;case EEPROM_CID_TOSHIBA : priv->customer_id =RT_CID_TOSHIBA ; -if (priv->eeprom_chnl_plan &0x80 ) - priv->chnl_plan = priv->eeprom_chnl_plan &0x7f ; -else - priv->chnl_plan =0x0 ;break ; } -if (priv->chnl_plan >CHANNEL_PLAN_LEN -1 ) - priv->chnl_plan =0 ; priv->chnl_plan =COUNTRY_CODE_WORLD_WIDE_13 ;if (priv->eeprom_vid ==0x1186 && priv->eeprom_did ==0x3304 )
Signature · 1 line
2.42.0
PATCH 5/10 staging: rtl8192e: Remove constant variable chnl_plan
In reply to Philipp HortmannRemove constant variable chnl_plan and replace it with its constant. Remove equation that limits maximum value of chnl_plan as it is always false.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 -- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 7 +------ drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 1 - 3 files changed, 1 insertion(+), 9 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +0 -2
@@ -396,8 +396,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev)break ; } - priv->chnl_plan =COUNTRY_CODE_WORLD_WIDE_13 ; -if (priv->eeprom_vid ==0x1186 && priv->eeprom_did ==0x3304 ) priv->rtllib->bSupportRemoteWakeUp = true;else
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +1 -6
@@ -795,13 +795,8 @@ static short _rtl92e_get_channel_map(struct net_device *dev)struct r8192_priv *priv =rtllib_priv (dev); -if (priv->chnl_plan >=COUNTRY_CODE_MAX ) { -netdev_info (dev, -"rtl819x_init:Error channel plan! Set to default.\n" ); - priv->chnl_plan =COUNTRY_CODE_FCC ; - }dot11d_init (priv->rtllib); -dot11d_channel_map (priv->chnl_plan, priv->rtllib); +dot11d_channel_map (COUNTRY_CODE_WORLD_WIDE_13 , priv->rtllib);for (i =1 ; i <=11 ; i++) (priv->rtllib->active_channel_map)[i] =1 ; (priv->rtllib->active_channel_map)[12 ] =2 ;
drivers/staging/rtl8192e/rtl8192e/rtl_core.h +0 -1
@@ -310,7 +310,6 @@ struct r8192_priv {bool tx_pwr_data_read_from_eeprom; -u16 chnl_plan;u8 hw_rf_off_action;bool rf_change_in_progress;
Signature · 1 line
2.42.0
PATCH 6/10 staging: rtl8192e: Remove unused variable eeprom_chnl_plan
In reply to Philipp HortmannRemove unused variable eeprom_chnl_plan.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 -- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 1 - 2 files changed, 3 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +0 -2
@@ -261,7 +261,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->eeprom_customer_id = usValue &0xff ; usValue =rtl92e_eeprom_read (dev, EEPROM_ICVersion_ChannelPlan >>1 ); - priv->eeprom_chnl_plan = usValue &0xff ; IC_Version = (usValue &0xff00 ) >>8 ; ICVer8192 = IC_Version &0xf ;
@@ -283,7 +282,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->eeprom_vid =0 ; priv->eeprom_did =0 ; priv->eeprom_customer_id =0 ; - priv->eeprom_chnl_plan =0 ; }if (!priv->autoload_fail_flag) {
drivers/staging/rtl8192e/rtl8192e/rtl_core.h +0 -1
@@ -284,7 +284,6 @@ struct r8192_priv {u16 eeprom_vid;u16 eeprom_did;u8 eeprom_customer_id; -u16 eeprom_chnl_plan;u8 eeprom_tx_pwr_level_cck[14 ];u8 eeprom_tx_pwr_level_ofdm24g[14 ];
Signature · 1 line
2.42.0
PATCH 7/10 staging: rtl8192e: Remove equation to check limits of channel
In reply to Philipp Hortmannchannel_plan is constant COUNTRY_CODE_WORLD_WIDE_13. Remove equation to check limits of channel as those are always in limit.
--- drivers/staging/rtl8192e/dot11d.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/rtl8192e/dot11d.c +1 -4
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(dot11d_init);void dot11d_channel_map (u8 channel_plan,struct rtllib_device *ieee) { -int i, max_chan =14 , min_chan =1 ; +int i; ieee->global_domain = false;
@@ -59,9 +59,6 @@ void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee)memset (GET_DOT11D_INFO (ieee)->channel_map,0 ,sizeof (GET_DOT11D_INFO (ieee)->channel_map));for (i =0 ; i < channel_array[channel_plan].len; i++) { -if (channel_array[channel_plan].channel[i] < min_chan || - channel_array[channel_plan].channel[i] > max_chan) -break ;GET_DOT11D_INFO (ieee)->channel_map[channel_array [channel_plan].channel[i]] =1 ; }
Signature · 1 line
2.42.0
PATCH 8/10 staging: rtl8192e: Remove check if channel_array[channel_plan].len != 0
In reply to Philipp Hortmannchannel_plan is constant COUNTRY_CODE_WORLD_WIDE_13. Remove equation to check length of array as it is always not 0.
--- drivers/staging/rtl8192e/dot11d.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/staging/rtl8192e/dot11d.c +5 -7
@@ -55,13 +55,11 @@ void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee) ieee->global_domain = false; -if (channel_array[channel_plan].len !=0 ) { -memset (GET_DOT11D_INFO (ieee)->channel_map,0 , -sizeof (GET_DOT11D_INFO (ieee)->channel_map)); -for (i =0 ; i < channel_array[channel_plan].len; i++) { -GET_DOT11D_INFO (ieee)->channel_map[channel_array - [channel_plan].channel[i]] =1 ; - } +memset (GET_DOT11D_INFO (ieee)->channel_map,0 , +sizeof (GET_DOT11D_INFO (ieee)->channel_map)); +for (i =0 ; i < channel_array[channel_plan].len; i++) { +GET_DOT11D_INFO (ieee)->channel_map[channel_array + [channel_plan].channel[i]] =1 ; }switch (channel_plan) {
Signature · 1 line
2.42.0
PATCH 9/10 staging: rtl8192e: Remove switch for a constant in dot11d_channel_map()
In reply to Philipp HortmannRemove switch for a constant in dot11d_channel_map() as the result will always be the same.
--- drivers/staging/rtl8192e/dot11d.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
drivers/staging/rtl8192e/dot11d.c +3 -18
@@ -62,24 +62,9 @@ void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee) [channel_plan].channel[i]] = 1; } -switch (channel_plan) { -case COUNTRY_CODE_GLOBAL_DOMAIN : - ieee->global_domain = true; -for (i =12 ; i <=14 ; i++) -GET_DOT11D_INFO (ieee)->channel_map[i] =2 ; - ieee->bss_start_channel =10 ; -break ; - -case COUNTRY_CODE_WORLD_WIDE_13 : -for (i =12 ; i <=13 ; i++) -GET_DOT11D_INFO (ieee)->channel_map[i] =2 ; - ieee->bss_start_channel =10 ; -break ; - -default : - ieee->bss_start_channel =1 ; -break ; - } +for (i =12 ; i <=13 ; i++) +GET_DOT11D_INFO (ieee)->channel_map[i] =2 ; + ieee->bss_start_channel =10 ; }EXPORT_SYMBOL (dot11d_channel_map);
Signature · 1 line
2.42.0
PATCH 10/10 staging: rtl8192e: Remove constant index from channel_array[]
In reply to Philipp HortmannUsed index of channel_array[] is always COUNTRY_CODE_WORLD_WIDE_13. Remove index and store only used entry in channel_array. This shortens the code and increases readability.
--- drivers/staging/rtl8192e/dot11d.c | 31 +++----------------- drivers/staging/rtl8192e/dot11d.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- 3 files changed, 6 insertions(+), 29 deletions(-)
drivers/staging/rtl8192e/dot11d.c +4 -27
@@ -12,28 +12,7 @@ struct channel_list {u8 len; }; -static struct channel_list channel_array[] = { - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,36 ,40 ,44 ,48 ,52 ,56 ,60 ,64 , -149 ,153 ,157 ,161 ,165 },24 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 },11 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,36 ,40 ,44 ,48 ,52 ,56 , -60 ,64 },21 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 },13 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 },13 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,36 ,40 ,44 ,48 ,52 , -56 ,60 ,64 },22 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,36 ,40 ,44 ,48 ,52 , -56 ,60 ,64 },22 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 },13 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,36 ,40 ,44 ,48 ,52 , -56 ,60 ,64 },22 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,36 ,40 ,44 ,48 ,52 , -56 ,60 ,64 },22 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 },14 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 },13 }, - {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,36 ,40 ,44 ,48 ,52 , -56 ,60 ,64 },21 } -}; +static struct channel_list channel_array = {{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 },13 };void dot11d_init (struct rtllib_device *ieee) {
@@ -49,7 +28,7 @@ void dot11d_init(struct rtllib_device *ieee) }EXPORT_SYMBOL (dot11d_init); -void dot11d_channel_map (u8 channel_plan,struct rtllib_device *ieee) +void dot11d_channel_map (struct rtllib_device *ieee) {int i;
@@ -57,10 +36,8 @@ void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee)memset (GET_DOT11D_INFO (ieee)->channel_map,0 ,sizeof (GET_DOT11D_INFO (ieee)->channel_map)); -for (i =0 ; i < channel_array[channel_plan].len; i++) { -GET_DOT11D_INFO (ieee)->channel_map[channel_array - [channel_plan].channel[i]] =1 ; - } +for (i =0 ; i < channel_array.len; i++) +GET_DOT11D_INFO (ieee)->channel_map[channel_array.channel[i]] =1 ;for (i =12 ; i <=13 ; i++)GET_DOT11D_INFO (ieee)->channel_map[i] =2 ;
drivers/staging/rtl8192e/dot11d.h +1 -1
@@ -75,7 +75,7 @@ static inline void RESET_CIE_WATCHDOG(struct rtllib_device *__ieee_dev)#define UPDATE_CIE_WATCHDOG (__ieee_dev) (++GET_CIE_WATCHDOG(__ieee_dev))void dot11d_init (struct rtllib_device *dev); -void dot11d_channel_map (u8 channel_plan,struct rtllib_device *ieee); +void dot11d_channel_map (struct rtllib_device *ieee);void dot11d_reset (struct rtllib_device *dev);void dot11d_update_country (struct rtllib_device *dev,u8 *address,u16 country_len,u8 *country);
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +1 -1
@@ -796,7 +796,7 @@ static short _rtl92e_get_channel_map(struct net_device *dev)struct r8192_priv *priv =rtllib_priv (dev);dot11d_init (priv->rtllib); -dot11d_channel_map (COUNTRY_CODE_WORLD_WIDE_13 , priv->rtllib); +dot11d_channel_map (priv->rtllib);for (i =1 ; i <=11 ; i++) (priv->rtllib->active_channel_map)[i] =1 ; (priv->rtllib->active_channel_map)[12 ] =2 ;
Signature · 1 line
2.42.0