dev->priv to netdev_priv(dev), drivers/net/tokenring/
Subsystems (2)
PATCH 1/1 dev->priv to netdev_priv(dev), drivers/net/tokenring/
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)
PS: I have performed the same transformation on the whole kernel and it affects around 70 files, most of them in drivers/net/. Should I split my patch for each subnet directories ? (wireless/, wan/, etc)
Thanks to Thomas Surrel for helping me refining my semantic patch.
3c359.c | 58 +++++++++++++++++++++++++++++----------------------------- ibmtr.c | 38 +++++++++++++++++++------------------- lanstreamer.c | 32 ++++++++++++++++---------------- madgemc.c | 4 ++-- olympic.c | 36 ++++++++++++++++++------------------ tmspci.c | 4 ++-- 6 files changed, 86 insertions(+), 86 deletions(-)
drivers/net/tokenring/3c359.c +29 -29
@@ -156,7 +156,7 @@ static void print_rx_state(struct net_destatic void print_tx_state (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *)dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;struct xl_tx_desc *txd ;u8 __iomem *xl_mmio = xl_priv->xl_mmio ;int i ;
@@ -179,7 +179,7 @@ static void print_tx_state(struct net_destatic void print_rx_state (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *)dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;struct xl_rx_desc *rxd ;u8 __iomem *xl_mmio = xl_priv->xl_mmio ;int i ;
@@ -213,7 +213,7 @@ #endifstatic u16 xl_ee_read (struct net_device *dev,int ee_addr) { -struct xl_private *xl_priv = (struct xl_private *)dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem *xl_mmio = xl_priv->xl_mmio ;/* Wait for EEProm to not be busy */
@@ -245,7 +245,7 @@ static u16 xl_ee_read(struct net_devicestatic void xl_ee_write (struct net_device *dev,int ee_addr,u16 ee_value) { -struct xl_private *xl_priv = (struct xl_private *)dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem *xl_mmio = xl_priv->xl_mmio ;/* Wait for EEProm to not be busy */
@@ -305,11 +305,11 @@ static int __devinit xl_probe(struct pcipci_release_regions (pdev) ;return -ENOMEM ; } - xl_priv = dev->priv ; + xl_priv =netdev_priv (dev) ;#if XL_DEBUG printk ("pci_device: %p, dev:%p, dev->priv: %p, ba[0]: %10x, ba[1]:%10x\n" , - pdev, dev, dev->priv, (unsigned int )pdev->resource[0 ].start, (unsigned int )pdev->resource[1 ].start) ; + pdev, dev,netdev_priv (dev), (unsigned int )pdev->resource[0 ].start, (unsigned int )pdev->resource[1 ].start) ;#endif dev->irq=pdev->irq;
@@ -365,7 +365,7 @@ #endifstatic int __devinit xl_init (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *)dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;printk (KERN_INFO "%s \n" , version); printk(KERN_INFO "%s: I/O at %hx, MMIO at %p, using irq %d\n",
@@ -385,7 +385,7 @@ static int __devinit xl_init(struct net_static int xl_hw_reset (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *)dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem *xl_mmio = xl_priv->xl_mmio ;unsigned long t ;u16 i ;
@@ -568,7 +568,7 @@ #endifstatic int xl_open (struct net_device *dev) { -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);u8 __iomem *xl_mmio = xl_priv->xl_mmio ;u8 i ;u16 hwaddr[3 ] ;/* Should be u8[6] but we get word return values */
@@ -726,7 +726,7 @@ static int xl_open(struct net_device *destatic int xl_open_hw (struct net_device *dev) { -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);u8 __iomem *xl_mmio = xl_priv->xl_mmio ;u16 vsoff ;char ver_str[33 ];
@@ -875,7 +875,7 @@ static int xl_open_hw(struct net_devicestatic void adv_rx_ring (struct net_device *dev)/* Advance rx_ring, cut down on bloat in xl_rx */ { -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);int prev_ring_loc ; prev_ring_loc = (xl_priv->rx_ring_tail +XL_RX_RING_SIZE -1 ) & (XL_RX_RING_SIZE -1 );
@@ -890,7 +890,7 @@ static void adv_rx_ring(struct net_devicstatic void xl_rx (struct net_device *dev) { -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);u8 __iomem * xl_mmio = xl_priv->xl_mmio ;struct sk_buff *skb, *skb2 ;int frame_length =0 , copy_len =0 ;
@@ -997,7 +997,7 @@ static void xl_rx(struct net_device *devstatic void xl_reset (struct net_device *dev) { -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);u8 __iomem * xl_mmio = xl_priv->xl_mmio ;unsigned long t;
@@ -1020,7 +1020,7 @@ static void xl_reset(struct net_device *static void xl_freemem (struct net_device *dev) { -struct xl_private *xl_priv=(struct xl_private *)dev->priv ; +struct xl_private *xl_priv=netdev_priv (dev) ;int i ;for (i=0 ;i<XL_RX_RING_SIZE ;i++) {
@@ -1044,7 +1044,7 @@ static void xl_freemem(struct net_devicestatic irqreturn_t xl_interrupt (int irq,void *dev_id) {struct net_device *dev = (struct net_device *)dev_id; -struct xl_private *xl_priv =(struct xl_private *)dev->priv; +struct xl_private *xl_priv =netdev_priv (dev);u8 __iomem * xl_mmio = xl_priv->xl_mmio ;u16 intstatus, macstatus ;
@@ -1171,7 +1171,7 @@ static irqreturn_t xl_interrupt(int irq,static int xl_xmit (struct sk_buff *skb,struct net_device *dev) { -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);struct xl_tx_desc *txd ;int tx_head, tx_tail, tx_prev ;unsigned long flags ;
@@ -1232,7 +1232,7 @@ static int xl_xmit(struct sk_buff *skb,static void xl_dn_comp (struct net_device *dev) { -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);u8 __iomem * xl_mmio = xl_priv->xl_mmio ;struct xl_tx_desc *txd ;
@@ -1268,7 +1268,7 @@ static void xl_dn_comp(struct net_devicestatic int xl_close (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem * xl_mmio = xl_priv->xl_mmio ;unsigned long t ;
@@ -1366,7 +1366,7 @@ static int xl_close(struct net_device *dstatic void xl_set_rx_mode (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;struct dev_mc_list *dmi ;unsigned char dev_mc_address[4 ] ;u16 options ;
@@ -1407,7 +1407,7 @@ static void xl_set_rx_mode(struct net_destatic void xl_srb_bh (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem * xl_mmio = xl_priv->xl_mmio ;u8 srb_cmd, ret_code ;int i ;
@@ -1476,14 +1476,14 @@ static void xl_srb_bh(struct net_devicestatic struct net_device_stats *xl_get_stats (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;return (struct net_device_stats *) &xl_priv->xl_stats; }static int xl_set_mac_address (struct net_device *dev,void *addr) {struct sockaddr *saddr = addr ; -struct xl_private *xl_priv = (struct xl_private *)dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;if (netif_running (dev)) {printk (KERN_WARNING "%s: Cannot set mac/laa address while card is open\n" , dev->name) ;
@@ -1504,7 +1504,7 @@ static int xl_set_mac_address (struct nestatic void xl_arb_cmd (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv; +struct xl_private *xl_priv =netdev_priv (dev);u8 __iomem * xl_mmio = xl_priv->xl_mmio ;u8 arb_cmd ;u16 lan_status, lan_status_diff ;
@@ -1632,7 +1632,7 @@ #endifstatic void xl_asb_cmd (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem * xl_mmio = xl_priv->xl_mmio ;if (xl_priv->asb_queued =1 )
@@ -1663,7 +1663,7 @@ static void xl_asb_cmd(struct net_device*/ static void xl_asb_bh (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem * xl_mmio = xl_priv->xl_mmio ;u8 ret_code ;
@@ -1691,7 +1691,7 @@ static void xl_asb_bh(struct net_devicestatic void xl_srb_cmd (struct net_device *dev,int srb_cmd) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem * xl_mmio = xl_priv->xl_mmio ;switch (srb_cmd) {
@@ -1748,7 +1748,7 @@ static void xl_srb_cmd(struct net_devicestatic void xl_wait_misr_flags (struct net_device *dev) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv ; +struct xl_private *xl_priv =netdev_priv (dev) ;u8 __iomem * xl_mmio = xl_priv->xl_mmio ;int i ;
@@ -1773,7 +1773,7 @@ static void xl_wait_misr_flags(struct nestatic int xl_change_mtu (struct net_device *dev,int mtu) { -struct xl_private *xl_priv = (struct xl_private *) dev->priv; +struct xl_private *xl_priv =netdev_priv (dev);u16 max_mtu ;if (xl_priv->xl_ring_speed =4 )
@@ -1795,7 +1795,7 @@ static int xl_change_mtu(struct net_devi static void __devexit xl_remove_one (struct pci_dev *pdev) {struct net_device *dev =pci_get_drvdata (pdev); -struct xl_private *xl_priv=(struct xl_private *)dev->priv; +struct xl_private *xl_priv=netdev_priv (dev);unregister_netdev (dev);iounmap (xl_priv->xl_mmio) ;
drivers/net/tokenring/ibmtr.c +19 -19
@@ -327,7 +327,7 @@ #ifndef PCMCIArelease_region (dev->base_addr,IBMTR_IO_EXTENT ); { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);iounmap (ti->mmio);iounmap (ti->sram_virt); }
@@ -384,7 +384,7 @@ static int __devinit ibmtr_probe1(structunsigned char segment, intr=0 , irq=0 , i, j, cardpresent=NOTOK , temp=0 ;void __iomem * t_mmio =NULL ; -struct tok_info *ti = dev->priv; +struct tok_info *ti =netdev_priv (dev);void __iomem *cd_chanid;unsigned char *tchanid, ctemp;#ifndef PCMCIA
@@ -823,7 +823,7 @@ static unsigned char __devinit get_sram_static int __devinit trdev_init (struct net_device *dev) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);SET_PAGE (ti->srb_page); ti->open_failure =NO ;
@@ -846,7 +846,7 @@ static int tok_init_card(struct net_deviunsigned long i; PIOaddr = dev->base_addr; - ti = (struct tok_info *) dev->priv; + ti =netdev_priv (dev);/* Special processing for first interrupt after reset */ ti->do_tok_int =FIRST_INT ;/* Reset adapter */
@@ -868,7 +868,7 @@ #endif/*****************************************************************************/ static int tok_open (struct net_device *dev) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);int i;/*the case we were left in a failure state during a previous open */
@@ -927,7 +927,7 @@ static void tok_open_adapter(unsigned lostruct tok_info *ti;int i; - ti = (struct tok_info *) dev->priv; + ti =netdev_priv (dev);SET_PAGE (ti->init_srb_page);writeb (~SRB_RESP_INT , ti->mmio +ACA_OFFSET +ACA_RESET +ISRP_ODD );for (i =0 ; i <sizeof (struct dir_open_adapter ); i++)
@@ -962,7 +962,7 @@ static void tok_open_adapter(unsigned lostatic void open_sap (unsigned char type,struct net_device *dev) {int i; -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);SET_PAGE (ti->srb_page);for (i =0 ; i <sizeof (struct dlc_open_sap ); i++)
@@ -986,7 +986,7 @@ #define STATION_COUNT_OFST 18static void tok_set_multicast_list (struct net_device *dev) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);struct dev_mc_list *mclist;unsigned char address[4 ];
@@ -1029,7 +1029,7 @@ static int tok_send_packet(struct sk_buf {struct tok_info *ti;unsigned long flags; - ti = (struct tok_info *) dev->priv; + ti =netdev_priv (dev);netif_stop_queue (dev);
@@ -1051,7 +1051,7 @@ static int tok_send_packet(struct sk_bufstatic int tok_close (struct net_device *dev) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);/* Important for PCMCIA hot unplug, otherwise, we'll pull the card, */ /* unloading the module from memory, and then if a timer pops, ouch */
@@ -1094,7 +1094,7 @@ static void __iomem *map_address(structstatic void dir_open_adapter (struct net_device *dev) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);unsigned char ret_code;__u16 err;
@@ -1179,7 +1179,7 @@ #endif#if TR_VERBOSE DPRINTK ("Int from tok_driver, dev : %p irq%d\n" , dev,irq);#endif - ti = (struct tok_info *) dev->priv; + ti =netdev_priv (dev);if (ti->sram_phys &1 )return IRQ_NONE ;/* PCMCIA card extraction flag */ spin_lock (&(ti->lock));
@@ -1498,7 +1498,7 @@ static void initial_tok_int(struct net_dstruct tok_info *ti;unsigned char init_status;/*BMS 12/2000*/ - ti = (struct tok_info *) dev->priv; + ti =netdev_priv (dev); ti->do_tok_int =NOT_FIRST ;
@@ -1560,7 +1560,7 @@ #define RSAP_VALUE_OFST 9static void tr_tx (struct net_device *dev) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);struct trh_hdr *trhdr = (struct trh_hdr *) ti->current_skb->data;unsigned int hdr_len;__u32 dhb=0 ,dhb_base;
@@ -1674,7 +1674,7 @@ #define ETHERTYPE_OFST 6static void tr_rx (struct net_device *dev) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);__u32 rbuffer;void __iomem *rbuf, *rbufdata, *llc;__u8 rbuffer_page =0 ;
@@ -1846,7 +1846,7 @@ static void ibmtr_reset_timer(struct timvoid tok_rerun (unsigned long dev_addr){struct net_device *dev = (struct net_device *)dev_addr; -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);if ( ti->open_action =RESTART ){ ti->do_tok_int =FIRST_INT ;
@@ -1868,7 +1868,7 @@ static void ibmtr_readlog(struct net_dev {struct tok_info *ti; - ti = (struct tok_info *) dev->priv; + ti =netdev_priv (dev); ti->readlog_pending =0 ;SET_PAGE (ti->srb_page);
@@ -1891,7 +1891,7 @@ static struct net_device_stats *tok_get_ {struct tok_info *toki; - toki = (struct tok_info *) dev->priv; + toki =netdev_priv (dev);return (struct net_device_stats *) &toki->tr_stats; }
@@ -1899,7 +1899,7 @@ static struct net_device_stats *tok_get_static int ibmtr_change_mtu (struct net_device *dev,int mtu) { -struct tok_info *ti = (struct tok_info *) dev->priv; +struct tok_info *ti =netdev_priv (dev);if (ti->ring_speed =16 && mtu > ti->maxmtu16)return -EINVAL ;
drivers/net/tokenring/lanstreamer.c +16 -7
@@ -245,7 +245,7 @@ #endif }SET_MODULE_OWNER (dev); - streamer_priv = dev->priv; + streamer_priv =netdev_priv (dev);#if STREAMER_NETWORK_MONITOR #ifdef CONFIG_PROC_FS
@@ -404,7 +404,7 @@ #endifreturn ; } - streamer_privÞv->priv; + streamer_priv=netdev_priv (dev);if (streamer_priv =NULL ) {printk (KERN_ERR "lanstreamer::streamer_remove_one, ERROR dev->priv is NULL\n" );return ;
@@ -448,7 +448,7 @@ static int streamer_reset(struct net_devstruct sk_buff *skb =NULL ;__u16 misr; - streamer_priv = (struct streamer_private *) dev->priv; + streamer_priv =netdev_priv (dev); streamer_mmio = streamer_priv->streamer_mmio;writew (readw (streamer_mmio +BCTL ) |BCTL_SOFTRESET , streamer_mmio +BCTL );
@@ -587,7 +587,7 @@ #endifstatic int streamer_open (struct net_device *dev) { -struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv; +struct streamer_private *streamer_priv =netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;unsigned long flags;char open_error[255 ];
@@ -904,7 +904,7 @@ #endifstatic void streamer_rx (struct net_device *dev) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;struct streamer_rx_desc *rx_desc;int rx_ring_last_received, length, frame_length, buffer_cnt =0 ;
@@ -1029,7 +1029,7 @@ static irqreturn_t streamer_interrupt(in {struct net_device *dev = (struct net_device *) dev_id; struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;__u16 sisr;__u16 misr;
@@ -1152,7 +1152,7 @@ static irqreturn_t streamer_interrupt(instatic int streamer_xmit (struct sk_buff *skb,struct net_device *dev) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;unsigned long flags ;
@@ -1203,7 +1203,7 @@ #endifstatic int streamer_close (struct net_device *dev) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;unsigned long flags;int i;
@@ -1269,7 +1269,7 @@ #endifstatic void streamer_set_rx_mode (struct net_device *dev) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;__u8 options =0 ;struct dev_mc_list *dmi;
@@ -1328,7 +1328,7 @@ static void streamer_set_rx_mode(structstatic void streamer_srb_bh (struct net_device *dev) { -struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv; +struct streamer_private *streamer_priv =netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;__u16 srb_word;
@@ -1493,14 +1493,14 @@ static void streamer_srb_bh(struct net_dstatic struct net_device_stats *streamer_get_stats (struct net_device *dev) {struct streamer_private *streamer_priv; - streamer_priv = (struct streamer_private *) dev->priv; + streamer_priv =netdev_priv (dev);return (struct net_device_stats *) &streamer_priv->streamer_stats; }static int streamer_set_mac_address (struct net_device *dev,void *addr) {struct sockaddr *saddr = addr; -struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv; +struct streamer_private *streamer_priv =netdev_priv (dev);if (netif_running (dev)) {
@@ -1525,7 +1525,7 @@ static int streamer_set_mac_address(strustatic void streamer_arb_cmd (struct net_device *dev) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;__u8 header_len;__u16 frame_len, buffer_len;
@@ -1740,7 +1740,7 @@ drop_frame:static void streamer_asb_bh (struct net_device *dev) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;if (streamer_priv->asb_queued =1 )
@@ -1784,7 +1784,7 @@ static void streamer_asb_bh(struct net_dstatic int streamer_change_mtu (struct net_device *dev,int mtu) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u16 max_mtu;if (streamer_priv->streamer_ring_speed =4 )
@@ -1848,7 +1848,7 @@ static int streamer_proc_info(char *buffstatic int sprintf_info (char *buffer,struct net_device *dev) { struct streamer_private *streamer_priv - (struct streamer_private *) dev->priv; +netdev_priv (dev);__u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;struct streamer_adapter_addr_table sat;struct streamer_parameters_table spt;
drivers/net/tokenring/madgemc.c +2 -2
@@ -690,7 +690,7 @@ static int madgemc_close(struct net_devistatic int madgemc_mcaproc (char *buf,int slot,void *d) {struct net_device *dev = (struct net_device *)d; -struct net_local *tp = dev->priv; +struct net_local *tp =netdev_priv (dev);struct card_info *curcard = tp->tmspriv;int len =0 ;
@@ -736,7 +736,7 @@ static int __devexit madgemc_remove(struBUG_ON (!dev); - tp = dev->priv; + tp =netdev_priv (dev); card = tp->tmspriv;kfree (card); tp->tmspriv =NULL ;
drivers/net/tokenring/olympic.c +18 -18
@@ -219,14 +219,14 @@ static int __devinit olympic_probe(struc goto op_release_dev; } - olympic_priv = dev->priv ; + olympic_priv =netdev_priv (dev) ;spin_lock_init (&olympic_priv->olympic_lock) ;init_waitqueue_head (&olympic_priv->srb_wait);init_waitqueue_head (&olympic_priv->trb_wait);#if OLYMPIC_DEBUG -printk (KERN_INFO "pci_device: %p, dev:%p, dev->priv: %p\n" , pdev, dev, dev->priv); +printk (KERN_INFO "pci_device: %p, dev:%p, dev->priv: %p\n" , pdev, dev,netdev_priv (dev));#endif dev->irq=pdev->irq; dev->base_addr=pci_resource_start (pdev,0 );
@@ -297,7 +297,7 @@ static int __devinit olympic_init(structunsigned long t;unsigned int uaa_addr; - olympic_priv=(struct olympic_private *)dev->priv; + olympic_priv=netdev_priv (dev); olympic_mmio=olympic_priv->olympic_mmio;printk ("%s \n" , version);
@@ -435,7 +435,7 @@ #endifstatic int olympic_open (struct net_device *dev) { -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*init_srb;unsigned long flags, t;int i, open_finished =1 ;
@@ -755,7 +755,7 @@ out:*/ static void olympic_rx (struct net_device *dev) { -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio;struct olympic_rx_status *rx_status;struct olympic_rx_desc *rx_desc ;
@@ -897,7 +897,7 @@ #endifstatic void olympic_freemem (struct net_device *dev) { -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);int i;for (i=0 ;i<OLYMPIC_RX_RING_SIZE ;i++) {
@@ -930,7 +930,7 @@ static void olympic_freemem(struct net_dstatic irqreturn_t olympic_interrupt (int irq,void *dev_id) {struct net_device *dev= (struct net_device *)dev_id; -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio;u32 sisr;u8 __iomem *adapter_check_area ;
@@ -1046,7 +1046,7 @@ static irqreturn_t olympic_interrupt(intstatic int olympic_xmit (struct sk_buff *skb,struct net_device *dev) { -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio;unsigned long flags ;
@@ -1077,7 +1077,7 @@ static int olympic_xmit(struct sk_buff *static int olympic_close (struct net_device *dev) { -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*srb;unsigned long t,flags;
@@ -1147,7 +1147,7 @@ #endifstatic void olympic_set_rx_mode (struct net_device *dev) { -struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv ; +struct olympic_private *olympic_priv =netdev_priv (dev) ;u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ;u8 options =0 ;u8 __iomem *srb;
@@ -1215,7 +1215,7 @@ static void olympic_set_rx_mode(struct nstatic void olympic_srb_bh (struct net_device *dev) { -struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv ; +struct olympic_private *olympic_priv =netdev_priv (dev) ;u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ;u8 __iomem *srb;
@@ -1361,14 +1361,14 @@ static void olympic_srb_bh(struct net_destatic struct net_device_stats *olympic_get_stats (struct net_device *dev) {struct olympic_private *olympic_priv ; - olympic_priv=(struct olympic_private *) dev->priv; + olympic_priv=netdev_priv (dev);return (struct net_device_stats *) &olympic_priv->olympic_stats; }static int olympic_set_mac_address (struct net_device *dev,void *addr) {struct sockaddr *saddr = addr ; -struct olympic_private *olympic_priv = (struct olympic_private *)dev->priv ; +struct olympic_private *olympic_priv =netdev_priv (dev) ;if (netif_running (dev)) {printk (KERN_WARNING "%s: Cannot set mac/laa address while card is open\n" , dev->name) ;
@@ -1389,7 +1389,7 @@ static int olympic_set_mac_address (strustatic void olympic_arb_cmd (struct net_device *dev) { -struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv; +struct olympic_private *olympic_priv =netdev_priv (dev);u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio;u8 __iomem *arb_block, *asb_block, *srb ;u8 header_len ;
@@ -1575,7 +1575,7 @@ drop_frame:static void olympic_asb_bh (struct net_device *dev) { -struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv ; +struct olympic_private *olympic_priv =netdev_priv (dev) ;u8 __iomem *arb_block, *asb_block ; arb_block = (olympic_priv->olympic_lap + olympic_priv->arb) ;
@@ -1615,7 +1615,7 @@ static void olympic_asb_bh(struct net_destatic int olympic_change_mtu (struct net_device *dev,int mtu) { -struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv; +struct olympic_private *olympic_priv =netdev_priv (dev);u16 max_mtu ;if (olympic_priv->olympic_ring_speed =4 )
@@ -1637,7 +1637,7 @@ static int olympic_change_mtu(struct netstatic int olympic_proc_info (char *buffer,char **start,off_t offset,int length,int *eof,void *data) {struct net_device *dev = (struct net_device *)data ; -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);u8 __iomem *oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr) ;u8 __iomem *opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr) ;int size =0 ;
@@ -1748,7 +1748,7 @@ static int olympic_proc_info(char *buffe static void __devexit olympic_remove_one(struct pci_dev *pdev) {struct net_device *dev =pci_get_drvdata (pdev) ; -struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; +struct olympic_private *olympic_priv=netdev_priv (dev);if (olympic_priv->olympic_network_monitor) {char proc_name[20 ] ;
drivers/net/tokenring/tmspci.c +2 -2
@@ -149,7 +149,7 @@ static int __devinit tms_pci_attach(stru goto err_out_irq; } - tp = dev->priv; + tp =netdev_priv (dev); tp->setnselout = tms_pci_setnselout_pins; tp->sifreadb = tms_pci_sifreadb;
@@ -210,7 +210,7 @@ static void tms_pci_read_eeprom(struct nstatic unsigned short tms_pci_setnselout_pins (struct net_device *dev) {unsigned short val =0 ; -struct net_local *tp = dev->priv; +struct net_local *tp =netdev_priv (dev);struct card_info *cardinfo = tp->tmspriv;if (tp->DataRate =SPEED_4 )
-
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Yoann Padioleau
Here is an excerpt of the semantic patch that performs the transformation
@@
- (T*)
dev->priv
+netdev_priv(dev)
Note that dev->priv is a void*, and hence does not need casting. So dev->priv may also appear without one.
Quoted 7 lines
{
(quoted diff) +1
-1- struct xl_private *xl_priv = (struct xl_private *)dev->priv ; + struct xl_private *xl_priv = netdev_priv(dev) ;struct xl_tx_desc *txd ; u8 __iomem *xl_mmio = xl_priv->xl_mmio ; int i ;
Jan
Quoted 11 lines · Jan Engelhardt
Quoted 7 lines · Yoann Padioleau
Here is an excerpt of the semantic patch that performs the transformation
@@
- (T*)
dev->priv
+netdev_priv(dev)Note that
dev->privis a void*, and hence does not need casting. Sodev->privmay also appear without one.
Yes you are right. I have shown only an excerpt of the semantic patch. Sorry. There is another rule:
@ rule3 depends on rule1 && !rule1bis @
struct net_device *dev;
@@
- dev->priv
+ netdev_priv(dev)
If you look at my patch there is one such case
- struct tok_info *ti = dev->priv;
+ struct tok_info *ti = netdev_priv(dev);
Jeff Garzik
AppliedQuoted 35 lines · Yoann Padioleau
Replacing accesses to
dev->privtonetdev_priv(dev). The replacment
is safe whennetdev_privis used to access a private structure that is
right next to thenet_devicestructure in memory.
Cf http://groups.google.com/group/comp.os.linux.development.system/browse_thread/thread/de19321bcd94dbb8/0d74a4adcd6177bd
This is the case when thenet_devicestructure was allocated with
a call toalloc_netdevor one of its derivative.Here is an excerpt of the semantic patch that performs the transformation
@ rule1 @
type T;
structnet_device*dev;
@@dev =
(
alloc_netdev
|
alloc_etherdev
|
alloc_trdev
)
(sizeof(T), ...)@ rule1bis @
structnet_device*dev;
expression E;
@@
dev->priv= E@ rule2 depends on rule1 && !rule1bis @
structnet_device*dev;
type rule1.T;
@@
Quoted 7 lines
- (T*)
dev->priv
+netdev_priv(dev)PS: I have performed the same transformation on the whole kernel and it affects around 70 files, most of them in
drivers/net/. Should I split my patch for each subnet directories ? (wireless/, wan/, etc)
applied. splitting up by sub-directory would be helpful.
dev->priv to netdev_priv(dev)
Quoted 5 lines · Jeff Garzik
Quoted 3 lines
PS: I have performed the same transformation on the whole kernel and it affects around 70 files, most of them in
drivers/net/. Should I split my patch for each subnet directories ? (wireless/, wan/, etc)applied. splitting up by sub-directory would be helpful.
Done. I was not always able to find the maintainer for all the subdirectories so for those cases I have considered you as the maintainer :)
I have run another semantic patch (more like a semantic grep in fact) to find the places where our tool didn't transform the dev->priv to netdev_priv. The reason is that our tool was not able to find the call to alloc_dev_xxx(sizeof(T),...) in the driver or there was an assignation to dev->priv which means that transforming to netdev_priv would do something wrong. I have printed the list of "bad driver" below.
In very few cases the driver was in fact "good" but because of the way the code was written, our tool was not able to find the alloc_xxx function.
drivers/net/82596.cdrivers/net/chelsio/cxgb2.cdrivers/net/chelsio/sge.cdrivers/net/cxgb3/cxgb3_main.cdrivers/net/cxgb3/sge.cdrivers/net/e1000/e1000_main.cdrivers/net/ehea/ehea_main.cdrivers/net/hamradio/dmascc.cdrivers/net/hamradio/scc.cdrivers/net/lance.cdrivers/net/mace.c
for mace.c the code is written this way:
#define PRIV_BYTES (sizeof(struct mace_data) \
+ (N_RX_RING + NCMDS_TX * N_TX_RING + 3) * sizeof(struct dbdma_cmd))
dev = alloc_etherdev(PRIV_BYTES); So our semantic patch can't find a alloc_etherdev(sizeof(T)).
If I inline the definition of PRIV_BYTES, then our tool will be able to transform it.
drivers/net/ni65.cdrivers/net/pcmcia/com20020_cs.c
dev = alloc_arcdev("");drivers/net/ppp_generic.cdrivers/net/spider_net_ethtool.c
again, the code is written this way:
alloc_size = sizeof(struct spider_net_card) +
(tx_descriptors + rx_descriptors) * sizeof(struct spider_net_descr);
netdev = alloc_etherdev(alloc_size); If I inline the definition of alloc_size, then we can transform the file.
drivers/net/tulip/xircom_cb.cdrivers/net/wan/cosa.cdrivers/net/wan/cycx_x25.cdrivers/net/wan/hdlc_fr.cdrivers/net/wan/hdlc_ppp.cdrivers/net/wan/hostess_sv11.cdrivers/net/wan/pc300_drv.cdrivers/net/wan/sbni.cdrivers/net/wireless/airo.cdrivers/net/wireless/libertas/ethtool.cdrivers/net/wireless/libertas/main.cdrivers/net/wireless/libertas/scan.cdrivers/net/wireless/libertas/wext.cdrivers/net/wireless/wavelan.cdrivers/net/wireless/zd1201.c
drivers/net/tokenring/tms380tr.c
This file is both used as a single module and used by other module. The other modules have a call to a alloc_xxx but not tms380tr.c when used as a single module.
Re: dev->priv to netdev_priv(dev)
Quoted 1 line · Yoann Padioleau
drivers/net/wan/hdlc_fr.c
hdlc_fr (PVC device) uses dev->priv for N:1 mappings (a single pvc structure may be referenced as dev->priv by multiple (up to 2 currently) PVC devs).
Quoted 1 line
drivers/net/wan/hdlc_ppp.c
hdlc_ppp obviously has to do some tricks to use syncppp:
static int ppp_open(struct net_device *dev)
{
hdlc_device *hdlc = dev_to_hdlc(dev);
void *old_ioctl;
int result;
dev->priv = &state(hdlc)->syncppp_ptr;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev;
state(hdlc)->pppdev.dev = dev;
old_ioctl = dev->do_ioctl;
state(hdlc)->old_change_mtu = dev->change_mtu;
sppp_attach(&state(hdlc)->pppdev);Perhaps I should remove that and make a sane interface in syncppp.
Signature · 1 line
Krzysztof Halasa