diff options
author | Johannes Berg <johannes.berg@intel.com> | 2017-06-16 14:29:20 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-16 11:48:37 -0400 |
commit | 59ae1d127ac0ae404baf414c434ba2651b793f46 (patch) | |
tree | 043e71496aa7a7db86bcc8219a3a51f533aac982 /drivers/isdn/hardware | |
parent | b080db585384b9f037e015c0c28d1ad33be41dfc (diff) | |
download | linux-59ae1d127ac0ae404baf414c434ba2651b793f46.tar.bz2 |
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/isdn/hardware')
-rw-r--r-- | drivers/isdn/hardware/avm/b1.c | 6 | ||||
-rw-r--r-- | drivers/isdn/hardware/avm/b1dma.c | 6 | ||||
-rw-r--r-- | drivers/isdn/hardware/avm/c4.c | 6 | ||||
-rw-r--r-- | drivers/isdn/hardware/avm/t1isa.c | 6 | ||||
-rw-r--r-- | drivers/isdn/hardware/mISDN/hfcmulti.c | 5 | ||||
-rw-r--r-- | drivers/isdn/hardware/mISDN/hfcsusb.c | 2 |
6 files changed, 15 insertions, 16 deletions
diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c index 9fdbd99c7547..b1833d08a5fe 100644 --- a/drivers/isdn/hardware/avm/b1.c +++ b/drivers/isdn/hardware/avm/b1.c @@ -529,8 +529,8 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); - memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); + skb_put_data(skb, card->msgbuf, MsgLen); + skb_put_data(skb, card->databuf, DataB3Len); capi_ctr_handle_message(ctrl, ApplId, skb); } break; @@ -544,7 +544,7 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) card->name); spin_unlock_irqrestore(&card->lock, flags); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); + skb_put_data(skb, card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) capilib_data_b3_conf(&cinfo->ncci_head, ApplId, CAPIMSG_NCCI(skb->data), diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c index 818bd8f231db..9538a9e5e1a8 100644 --- a/drivers/isdn/hardware/avm/b1dma.c +++ b/drivers/isdn/hardware/avm/b1dma.c @@ -474,8 +474,8 @@ static void b1dma_handle_rx(avmcard *card) printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); - memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); + skb_put_data(skb, card->msgbuf, MsgLen); + skb_put_data(skb, card->databuf, DataB3Len); capi_ctr_handle_message(ctrl, ApplId, skb); } break; @@ -488,7 +488,7 @@ static void b1dma_handle_rx(avmcard *card) printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); + skb_put_data(skb, card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) { spin_lock(&card->lock); capilib_data_b3_conf(&cinfo->ncci_head, ApplId, diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c index 17beb2869dc1..40c7e2cf423b 100644 --- a/drivers/isdn/hardware/avm/c4.c +++ b/drivers/isdn/hardware/avm/c4.c @@ -536,8 +536,8 @@ static void c4_handle_rx(avmcard *card) printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); - memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); + skb_put_data(skb, card->msgbuf, MsgLen); + skb_put_data(skb, card->databuf, DataB3Len); capi_ctr_handle_message(ctrl, ApplId, skb); } break; @@ -555,7 +555,7 @@ static void c4_handle_rx(avmcard *card) printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); + skb_put_data(skb, card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) capilib_data_b3_conf(&cinfo->ncci_head, ApplId, CAPIMSG_NCCI(skb->data), diff --git a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c index 9516203c735f..9f80d20ced87 100644 --- a/drivers/isdn/hardware/avm/t1isa.c +++ b/drivers/isdn/hardware/avm/t1isa.c @@ -171,8 +171,8 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); - memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); + skb_put_data(skb, card->msgbuf, MsgLen); + skb_put_data(skb, card->databuf, DataB3Len); capi_ctr_handle_message(ctrl, ApplId, skb); } break; @@ -186,7 +186,7 @@ static irqreturn_t t1isa_interrupt(int interrupt, void *devptr) printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { - memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); + skb_put_data(skb, card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3) capilib_data_b3_conf(&cinfo->ncci_head, ApplId, CAPIMSG_NCCI(skb->data), diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c index 961c07ee47b7..aea0c9616ea5 100644 --- a/drivers/isdn/hardware/mISDN/hfcmulti.c +++ b/drivers/isdn/hardware/mISDN/hfcmulti.c @@ -1926,7 +1926,7 @@ hfcmulti_dtmf(struct hfc_multi *hc) hh = mISDN_HEAD_P(skb); hh->prim = PH_CONTROL_IND; hh->id = DTMF_HFC_COEF; - memcpy(skb_put(skb, 512), hc->chan[ch].coeff, 512); + skb_put_data(skb, hc->chan[ch].coeff, 512); recv_Bchannel_skb(bch, skb); } } @@ -2332,8 +2332,7 @@ next_frame: skb = *sp; *sp = mI_alloc_skb(skb->len, GFP_ATOMIC); if (*sp) { - memcpy(skb_put(*sp, skb->len), - skb->data, skb->len); + skb_put_data(*sp, skb->data, skb->len); skb_trim(skb, 0); } else { printk(KERN_DEBUG "%s: No mem\n", diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c index 114f3bcba1b0..17cc879ad2bb 100644 --- a/drivers/isdn/hardware/mISDN/hfcsusb.c +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c @@ -893,7 +893,7 @@ hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len, } } - memcpy(skb_put(rx_skb, len), data, len); + skb_put_data(rx_skb, data, len); if (hdlc) { /* we have a complete hdlc packet */ |