linux_dsm_epyc7002/drivers/net/ethernet/marvell
Johannes Berg 59ae1d127a 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>
2017-06-16 11:48:37 -04:00
..
Kconfig net: mvpp2: finally add the PPv2.2 compatible string 2017-03-09 10:12:11 -08:00
Makefile net: mvneta: bm: add support for hardware buffer management 2016-03-14 12:19:46 -04:00
mv643xx_eth.c net: phy: Make phy_ethtool_ksettings_get return void 2017-06-13 12:59:06 -04:00
mvmdio.c net: mvmdio: allow up to three clocks to be specified for orion-mdio 2017-04-13 10:59:12 -04:00
mvneta_bm.c net: mvneta: Fix lacking spinlock initialization 2016-05-25 12:35:08 -07:00
mvneta_bm.h net: mvneta: use IS_ENABLED() instead of checking for built-in or module 2016-09-12 20:27:59 -07:00
mvneta.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
mvpp2.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-06-15 11:59:32 -04:00
pxa168_eth.c net: pxa168_eth: Adjust four checks for null pointers 2017-04-18 13:55:10 -04:00
skge.c skge: Adjust a null pointer check in skge_down() 2017-04-18 13:55:10 -04:00
skge.h skge: Rename LED_OFF and LED_ON in marvel skge driver to avoid conflicts with leds namespace 2016-10-18 11:56:30 -04:00
sky2.c sky2: Use seq_puts() in sky2_debug_show() 2017-04-18 13:55:11 -04:00
sky2.h net: Remove usage of net_device last_rx member 2017-01-18 17:22:49 -05:00