dev->priv to netdev_priv(dev), for drivers/net/wan
Subsystems (3)
PATCH 12/13 dev->priv to netdev_priv(dev), for drivers/net/wan
Replacing accesses to dev->priv to netdev_priv(dev). The replacment is safe when netdev_priv is used to access a private structure that is right next to the net_device structure in memory. Cf
http://groups.google.com/group/comp.os.linux.development.system/browse_thread/thread/de19321bcd94dbb8/0d74a4adcd6177bd
This is the case when the net_device structure was allocated with a call to alloc_netdev or one of its derivative.
Here is an excerpt of the semantic patch that performs the transformation
@ rule1 @
type T;
struct net_device *dev;
@@
dev =
(
alloc_netdev
|
alloc_etherdev
|
alloc_trdev
)
(sizeof(T), ...)
@ rule1bis @
struct net_device *dev;
expression E;
@@
dev->priv = E
@ rule2 depends on rule1 && !rule1bis @
struct net_device *dev;
type rule1.T;
@@
- (T*) dev->priv
+ netdev_priv(dev)
---
drivers/net/wan/dlci.c | 30 +++++++++++++------------- drivers/net/wan/lmc/lmc_main.c | 26 +++++++++++------------ drivers/net/wan/sdla.c | 46 ++++++++++++++++++++--------------------- drivers/net/wan/sealevel.c | 12 +++++----- drivers/net/wan/x25_asy.c | 28 ++++++++++++------------ 5 files changed, 71 insertions(+), 71 deletions(-)
drivers/net/wan/dlci.c +15 -15
@@ -74,7 +74,7 @@ static int dlci_header(struct sk_buff *sunsigned int hlen;char *dest; - dlp = dev->priv; + dlp =netdev_priv (dev); hdr.control =FRAD_I_UI ; switch(type)
@@ -110,7 +110,7 @@ static void dlci_receive(struct sk_buffstruct frhdr *hdr;int process, header; - dlp = dev->priv; + dlp =netdev_priv (dev);if (!pskb_may_pull (skb,sizeof (*hdr))) {printk (KERN_NOTICE "%s: invalid data no header\n" , dev->name);
@@ -197,7 +197,7 @@ static int dlci_transmit(struct sk_buffif (!skb || !dev)return (0 ); - dlp = dev->priv; + dlp =netdev_priv (dev);netif_stop_queue (dev);
@@ -235,7 +235,7 @@ static int dlci_config(struct net_devicestruct frad_local *flp;int err; - dlp = dev->priv; + dlp =netdev_priv (dev); flp = dlp->slave->priv;
@@ -269,7 +269,7 @@ static int dlci_dev_ioctl(struct net_devif (!capable (CAP_NET_ADMIN ))return (-EPERM ); - dlp = dev->priv; + dlp =netdev_priv (dev);switch (cmd) {
@@ -298,7 +298,7 @@ static int dlci_change_mtu(struct net_de {struct dlci_local *dlp; - dlp = dev->priv; + dlp =netdev_priv (dev);return ((*dlp->slave->change_mtu)(dlp->slave, new_mtu)); }
@@ -309,7 +309,7 @@ static int dlci_open(struct net_device *struct frad_local *flp;int err; - dlp = dev->priv; + dlp =netdev_priv (dev);if (!*(short *)(dev->dev_addr))return (-EINVAL );
@@ -335,7 +335,7 @@ static int dlci_close(struct net_devicenetif_stop_queue (dev); - dlp = dev->priv; + dlp =netdev_priv (dev); flp = dlp->slave->priv; err = (*flp->deactivate)(dlp->slave, dev);
@@ -347,7 +347,7 @@ static struct net_device_stats *dlci_get {struct dlci_local *dlp; - dlp = dev->priv; + dlp =netdev_priv (dev);return (&dlp->stats); }
@@ -365,7 +365,7 @@ static int dlci_add(struct dlci_add *dlcif (!slave)return -ENODEV ; -if (slave->type !=ARPHRD_FRAD || slave->priv =NULL ) +if (slave->type !=ARPHRD_FRAD ||netdev_priv (slave) =NULL ) goto err1;/* create device name */
@@ -391,11 +391,11 @@ static int dlci_add(struct dlci_add *dlc *(short *)(master->dev_addr) = dlci->dlci; - dlp = (struct dlci_local *) master->priv; + dlp =netdev_priv (master); dlp->slave = slave; dlp->master = master; - flp = slave->priv; + flp =netdev_priv (slave); err = (*flp->assoc)(slave, master);if (err <0 ) goto err2;
@@ -435,9 +435,9 @@ static int dlci_del(struct dlci_add *dlcreturn (-EBUSY ); } - dlp = master->priv; + dlp =netdev_priv (master); slave = dlp->slave; - flp = slave->priv; + flp =netdev_priv (slave);rtnl_lock (); err = (*flp->deassoc)(slave, master);
@@ -487,7 +487,7 @@ static int dlci_ioctl(unsigned int cmd,static void dlci_setup (struct net_device *dev) { -struct dlci_local *dlp = dev->priv; +struct dlci_local *dlp =netdev_priv (dev); dev->flags =0 ; dev->open = dlci_open;
drivers/net/wan/lmc/lmc_main.c +13 -13
@@ -126,7 +126,7 @@ int lmc_ioctl (struct net_device *dev, s ret = -EOPNOTSUPP ; - sc = dev->priv; + sc =netdev_priv (dev);lmc_trace (dev,"lmc_ioctl in" );
@@ -634,7 +634,7 @@ static void lmc_watchdog (unsigned longu_int32_t ticks;unsigned long flags; - sc = dev->priv; + sc =netdev_priv (dev);lmc_trace (dev,"lmc_watchdog in" );
@@ -872,7 +872,7 @@ #endif lmc_first_load =1 ; } - sc = dev->priv; + sc =netdev_priv (dev); sc->lmc_device = dev; sc->name = dev->name;
@@ -1018,7 +1018,7 @@ static void __devexit lmc_remove_one (ststruct net_device *dev =pci_get_drvdata (pdev);if (dev) { -lmc_softc_t *sc = dev->priv; +lmc_softc_t *sc =netdev_priv (dev);printk ("%s: removing...\n" , dev->name);lmc_proto_detach (sc);
@@ -1035,7 +1035,7 @@ static void __devexit lmc_remove_one (st*/ static int lmc_open (struct net_device *dev)/*fold00*/ { -lmc_softc_t *sc = dev->priv; +lmc_softc_t *sc =netdev_priv (dev);lmc_trace (dev,"lmc_open in" );
@@ -1153,7 +1153,7 @@ static int lmc_open (struct net_device *static void lmc_running_reset (struct net_device *dev)/*fold00*/ { -lmc_softc_t *sc = (lmc_softc_t *) dev->priv; +lmc_softc_t *sc =netdev_priv (dev);lmc_trace (dev,"lmc_runnig_reset in" );
@@ -1194,7 +1194,7 @@ static int lmc_close (struct net_devicelmc_trace (dev,"lmc_close in" ); - sc = dev->priv; + sc =netdev_priv (dev); sc->lmc_ok =0 ; sc->lmc_media->set_link_status (sc,0 );del_timer (&sc->timer);
@@ -1210,7 +1210,7 @@ static int lmc_close (struct net_device/* When the interface goes down, this is called */ static int lmc_ifdown (struct net_device *dev)/*fold00*/ { -lmc_softc_t *sc = dev->priv; +lmc_softc_t *sc =netdev_priv (dev);u32 csr6;int i;
@@ -1287,7 +1287,7 @@ static irqreturn_t lmc_interrupt (int irlmc_trace (dev,"lmc_interrupt in" ); - sc = dev->priv; + sc =netdev_priv (dev);spin_lock (&sc->lmc_lock);
@@ -1473,7 +1473,7 @@ static int lmc_start_xmit (struct sk_buflmc_trace (dev,"lmc_start_xmit in" ); - sc = dev->priv; + sc =netdev_priv (dev);spin_lock_irqsave (&sc->lmc_lock, flags);
@@ -1570,7 +1570,7 @@ static int lmc_rx (struct net_device *delmc_trace (dev,"lmc_rx in" ); - sc = dev->priv; + sc =netdev_priv (dev);lmc_led_on (sc,LMC_DS3_LED3 );
@@ -1764,7 +1764,7 @@ skip_out_of_mem:static struct net_device_stats *lmc_get_stats (struct net_device *dev)/*fold00*/ { -lmc_softc_t *sc = dev->priv; +lmc_softc_t *sc =netdev_priv (dev);unsigned long flags;lmc_trace (dev,"lmc_get_stats in" );
@@ -2145,7 +2145,7 @@ static void lmc_driver_timeout(struct nelmc_trace (dev,"lmc_driver_timeout in" ); - sc = dev->priv; + sc =netdev_priv (dev);spin_lock_irqsave (&sc->lmc_lock, flags);
drivers/net/wan/sdla.c +23 -23
184 lines not on this page · raw message
drivers/net/wan/sealevel.c +6 -6
@@ -77,7 +77,7 @@ static void sealevel_input(struct z8530_static int sealevel_open (struct net_device *d) { -struct slvl_device *slvl=d->priv; +struct slvl_device *slvl=netdev_priv (d);int err =-1 ;int unit = slvl->channel;
@@ -126,7 +126,7 @@ static int sealevel_open(struct net_devistatic int sealevel_close (struct net_device *d) { -struct slvl_device *slvl=d->priv; +struct slvl_device *slvl=netdev_priv (d);int unit = slvl->channel;/*
@@ -166,7 +166,7 @@ static int sealevel_ioctl(struct net_devstatic struct net_device_stats *sealevel_get_stats (struct net_device *d) { -struct slvl_device *slvl=d->priv; +struct slvl_device *slvl=netdev_priv (d);if (slvl)return z8530_get_stats (slvl->chan);else
@@ -179,7 +179,7 @@ static struct net_device_stats *sealevelstatic int sealevel_queue_xmit (struct sk_buff *skb,struct net_device *d) { -struct slvl_device *slvl=d->priv; +struct slvl_device *slvl=netdev_priv (d);return z8530_queue_xmit (slvl->chan, skb); }
@@ -204,7 +204,7 @@ static int sealevel_neigh_setup_dev(strustatic int sealevel_attach (struct net_device *dev) { -struct slvl_device *sv = dev->priv; +struct slvl_device *sv =netdev_priv (dev);sppp_attach (&sv->pppdev);return 0 ; }
@@ -240,7 +240,7 @@ static inline struct slvl_device *slvl_aif (!d)return NULL ; - sv = d->priv; + sv =netdev_priv (d); sv->if_ptr = &sv->pppdev; sv->pppdev.dev = d; d->base_addr = iobase;
drivers/net/wan/x25_asy.c +14 -14
@@ -63,7 +63,7 @@ static struct x25_asy *x25_asy_alloc(voiif (dev =NULL )break ; - sl = dev->priv; + sl =netdev_priv (dev);/* Not in use ? */ if (!test_and_set_bit (SLF_INUSE , &sl->flags))return sl;
@@ -85,7 +85,7 @@ static struct x25_asy *x25_asy_alloc(voireturn NULL ;/* Initialize channel control data */ - sl = dev->priv; + sl =netdev_priv (dev); dev->base_addr = i;/* register device so that it can be ifconfig'ed */
@@ -119,7 +119,7 @@ static void x25_asy_free(struct x25_asystatic int x25_asy_change_mtu (struct net_device *dev,int newmtu) { -struct x25_asy *sl = dev->priv; +struct x25_asy *sl =netdev_priv (dev);unsigned char *xbuff, *rbuff;int len =2 * newmtu;
@@ -282,7 +282,7 @@ static void x25_asy_write_wakeup(structstatic void x25_asy_timeout (struct net_device *dev) { -struct x25_asy *sl = (struct x25_asy *)(dev->priv); +struct x25_asy *sl = (struct x25_asy *)(netdev_priv (dev));spin_lock (&sl->lock);if (netif_queue_stopped (dev)) {
@@ -303,7 +303,7 @@ static void x25_asy_timeout(struct net_dstatic int x25_asy_xmit (struct sk_buff *skb,struct net_device *dev) { -struct x25_asy *sl = (struct x25_asy *)(dev->priv); +struct x25_asy *sl = (struct x25_asy *)(netdev_priv (dev));int err;if (!netif_running (sl->dev)) {
@@ -372,7 +372,7 @@ static int x25_asy_data_indication(strucstatic void x25_asy_data_transmit (struct net_device *dev,struct sk_buff *skb) { - struct x25_asy *slÞv->priv; +struct x25_asy *sl=netdev_priv (dev);spin_lock (&sl->lock);if (netif_queue_stopped (sl->dev) || sl->tty =NULL )
@@ -399,7 +399,7 @@ static void x25_asy_data_transmit(structstatic void x25_asy_connected (struct net_device *dev,int reason) { -struct x25_asy *sl = dev->priv; +struct x25_asy *sl =netdev_priv (dev);struct sk_buff *skb;unsigned char *ptr;
@@ -418,7 +418,7 @@ static void x25_asy_connected(struct netstatic void x25_asy_disconnected (struct net_device *dev,int reason) { -struct x25_asy *sl = dev->priv; +struct x25_asy *sl =netdev_priv (dev);struct sk_buff *skb;unsigned char *ptr;
@@ -449,7 +449,7 @@ static struct lapb_register_struct x25_a/* Open the low-level part of the X.25 channel. Easy! */ static int x25_asy_open (struct net_device *dev) { -struct x25_asy *sl = (struct x25_asy *)(dev->priv); +struct x25_asy *sl = (struct x25_asy *)(netdev_priv (dev));unsigned long len;int err;
@@ -499,7 +499,7 @@ norbuff:/* Close the low-level part of the X.25 channel. Easy! */ static int x25_asy_close (struct net_device *dev) { -struct x25_asy *sl = (struct x25_asy *)(dev->priv); +struct x25_asy *sl = (struct x25_asy *)(netdev_priv (dev));int err;spin_lock (&sl->lock);
@@ -615,7 +615,7 @@ static void x25_asy_close_tty(struct ttystatic struct net_device_stats *x25_asy_get_stats (struct net_device *dev) { -struct x25_asy *sl = (struct x25_asy *)(dev->priv); +struct x25_asy *sl = (struct x25_asy *)(netdev_priv (dev));return &sl->stats; }
@@ -730,7 +730,7 @@ static int x25_asy_ioctl(struct tty_strustatic int x25_asy_open_dev (struct net_device *dev) { -struct x25_asy *sl = (struct x25_asy *)(dev->priv); +struct x25_asy *sl = (struct x25_asy *)(netdev_priv (dev));if (sl->tty=NULL )return -ENODEV ;return 0 ;
@@ -739,7 +739,7 @@ static int x25_asy_open_dev(struct net_d/* Initialise the X.25 driver. Called by the device init code */ static void x25_asy_setup (struct net_device *dev) { -struct x25_asy *sl = dev->priv; +struct x25_asy *sl =netdev_priv (dev); sl->magic =X25_ASY_MAGIC ; sl->dev = dev;
@@ -805,7 +805,7 @@ static void __exit exit_x25_asy(void)for (i =0 ; i < x25_asy_maxdev; i++) { dev = x25_asy_devs[i];if (dev) { -struct x25_asy *sl = dev->priv; +struct x25_asy *sl =netdev_priv (dev);spin_lock_bh (&sl->lock);if (sl->tty)