Refactor code to increase readability
v2 cover Refactor code to increase readability
The function get_right_chnl_for_iqk only requires Wifi channels from the 5GHz spectrum. Therefore, the 14 2GHz channels can be removed.
Vatika Harlalka (2):
Staging: rtl8188eu: Introduce new macro
Staging: rtl8188eu: Refactor code to increase readability
drivers/staging/rtl8188eu/hal/phy.c | 11 +++++------ drivers/staging/rtl8188eu/include/phy.h | 1 + 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/2 Introduce new macro
New macro is introduced for the number of channels in the 5GHz spectrum.
--- drivers/staging/rtl8188eu/include/phy.h | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/include/phy.h +1 -0
@@ -4,6 +4,7 @@#define index_mapping_NUM_88E 15#define AVG_THERMAL_NUM_88E 4#define ODM_TARGET_CHNL_NUM_2G_5G 59 +#define ODM_TARGET_CHNL_NUM_5G 45bool rtl88eu_phy_mac_config (struct adapter *adapt);bool rtl88eu_phy_rf_config (struct adapter *adapt);
Signature · 1 line
1.9.1
PATCH v2 2/2 Staging: rtl8188eu: Refactor code to increase readability
In reply to Vatika HarlalkaReduce the array size and modify the loop
counter so as to start from 0.
Also, the assignment of variable place is redundant as it is initialized again in the loop.
--- drivers/staging/rtl8188eu/hal/phy.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/rtl8188eu/hal/phy.c +5 -6
@@ -386,19 +386,18 @@ void phy_sw_chnl(struct adapter *adapt, u8 channel)static u8 get_right_chnl_for_iqk (u8 chnl) { -u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G ] = { -1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 , +u8 place; +u8 channel_5g[ODM_TARGET_CHNL_NUM_5G ] = {36 ,38 ,40 ,42 ,44 ,46 ,48 ,50 ,52 ,54 ,56 ,58 ,60 ,62 ,64 ,100 ,102 ,104 ,106 ,108 ,110 ,112 ,114 ,116 ,118 ,120 ,122 ,124 ,126 ,128 ,130 ,132 ,134 ,136 ,138 ,140 ,149 ,151 ,153 ,155 ,157 ,159 ,161 ,163 ,165 }; -u8 place = chnl;if (chnl >14 ) { -for (place =14 ; place <sizeof (channel_all); place++) { -if (channel_all[place] == chnl) -return place-13 ; +for (place =0 ; place <sizeof (channel_5g); place++) { +if (channel_5g[place] == chnl) +return ++place; } }return 0 ;
Signature · 1 line
1.9.1
Greg KH
maintainerRe: [Outreachy kernel] [PATCH 1/2 v2] Introduce new macro
In reply to Vatika HarlalkaQuoted 13 lines · Vatika Harlalka
New macro is introduced for the number of channels in the 5GHz spectrum.
Signed-off-by Vatika Harlalka <[email protected]>--- drivers/staging/rtl8188eu/include/phy.h | 1 + 1 file changed, 1 insertion(+)drivers/staging/rtl8188eu/include/phy.h +0
-0
drivers/staging/rtl8188eu/include/phy.h line 7
Quoted 4 lines
drivers/staging/rtl8188eu/include/phy.h +1
-0@@ -4,6 +4,7 @@#define index_mapping_NUM_88E 15#define AVG_THERMAL_NUM_88E 4#define ODM_TARGET_CHNL_NUM_2G_5G 59 +#define ODM_TARGET_CHNL_NUM_5G 45
Why do you need this? You aren't using it in this patch :(
Re: [Outreachy kernel] [PATCH 1/2 v2] Introduce new macro
Hi, thanks for your response!
I'm using this macro in /rtl8188eu/hal/phy.c ( in patch 2/2 ).
Quoted 1 line
u8 channel_5g[ODM_TARGET_CHNL_NUM_5G]
However, based on your response, I will make this array static const int, so I won't explicitly declare the size.
Should I resend a patch for this with just that fix?
Thanks a lot for your help!
Greg KH
maintainerRe: [Outreachy kernel] [PATCH 1/2 v2] Introduce new macro
Quoted 7 lines · Vatika Harlalka
Hi, thanks for your response!
I'm using this macro in� /rtl8188eu/hal/phy.c ( in patch 2/2 ).
Quoted 1 line
u8 channel_5g[ODM_TARGET_CHNL_NUM_5G]
However, based on your response, I will make this array static const int, so I won't explicitly declare the size.
Should I resend a patch for this with just that fix?
Why 'int'?
And watch out for your email client settings, you are sending html email which the linux-kernel mailing lists will reject.
thanks,
greg k-h
Re: [Outreachy kernel] [PATCH 1/2 v2] Introduce new macro
Oh sorry, if the array is declared as static const u8, the additional macro will not be required as we do not need the size in advance.