staging: wilc1000: fix return type of wilc_send_config_pkt
PATCH v2 1/4 staging: wilc1000: fix return type of wilc_send_config_pkt
wilc_send_config_pkt is returned 0 or -ETIMEDOUT according to return value of wilc_wlan_cfg_set or wilc_wlan_cfg_set.
It is better to use int type to represent linux standard error code.
---
v2: rebase latest staging-testing
drivers/staging/wilc1000/wilc_wlan.c | 5 +++-- drivers/staging/wilc1000/wilc_wlan.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/staging/wilc1000/wilc_wlan.c +3 -2
@@ -1349,10 +1349,11 @@ int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size)return ret; } -s32 wilc_send_config_pkt (struct wilc_vif *vif,u8 mode,struct wid *wids, +int wilc_send_config_pkt (struct wilc_vif *vif,u8 mode,struct wid *wids,u32 count,u32 drv) { -s32 counter =0 , ret =0 ; +s32 counter =0 ; +int ret =0 ;if (mode ==GET_CFG ) {for (counter =0 ; counter < count; counter++) {
drivers/staging/wilc1000/wilc_wlan.h +1 -1
@@ -301,6 +301,6 @@ void host_sleep_notify(struct wilc *wilc);extern bool wilc_enable_ps;void chip_allow_sleep (struct wilc *wilc);void chip_wakeup (struct wilc *wilc); -s32 wilc_send_config_pkt (struct wilc_vif *vif,u8 mode,struct wid *wids, +int wilc_send_config_pkt (struct wilc_vif *vif,u8 mode,struct wid *wids,u32 count,u32 drv);#endif
Signature · 1 line
2.7.1
PATCH v2 2/4 staging: wilc1000: use int type for counter variable
counter is used as for-loop control variable and indicating index of struct wid array so that it is better to use int type. There is no need to set to 0 when it is declared at the top of this function. It is initialized as 0 in for-loop statement.
---
v2: rebase latest staging-testing
drivers/staging/wilc1000/wilc_wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/wilc_wlan.c +1 -1
@@ -1352,7 +1352,7 @@ int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size)int wilc_send_config_pkt (struct wilc_vif *vif,u8 mode,struct wid *wids,u32 count,u32 drv) { -s32 counter =0 ; +int counter;int ret =0 ;if (mode ==GET_CFG ) {
Signature · 1 line
2.7.1
PATCH v2 3/4 staging: wilc1000: remove initialization code of counter variable
In reply to Chaehyun LimThere is no need to set to 0 for counter variable before entering next for-loop statement because counter is initialized again in for-loop statement, so just remove it.
---
v2: rebase latest staging-testing
drivers/staging/wilc1000/wilc_wlan.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/wilc1000/wilc_wlan.c +0 -1
@@ -1365,7 +1365,6 @@ int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids,break ; } } - counter =0 ;for (counter =0 ; counter < count; counter++) { wids[counter].size = wilc_wlan_cfg_get_val( wids[counter].id,
Signature · 1 line
2.7.1
PATCH v2 4/4 staging: wilc1000: rename counter in wilc_send_config_pkt
In reply to Chaehyun LimThis patch renames the name of counter variable to i.
This change makes more readability because wilc_send_config_pkt has a similar argument name as count.
---
v2: rebase latest staging-testing
drivers/staging/wilc1000/wilc_wlan.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/staging/wilc1000/wilc_wlan.c +15 -16
@@ -1352,32 +1352,31 @@ int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size)int wilc_send_config_pkt (struct wilc_vif *vif,u8 mode,struct wid *wids,u32 count,u32 drv) { -int counter; +int i;int ret =0 ;if (mode ==GET_CFG ) { -for (counter =0 ; counter < count; counter++) { -if (!wilc_wlan_cfg_get (vif, !counter, - wids[counter].id, - (counter == count -1 ), +for (i =0 ; i < count; i++) { +if (!wilc_wlan_cfg_get (vif, !i, + wids[i].id, + (i == count -1 ), drv)) { ret = -ETIMEDOUT ;break ; } } -for (counter =0 ; counter < count; counter++) { - wids[counter].size =wilc_wlan_cfg_get_val ( - wids[counter].id, - wids[counter].val, - wids[counter].size); +for (i =0 ; i < count; i++) { + wids[i].size =wilc_wlan_cfg_get_val (wids[i].id, + wids[i].val, + wids[i].size); } }else if (mode ==SET_CFG ) { -for (counter =0 ; counter < count; counter++) { -if (!wilc_wlan_cfg_set (vif, !counter, - wids[counter].id, - wids[counter].val, - wids[counter].size, - (counter == count -1 ), +for (i =0 ; i < count; i++) { +if (!wilc_wlan_cfg_set (vif, !i, + wids[i].id, + wids[i].val, + wids[i].size, + (i == count -1 ), drv)) { ret = -ETIMEDOUT ;break ;
Signature · 1 line
2.7.1