summaryrefslogtreecommitdiff
path: root/drivers/staging/wilc1000
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-06-16 14:29:20 +0200
committerDavid S. Miller <davem@davemloft.net>2017-06-16 11:48:37 -0400
commit59ae1d127ac0ae404baf414c434ba2651b793f46 (patch)
tree043e71496aa7a7db86bcc8219a3a51f533aac982 /drivers/staging/wilc1000
parentb080db585384b9f037e015c0c28d1ad33be41dfc (diff)
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy() some data into the new space, introduce skb_put_data() for this. An spatch similar to the one for skb_put_zero() converts many of the places using it: @@ identifier p, p2; expression len, skb, data; type t, t2; @@ ( -p = skb_put(skb, len); +p = skb_put_data(skb, data, len); | -p = (t)skb_put(skb, len); +p = skb_put_data(skb, data, len); ) ( p2 = (t2)p; -memcpy(p2, data, len); | -memcpy(p, data, len); ) @@ type t, t2; identifier p, p2; expression skb, data; @@ t *p; ... ( -p = skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); | -p = (t *)skb_put(skb, sizeof(t)); +p = skb_put_data(skb, data, sizeof(t)); ) ( p2 = (t2)p; -memcpy(p2, data, sizeof(*p)); | -memcpy(p, data, sizeof(*p)); ) @@ expression skb, len, data; @@ -memcpy(skb_put(skb, len), data, len); +skb_put_data(skb, data, len); (again, manually post-processed to retain some comments) Reviewed-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/staging/wilc1000')
-rw-r--r--drivers/staging/wilc1000/linux_mon.c6
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
index c9782d452b07..dbc266a37974 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -72,7 +72,7 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size)
if (!skb)
return;
- memcpy(skb_put(skb, size), buff, size);
+ skb_put_data(skb, buff, size);
cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *)skb_push(skb, sizeof(*cb_hdr));
memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
@@ -100,7 +100,7 @@ void WILC_WFI_monitor_rx(u8 *buff, u32 size)
if (!skb)
return;
- memcpy(skb_put(skb, size), buff, size);
+ skb_put_data(skb, buff, size);
hdr = (struct wilc_wfi_radiotap_hdr *)skb_push(skb, sizeof(*hdr));
memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
@@ -200,7 +200,7 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
if (!skb2)
return -ENOMEM;
- memcpy(skb_put(skb2, skb->len), skb->data, skb->len);
+ skb_put_data(skb2, skb->data, skb->len);
cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *)skb_push(skb2, sizeof(*cb_hdr));
memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index d6d803416be2..f36598a89ce0 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1160,7 +1160,7 @@ void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset)
skb->dev = wilc_netdev;
- memcpy(skb_put(skb, frame_len), buff_to_send, frame_len);
+ skb_put_data(skb, buff_to_send, frame_len);
skb->protocol = eth_type_trans(skb, wilc_netdev);
vif->netstats.rx_packets++;