netdevice: Kill netdev->priv
Subsystems (5)
PATCH 1/1 netdevice: Kill netdev->priv
This is the last shoot of this series.
After I removing all directly reference of netdev->priv, I am killing "priv" of "struct net_device" and fixing relative comments/docs.
Anyone will not be allowed to reference netdev->priv directly. If you want to reference the memory of private data, use netdev_priv() instead.
If the private data is not allocted when alloc_netdev(), use netdev->ml_priv to point that memory after you creating that private data.
--- Documentation/networking/driver.txt | 2 +- Documentation/networking/netdevices.txt | 2 +- drivers/net/3c501.h | 2 +- drivers/net/atp.c | 2 +- drivers/net/eexpress.c | 2 +- drivers/net/forcedeth.c | 4 ++-- drivers/net/lance.c | 2 +- drivers/net/myri_sbus.c | 2 +- drivers/net/pci-skeleton.c | 2 +- drivers/net/sun3_82586.c | 2 +- drivers/net/sunbmac.c | 2 +- drivers/net/tokenring/3c359.c | 5 +++-- drivers/net/via-rhine.c | 9 +++++---- drivers/net/wireless/strip.c | 2 +- include/linux/hdlc.h | 2 +- include/linux/netdevice.h | 1 - net/atm/mpc.c | 4 ++-- net/core/dev.c | 6 ------ 18 files changed, 24 insertions(+), 29 deletions(-)
Documentation/networking/driver.txt +1 -1
@@ -13,7 +13,7 @@ Transmit path guidelines: static int drv_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { - struct drv *dp = dev->priv; + struct drv *dp = netdev_priv(dev); lock_tx(dp); ...
Documentation/networking/netdevices.txt +1 -1
@@ -18,7 +18,7 @@ There are routines in net_init.c to handle the common cases of alloc_etherdev, alloc_netdev. These reserve extra space for driver private data which gets freed when the network device is freed. If separately allocated data is attached to the network device -(dev->priv) then it is up to the module exit handler to free that. +(netdev_priv(dev)) then it is up to the module exit handler to free that. MTU ===
drivers/net/3c501.h +1 -1
@@ -23,7 +23,7 @@ static const struct ethtool_ops netdev_ethtool_ops;static int el_debug =EL_DEBUG ;/* -* Board-specific info in dev->priv. +* Board-specific info in netdev_priv(dev). */ struct net_local
drivers/net/atp.c +1 -1
@@ -420,7 +420,7 @@ static unsigned short __init eeprom_op(long ioaddr, u32 cmd)registers that "should" only need to be set once at boot, so that there is non-reboot way to recover if something goes wrong. -This is an attachable device: if there is no dev->priv entry then it wasn't +This is an attachable device: if there is no private entry then it wasn't probed for at boot-time, and we need to probe for it again. */ static int net_open (struct net_device *dev)
drivers/net/eexpress.c +1 -1
@@ -1046,7 +1046,7 @@ static void eexp_hw_tx_pio(struct net_device *dev, unsigned short *buf,/* * Sanity check the suspected EtherExpress card * Read hardware address, reset card, size memory and initialize buffer -* memory pointers. These are held in dev->priv, in case someone has more +* memory pointers. These are held in netdev_priv(), in case someone has more * than one card in a machine. */
drivers/net/forcedeth.c +2 -2
@@ -712,12 +712,12 @@ struct nv_skb_map {/* * SMP locking: -* All hardware access under dev->priv->lock, except the performance +* All hardware access under netdev_priv(dev)->lock, except the performance * critical parts: * - rx is (pseudo-) lockless: it relies on the single-threading provided * by the arch code for interrupts. * - tx setup is lockless: it relies on netif_tx_lock. Actual submission -* needs dev->priv->lock :-( +* needs netdev_priv(dev)->lock :-( * - set_multicast_list: preparation lockless, relies on netif_tx_lock. */
drivers/net/lance.c +1 -1
@@ -519,7 +519,7 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int } } -/* We can't allocate dev->priv from alloc_etherdev() because it must +/* We can't allocate private data from alloc_etherdev() because it must a ISA DMA-able region. */ chipname = chip_table[lance_version].name;printk ("%s: %s at %#3x, " , dev->name, chipname, ioaddr);
drivers/net/myri_sbus.c +1 -1
@@ -1091,7 +1091,7 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic err_free_irq:free_irq (dev->irq, dev); err: -/* This will also free the co-allocated 'dev->priv' */ +/* This will also free the co-allocated private data*/ free_netdev (dev);return -ENODEV ; }
drivers/net/pci-skeleton.c +1 -1
@@ -781,7 +781,7 @@ static int __devinit netdrv_init_one (struct pci_dev *pdev, dev->irq = pdev->irq; dev->base_addr = (unsigned long ) ioaddr; -/* dev->priv/tp zeroed and aligned in alloc_etherdev */ +/* netdev_priv()/tp zeroed and aligned in alloc_etherdev */ tp =netdev_priv (dev);/* note: tp->chipset set in netdrv_init_board */
drivers/net/sun3_82586.c +1 -1
@@ -209,7 +209,7 @@ static int sun3_82586_open(struct net_device *dev)static int check586 (struct net_device *dev,char *where,unsigned size) {struct priv pb; -struct priv *p =/* (struct priv *) dev->priv*/ &pb; +struct priv *p = &pb;char *iscp_addr;int i;
drivers/net/sunbmac.c +1 -1
@@ -1233,7 +1233,7 @@ fail_and_cleanup: bp->bmac_block, bp->bblock_dvma); -/* This also frees the co-located 'dev->priv' */ +/* This also frees the co-located private data */ free_netdev (dev);return -ENODEV ; }
drivers/net/tokenring/3c359.c +3 -2
@@ -296,8 +296,9 @@ static int __devinit xl_probe(struct pci_dev *pdev, } ;/* -* Allowing init_trdev to allocate the dev->priv structure will align xl_private -* on a 32 bytes boundary which we need for the rx/tx descriptors +* Allowing init_trdev to allocate the private data will align +* xl_private on a 32 bytes boundary which we need for the rx/tx +* descriptors */ dev =alloc_trdev (sizeof (struct xl_private )) ;
drivers/net/via-rhine.c +5 -4
@@ -191,12 +191,13 @@ IIId. Synchronization The driver runs as two independent, single-threaded flows of control. One is the send-packet routine, which enforces single-threaded use by the -dev->priv->lock spinlock. The other thread is the interrupt handler, which -is single threaded by the hardware and interrupt handling software. +netdev_priv(dev)->lock spinlock. The other thread is the interrupt handler, +which is single threaded by the hardware and interrupt handling software. The send packet thread has partial control over the Tx ring. It locks the -dev->priv->lock whenever it's queuing a Tx packet. If the next slot in the ring -is not available it stops the transmit queue by calling netif_stop_queue. +netdev_priv(dev)->lock whenever it's queuing a Tx packet. If the next slot in +the ring is not available it stops the transmit queue by +calling netif_stop_queue. The interrupt handler has exclusive control over the Rx ring and records stats from the Tx ring. After reaping the stats, it marks the Tx queue entry as
drivers/net/wireless/strip.c +1 -1
@@ -2494,7 +2494,7 @@ static void strip_dev_setup(struct net_device *dev) dev->type =ARPHRD_METRICOM ;/* dtang */ dev->hard_header_len =sizeof (STRIP_Header);/* -* dev->priv Already holds a pointer to our struct strip +* netdev_priv(dev) Already holds a pointer to our struct strip */ *(MetricomAddress *) & dev->broadcast = broadcast_address;
include/linux/hdlc.h +1 -1
@@ -43,7 +43,7 @@ struct hdlc_proto { }; -/* Pointed to by dev->priv */ +/* Pointed to by netdev_priv(dev) */ typedef struct hdlc_device { /* used by HDLC layer to take control over HDLC device from hw driver*/ int (*attach)(struct net_device *dev,
include/linux/netdevice.h +0 -1
@@ -785,7 +785,6 @@ struct net_device/* * One part is mostly used on xmit path (device) */ -void *priv;/* pointer to private data */ /* These may be needed for future network-power-down code. */ unsigned long trans_start;/* Time (in jiffies) of last Tx */
net/atm/mpc.c +2 -2
@@ -341,8 +341,8 @@ static const char *mpoa_device_type_string(char type) }/* -* lec device calls this via its dev->priv->lane2_ops->associate_indicator() -* when it sees a TLV in LE_ARP packet. +* lec device calls this via its netdev_priv(dev)->lane2_ops +* ->associate_indicator() when it sees a TLV in LE_ARP packet. * We fill in the pointer above when we see a LANE2 lec initializing * See LANE2 spec 3.1.5 *
net/core/dev.c +0 -6
@@ -4378,12 +4378,6 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, dev->num_tx_queues = queue_count; dev->real_num_tx_queues = queue_count; -if (sizeof_priv) { - dev->priv = ((char *)dev + - ((sizeof (struct net_device ) +NETDEV_ALIGN_CONST ) - & ~NETDEV_ALIGN_CONST )); - } - dev->gso_max_size =GSO_MAX_SIZE ;netdev_init_queues (dev);
Signature · 1 line
1.5.3.4
From: Wang Chen <[email protected]>
Date: Mon, 08 Dec 2008 13:35:54 +0800
Quoted 4 lines
This is the last shoot of this series.
After I removing all directly reference ofnetdev->priv, I am killing "priv" of "structnet_device" and fixing relative comments/docs.
Quoted 8 lines
Anyone will not be allowed to reference
netdev->privdirectly. If you want to reference the memory of private data, usenetdev_priv()instead.
If the private data is not allocted whenalloc_netdev(), usenetdev->ml_privto point that memory after you creating that private data.Signed-off-by Wang Chen <[email protected]>
Applied.
Thanks so much for doing all of this work!