summaryrefslogtreecommitdiffstats
path: root/drivers/staging/wilc1000
diff options
context:
space:
mode:
authorAjay Singh2018-09-25 08:23:43 +0200
committerGreg Kroah-Hartman2018-09-25 20:53:57 +0200
commitba853fe6f8a4657ec675d53a34d6bc6cbb7d1638 (patch)
tree59482a70377a9d1de685b529988c7eca18055ea7 /drivers/staging/wilc1000
parentstaging: wilc1000: use usleep_range() in place of udelay() (diff)
downloadkernel-qcow2-linux-ba853fe6f8a4657ec675d53a34d6bc6cbb7d1638.tar.gz
kernel-qcow2-linux-ba853fe6f8a4657ec675d53a34d6bc6cbb7d1638.tar.xz
kernel-qcow2-linux-ba853fe6f8a4657ec675d53a34d6bc6cbb7d1638.zip
staging: wilc1000: refactor wilc_set_multicast_list() function
Refactor wilc_set_multicast_list() by making below changes: o use kmalloc_array o remove unnecessary res o add u8 *cur_mc o use i as index o use '%pM' extension in netdev_dbg() The below checkpatch issue is also resolved after code refactor. 'spaces preferred around that '/' (ctx:VxV)' Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Ajay Singh <ajay.kathat@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wilc1000')
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index e2093b8298e2..5346717e8c26 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -796,9 +796,9 @@ static void wilc_set_multicast_list(struct net_device *dev)
{
struct netdev_hw_addr *ha;
struct wilc_vif *vif = netdev_priv(dev);
- int i = 0;
+ int i;
u8 *mc_list;
- int res;
+ u8 *cur_mc;
if (dev->flags & IFF_PROMISC)
return;
@@ -814,20 +814,20 @@ static void wilc_set_multicast_list(struct net_device *dev)
return;
}
- mc_list = kmalloc(dev->mc.count * ETH_ALEN, GFP_KERNEL);
+ mc_list = kmalloc_array(dev->mc.count, ETH_ALEN, GFP_KERNEL);
if (!mc_list)
return;
+ cur_mc = mc_list;
+ i = 0;
netdev_for_each_mc_addr(ha, dev) {
- memcpy(mc_list + i, ha->addr, ETH_ALEN);
- netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i/ETH_ALEN,
- mc_list[i], mc_list[i + 1], mc_list[i + 2],
- mc_list[i + 3], mc_list[i + 4], mc_list[i + 5]);
- i += ETH_ALEN;
+ memcpy(cur_mc, ha->addr, ETH_ALEN);
+ netdev_dbg(dev, "Entry[%d]: %pM\n", i, cur_mc);
+ i++;
+ cur_mc += ETH_ALEN;
}
- res = wilc_setup_multicast_filter(vif, true, dev->mc.count, mc_list);
- if (res)
+ if (wilc_setup_multicast_filter(vif, true, dev->mc.count, mc_list))
kfree(mc_list);
}