summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorAjay Singh <ajay.kathat@microchip.com>2019-01-17 13:21:41 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-18 10:39:16 +0100
commita0c6a32e78a078fd5fa589ae2670155088e3a741 (patch)
tree323928d95fe0a5b36beb015c640ad60fa871e480 /drivers/staging
parent03cf31c41c2206731100aad51b98142b9e131fbb (diff)
staging: wilc1000: refactor handle_set_mcast_filter()
Refactor handle_set_mcast_filter() by making use of put_unaligned32() to pack the data instead of byte operation. Signed-off-by: Ajay Singh <ajay.kathat@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/wilc1000/host_interface.c37
-rw-r--r--drivers/staging/wilc1000/host_interface.h2
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c6
3 files changed, 20 insertions, 25 deletions
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index fa3af2c6bee6..f4638654d1a5 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -15,8 +15,8 @@ struct wilc_rcvd_mac_info {
u8 status;
};
-struct set_multicast {
- bool enabled;
+struct wilc_set_multicast {
+ u32 enabled;
u32 cnt;
u8 *mc_list;
};
@@ -71,7 +71,7 @@ struct wilc_gtk_key {
union message_body {
struct wilc_rcvd_net_info net_info;
struct wilc_rcvd_mac_info mac_info;
- struct set_multicast multicast_info;
+ struct wilc_set_multicast mc_info;
struct remain_ch remain_on_ch;
char *data;
};
@@ -1067,32 +1067,27 @@ static void handle_set_mcast_filter(struct work_struct *work)
{
struct host_if_msg *msg = container_of(work, struct host_if_msg, work);
struct wilc_vif *vif = msg->vif;
- struct set_multicast *hif_set_mc = &msg->body.multicast_info;
+ struct wilc_set_multicast *set_mc = &msg->body.mc_info;
int result;
struct wid wid;
u8 *cur_byte;
wid.id = WID_SETUP_MULTICAST_FILTER;
wid.type = WID_BIN;
- wid.size = sizeof(struct set_multicast) + (hif_set_mc->cnt * ETH_ALEN);
+ wid.size = sizeof(struct wilc_set_multicast) + (set_mc->cnt * ETH_ALEN);
wid.val = kmalloc(wid.size, GFP_KERNEL);
if (!wid.val)
goto error;
cur_byte = wid.val;
- *cur_byte++ = (hif_set_mc->enabled & 0xFF);
- *cur_byte++ = 0;
- *cur_byte++ = 0;
- *cur_byte++ = 0;
+ put_unaligned_le32(set_mc->enabled, cur_byte);
+ cur_byte += 4;
- *cur_byte++ = (hif_set_mc->cnt & 0xFF);
- *cur_byte++ = ((hif_set_mc->cnt >> 8) & 0xFF);
- *cur_byte++ = ((hif_set_mc->cnt >> 16) & 0xFF);
- *cur_byte++ = ((hif_set_mc->cnt >> 24) & 0xFF);
+ put_unaligned_le32(set_mc->cnt, cur_byte);
+ cur_byte += 4;
- if (hif_set_mc->cnt > 0 && hif_set_mc->mc_list)
- memcpy(cur_byte, hif_set_mc->mc_list,
- ((hif_set_mc->cnt) * ETH_ALEN));
+ if (set_mc->cnt > 0 && set_mc->mc_list)
+ memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN);
result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1,
wilc_get_vif_idx(vif));
@@ -1100,7 +1095,7 @@ static void handle_set_mcast_filter(struct work_struct *work)
netdev_err(vif->ndev, "Failed to send setup multicast\n");
error:
- kfree(hif_set_mc->mc_list);
+ kfree(set_mc->mc_list);
kfree(wid.val);
kfree(msg);
}
@@ -2150,7 +2145,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
return result;
}
-int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count,
+int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
u8 *mc_list)
{
int result;
@@ -2160,9 +2155,9 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count,
if (IS_ERR(msg))
return PTR_ERR(msg);
- msg->body.multicast_info.enabled = enabled;
- msg->body.multicast_info.cnt = count;
- msg->body.multicast_info.mc_list = mc_list;
+ msg->body.mc_info.enabled = enabled;
+ msg->body.mc_info.cnt = count;
+ msg->body.mc_info.mc_list = mc_list;
result = wilc_enqueue_work(msg);
if (result) {
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 363db0b9fea8..527ae0523d67 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -230,7 +230,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
struct station_parameters *params);
int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
-int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count,
+int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
u8 *mc_list);
int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
u32 duration, u16 chan,
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 5b554c6d39a1..87ec048824b8 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -811,12 +811,12 @@ static void wilc_set_multicast_list(struct net_device *dev)
if (dev->flags & IFF_ALLMULTI ||
dev->mc.count > WILC_MULTICAST_TABLE_SIZE) {
- wilc_setup_multicast_filter(vif, false, 0, NULL);
+ wilc_setup_multicast_filter(vif, 0, 0, NULL);
return;
}
if (dev->mc.count == 0) {
- wilc_setup_multicast_filter(vif, true, 0, NULL);
+ wilc_setup_multicast_filter(vif, 1, 0, NULL);
return;
}
@@ -833,7 +833,7 @@ static void wilc_set_multicast_list(struct net_device *dev)
cur_mc += ETH_ALEN;
}
- if (wilc_setup_multicast_filter(vif, true, dev->mc.count, mc_list))
+ if (wilc_setup_multicast_filter(vif, 1, dev->mc.count, mc_list))
kfree(mc_list);
}