summaryrefslogtreecommitdiff
path: root/drivers/atm
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/atm
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/atm')
-rw-r--r--drivers/atm/fore200e.c2
-rw-r--r--drivers/atm/he.c2
-rw-r--r--drivers/atm/idt77252.c11
-rw-r--r--drivers/atm/solos-pci.c2
4 files changed, 7 insertions, 10 deletions
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 637c3e6b0f9e..7584ae1ded85 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -1104,7 +1104,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
/* Make device DMA transfer visible to CPU. */
fore200e->bus->dma_sync_for_cpu(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE);
- memcpy(skb_put(skb, rpd->rsd[ i ].length), buffer->data.align_addr, rpd->rsd[ i ].length);
+ skb_put_data(skb, buffer->data.align_addr, rpd->rsd[i].length);
/* Now let the device get at it again. */
fore200e->bus->dma_sync_for_device(fore200e, buffer->data.dma_addr, rpd->rsd[ i ].length, DMA_FROM_DEVICE);
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 3617659b9184..461da2bce8ef 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -1735,7 +1735,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
__net_timestamp(skb);
list_for_each_entry(heb, &he_vcc->buffers, entry)
- memcpy(skb_put(skb, heb->len), &heb->data, heb->len);
+ skb_put_data(skb, &heb->data, heb->len);
switch (vcc->qos.aal) {
case ATM_AAL0:
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 5ec109533bb9..4e64de380bda 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -1090,8 +1090,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
*((u32 *) sb->data) = aal0;
skb_put(sb, sizeof(u32));
- memcpy(skb_put(sb, ATM_CELL_PAYLOAD),
- cell, ATM_CELL_PAYLOAD);
+ skb_put_data(sb, cell, ATM_CELL_PAYLOAD);
ATM_SKB(sb)->vcc = vcc;
__net_timestamp(sb);
@@ -1159,8 +1158,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
return;
}
skb_queue_walk(&rpp->queue, sb)
- memcpy(skb_put(skb, sb->len),
- sb->data, sb->len);
+ skb_put_data(skb, sb->data, sb->len);
recycle_rx_pool_skb(card, rpp);
@@ -1322,8 +1320,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
*((u32 *) sb->data) = header;
skb_put(sb, sizeof(u32));
- memcpy(skb_put(sb, ATM_CELL_PAYLOAD), &(queue->data[16]),
- ATM_CELL_PAYLOAD);
+ skb_put_data(sb, &(queue->data[16]), ATM_CELL_PAYLOAD);
ATM_SKB(sb)->vcc = vcc;
__net_timestamp(sb);
@@ -2014,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
}
atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
- memcpy(skb_put(skb, 52), cell, 52);
+ skb_put_data(skb, cell, 52);
return idt77252_send_skb(vcc, skb, 1);
}
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 9115b292e680..077dd15c3a40 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -493,7 +493,7 @@ static int send_command(struct solos_card *card, int dev, const char *buf, size_
header->vci = cpu_to_le16(0);
header->type = cpu_to_le16(PKT_COMMAND);
- memcpy(skb_put(skb, size), buf, size);
+ skb_put_data(skb, buf, size);
fpga_queue(card, dev, skb, NULL);