summaryrefslogtreecommitdiffstats
path: root/drivers/nfc/pn533/pn533.c
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/nfc/pn533/pn533.c
parentb080db585384b9f037e015c0c28d1ad33be41dfc (diff)
downloadblackbird-op-linux-59ae1d127ac0ae404baf414c434ba2651b793f46.tar.gz
blackbird-op-linux-59ae1d127ac0ae404baf414c434ba2651b793f46.zip
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/nfc/pn533/pn533.c')
-rw-r--r--drivers/nfc/pn533/pn533.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index 70c304504a29..9200bb308e42 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -1035,11 +1035,10 @@ static struct sk_buff *pn533_alloc_poll_tg_frame(struct pn533 *dev)
*skb_put(skb, 1) = PN533_INIT_TARGET_DEP;
/* MIFARE params */
- memcpy(skb_put(skb, 6), mifare_params, 6);
+ skb_put_data(skb, mifare_params, 6);
/* Felica params */
- felica = skb_put(skb, 18);
- memcpy(felica, felica_params, 18);
+ felica = skb_put_data(skb, felica_params, 18);
get_random_bytes(felica + 2, 6);
/* NFCID3 */
@@ -1049,8 +1048,7 @@ static struct sk_buff *pn533_alloc_poll_tg_frame(struct pn533 *dev)
/* General bytes */
*skb_put(skb, 1) = gbytes_len;
- gb = skb_put(skb, gbytes_len);
- memcpy(gb, gbytes, gbytes_len);
+ gb = skb_put_data(skb, gbytes, gbytes_len);
/* Len Tk */
*skb_put(skb, 1) = 0;
@@ -1384,15 +1382,14 @@ static int pn533_poll_dep(struct nfc_dev *nfc_dev)
*next = 0;
/* Copy passive data */
- memcpy(skb_put(skb, PASSIVE_DATA_LEN), passive_data, PASSIVE_DATA_LEN);
+ skb_put_data(skb, passive_data, PASSIVE_DATA_LEN);
*next |= 1;
/* Copy NFCID3 (which is NFCID2 from SENSF_RES) */
- memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), nfcid3,
- NFC_NFCID3_MAXSIZE);
+ skb_put_data(skb, nfcid3, NFC_NFCID3_MAXSIZE);
*next |= 2;
- memcpy(skb_put(skb, dev->gb_len), dev->gb, dev->gb_len);
+ skb_put_data(skb, dev->gb, dev->gb_len);
*next |= 4; /* We have some Gi */
rc = pn533_send_cmd_async(dev, PN533_CMD_IN_JUMP_FOR_DEP, skb,
@@ -1472,7 +1469,7 @@ static struct sk_buff *pn533_alloc_poll_in_frame(struct pn533 *dev,
if (!skb)
return NULL;
- memcpy(skb_put(skb, mod->len), &mod->data, mod->len);
+ skb_put_data(skb, &mod->data, mod->len);
return skb;
}
@@ -1858,7 +1855,7 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
*next = 0;
/* Copy passive data */
- memcpy(skb_put(skb, PASSIVE_DATA_LEN), passive_data, PASSIVE_DATA_LEN);
+ skb_put_data(skb, passive_data, PASSIVE_DATA_LEN);
*next |= 1;
/* Copy NFCID3 (which is NFCID2 from SENSF_RES) */
@@ -1866,12 +1863,11 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), target->nfcid2,
target->nfcid2_len);
else
- memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), nfcid3,
- NFC_NFCID3_MAXSIZE);
+ skb_put_data(skb, nfcid3, NFC_NFCID3_MAXSIZE);
*next |= 2;
if (gb != NULL && gb_len > 0) {
- memcpy(skb_put(skb, gb_len), gb, gb_len);
+ skb_put_data(skb, gb, gb_len);
*next |= 4; /* We have some Gi */
} else {
*next = 0;
@@ -2100,7 +2096,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb)
*skb_push(frag, sizeof(u8)) = 1; /* TG */
}
- memcpy(skb_put(frag, frag_size), skb->data, frag_size);
+ skb_put_data(frag, skb->data, frag_size);
/* Reduce the size of incoming buffer */
skb_pull(skb, frag_size);
@@ -2375,7 +2371,7 @@ static int pn533_set_configuration(struct pn533 *dev, u8 cfgitem, u8 *cfgdata,
return -ENOMEM;
*skb_put(skb, sizeof(cfgitem)) = cfgitem;
- memcpy(skb_put(skb, cfgdata_len), cfgdata, cfgdata_len);
+ skb_put_data(skb, cfgdata, cfgdata_len);
resp = pn533_send_cmd_sync(dev, PN533_CMD_RF_CONFIGURATION, skb);
if (IS_ERR(resp))
OpenPOWER on IntegriCloud