staging: wilc1000: handle_set_mac_address: remove debug message of kmalloc failure
PATCH 1/7 staging: wilc1000: handle_set_mac_address: remove debug message of kmalloc failure
There is no need to print debug message when kmalloc is failed. This message is redundant. The code already show us that kmalloc is failed. The brace of if statement is remove as well due to have a single statement.
--- drivers/staging/wilc1000/host_interface.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/wilc1000/host_interface.c +2 -3
@@ -431,10 +431,9 @@ static s32 handle_set_mac_address(struct wilc_vif *vif,struct wid wid;u8 *mac_buf =kmalloc (ETH_ALEN ,GFP_KERNEL ); -if (!mac_buf) { -PRINT_ER ("No buffer to send mac address\n" ); +if (!mac_buf)return -EFAULT ; - } +memcpy (mac_buf, set_mac_addr->mac_addr,ETH_ALEN ); wid.id = (u16 )WID_MAC_ADDR ;
Signature · 1 line
2.7.1
PATCH 2/7 staging: wilc1000: handle_set_mac_address: fix kmalloc return error code
This patch fix return error code of kmalloc as -ENOMEM instead of -EFAULT.
--- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/host_interface.c +1 -1
@@ -432,7 +432,7 @@ static s32 handle_set_mac_address(struct wilc_vif *vif,u8 *mac_buf =kmalloc (ETH_ALEN ,GFP_KERNEL );if (!mac_buf) -return -EFAULT ; +return -ENOMEM ;memcpy (mac_buf, set_mac_addr->mac_addr,ETH_ALEN );
Signature · 1 line
2.7.1
PATCH 3/7 staging: wilc1000: handle_set_mac_address: use kmemdup
In reply to Chaehyun LimThis patch replaces kmalloc followed by memcpy with kmemdup.
--- drivers/staging/wilc1000/host_interface.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/wilc1000/host_interface.c +1 -3
@@ -429,13 +429,11 @@ static s32 handle_set_mac_address(struct wilc_vif *vif, {s32 result =0 ;struct wid wid; -u8 *mac_buf =kmalloc (ETH_ALEN ,GFP_KERNEL ); +u8 *mac_buf =kmemdup (set_mac_addr->mac_addr,ETH_ALEN ,GFP_KERNEL );if (!mac_buf)return -ENOMEM ; -memcpy (mac_buf, set_mac_addr->mac_addr,ETH_ALEN ); - wid.id = (u16 )WID_MAC_ADDR ; wid.type =WID_STR ; wid.val = mac_buf;
Signature · 1 line
2.7.1
PATCH 4/7 staging: wilc1000: handle_set_mac_address: change return type to void
In reply to Chaehyun LimWhen handle_set_mac_address is called in hostIFthread that is a kernel thread, it is not checked return type of this function. This patch changes return type to void and removes a brace of if statement due to have a single statement.
--- drivers/staging/wilc1000/host_interface.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/wilc1000/host_interface.c +4 -7
@@ -424,15 +424,15 @@ static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)return result; } -static s32 handle_set_mac_address (struct wilc_vif *vif, -struct set_mac_addr *set_mac_addr) +static void handle_set_mac_address (struct wilc_vif *vif, +struct set_mac_addr *set_mac_addr) {s32 result =0 ;struct wid wid;u8 *mac_buf =kmemdup (set_mac_addr->mac_addr,ETH_ALEN ,GFP_KERNEL );if (!mac_buf) -return -ENOMEM ; +return ; wid.id = (u16 )WID_MAC_ADDR ; wid.type =WID_STR ;
@@ -441,13 +441,10 @@ static s32 handle_set_mac_address(struct wilc_vif *vif, result =wilc_send_config_pkt (vif,SET_CFG , &wid,1 ,wilc_get_vif_idx (vif)); -if (result) { +if (result)PRINT_ER ("Failed to set mac address\n" ); - result = -EFAULT ; - }kfree (mac_buf); -return result; } static s32 handle_get_mac_address(struct wilc_vif *vif,
Signature · 1 line
2.7.1
PATCH 5/7 staging: wilc1000: handle_set_mac_address: change data type of result
In reply to Chaehyun Limresult variable gets value from wilc_send_config_pkt that has return value of int. This patch changes data type of result variable to int.
--- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/host_interface.c +1 -1
@@ -427,7 +427,7 @@ static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)static void handle_set_mac_address (struct wilc_vif *vif,struct set_mac_addr *set_mac_addr) { -s32 result =0 ; +int result =0 ;struct wid wid;u8 *mac_buf =kmemdup (set_mac_addr->mac_addr,ETH_ALEN ,GFP_KERNEL );
Signature · 1 line
2.7.1
PATCH 6/7 staging: wilc1000: handle_set_mac_address: rename result
In reply to Chaehyun LimThis patch renames result to ret that is used to get return value from wilc_send_config_pkt. It will be changed until all handle_*() function has same variable name as ret.
--- drivers/staging/wilc1000/host_interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/wilc1000/host_interface.c +4 -4
@@ -427,7 +427,7 @@ static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)static void handle_set_mac_address (struct wilc_vif *vif,struct set_mac_addr *set_mac_addr) { -int result =0 ; +int ret =0 ;struct wid wid;u8 *mac_buf =kmemdup (set_mac_addr->mac_addr,ETH_ALEN ,GFP_KERNEL );
@@ -439,9 +439,9 @@ static void handle_set_mac_address(struct wilc_vif *vif, wid.val = mac_buf; wid.size =ETH_ALEN ; - result =wilc_send_config_pkt (vif,SET_CFG , &wid,1 , -wilc_get_vif_idx (vif)); -if (result) + ret =wilc_send_config_pkt (vif,SET_CFG , &wid,1 , +wilc_get_vif_idx (vif)); +if (ret)PRINT_ER ("Failed to set mac address\n" );kfree (mac_buf);
Signature · 1 line
2.7.1
PATCH 7/7 staging: wilc1000: handle_set_mac_address: use netdev_err
In reply to Chaehyun LimThis patch uses netdev_err instead of PRINT_ER that is a custom debug print.
--- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/host_interface.c +1 -1
@@ -442,7 +442,7 @@ static void handle_set_mac_address(struct wilc_vif *vif, ret =wilc_send_config_pkt (vif,SET_CFG , &wid,1 ,wilc_get_vif_idx (vif));if (ret) -PRINT_ER ("Failed to set mac address\n" ); +netdev_err (vif->ndev,"Failed to set mac address\n" );kfree (mac_buf); }
Signature · 1 line
2.7.1