diff options
author | Yoann Padioleau <padator@wanadoo.fr> | 2007-07-23 09:18:21 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:50:19 -0400 |
commit | eda105317fece79fa7e8478214ff7450f5a3f9dd (patch) | |
tree | 4d781702bd664c58629bd649a929d78874de400c /drivers/net/tokenring/3c359.c | |
parent | af096046f63a065b692018cd4b8f5e7525c3e56a (diff) |
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.
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
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(-)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/tokenring/3c359.c')
-rw-r--r-- | drivers/net/tokenring/3c359.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c index 9f1b6ab9c228..6612db8ec215 100644 --- a/drivers/net/tokenring/3c359.c +++ b/drivers/net/tokenring/3c359.c | |||
@@ -156,7 +156,7 @@ static void print_rx_state(struct net_device *dev) ; | |||
156 | static void print_tx_state(struct net_device *dev) | 156 | static void print_tx_state(struct net_device *dev) |
157 | { | 157 | { |
158 | 158 | ||
159 | struct xl_private *xl_priv = (struct xl_private *)dev->priv ; | 159 | struct xl_private *xl_priv = netdev_priv(dev); |
160 | struct xl_tx_desc *txd ; | 160 | struct xl_tx_desc *txd ; |
161 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; | 161 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; |
162 | int i ; | 162 | int i ; |
@@ -179,7 +179,7 @@ static void print_tx_state(struct net_device *dev) | |||
179 | static void print_rx_state(struct net_device *dev) | 179 | static void print_rx_state(struct net_device *dev) |
180 | { | 180 | { |
181 | 181 | ||
182 | struct xl_private *xl_priv = (struct xl_private *)dev->priv ; | 182 | struct xl_private *xl_priv = netdev_priv(dev); |
183 | struct xl_rx_desc *rxd ; | 183 | struct xl_rx_desc *rxd ; |
184 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; | 184 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; |
185 | int i ; | 185 | int i ; |
@@ -213,7 +213,7 @@ static void print_rx_state(struct net_device *dev) | |||
213 | 213 | ||
214 | static u16 xl_ee_read(struct net_device *dev, int ee_addr) | 214 | static u16 xl_ee_read(struct net_device *dev, int ee_addr) |
215 | { | 215 | { |
216 | struct xl_private *xl_priv = (struct xl_private *)dev->priv ; | 216 | struct xl_private *xl_priv = netdev_priv(dev); |
217 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; | 217 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; |
218 | 218 | ||
219 | /* Wait for EEProm to not be busy */ | 219 | /* Wait for EEProm to not be busy */ |
@@ -245,7 +245,7 @@ static u16 xl_ee_read(struct net_device *dev, int ee_addr) | |||
245 | 245 | ||
246 | static void xl_ee_write(struct net_device *dev, int ee_addr, u16 ee_value) | 246 | static void xl_ee_write(struct net_device *dev, int ee_addr, u16 ee_value) |
247 | { | 247 | { |
248 | struct xl_private *xl_priv = (struct xl_private *)dev->priv ; | 248 | struct xl_private *xl_priv = netdev_priv(dev); |
249 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; | 249 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; |
250 | 250 | ||
251 | /* Wait for EEProm to not be busy */ | 251 | /* Wait for EEProm to not be busy */ |
@@ -305,11 +305,11 @@ static int __devinit xl_probe(struct pci_dev *pdev, | |||
305 | pci_release_regions(pdev) ; | 305 | pci_release_regions(pdev) ; |
306 | return -ENOMEM ; | 306 | return -ENOMEM ; |
307 | } | 307 | } |
308 | xl_priv = dev->priv ; | 308 | xl_priv = netdev_priv(dev); |
309 | 309 | ||
310 | #if XL_DEBUG | 310 | #if XL_DEBUG |
311 | printk("pci_device: %p, dev:%p, dev->priv: %p, ba[0]: %10x, ba[1]:%10x\n", | 311 | printk("pci_device: %p, dev:%p, dev->priv: %p, ba[0]: %10x, ba[1]:%10x\n", |
312 | pdev, dev, dev->priv, (unsigned int)pdev->resource[0].start, (unsigned int)pdev->resource[1].start) ; | 312 | pdev, dev, netdev_priv(dev), (unsigned int)pdev->resource[0].start, (unsigned int)pdev->resource[1].start); |
313 | #endif | 313 | #endif |
314 | 314 | ||
315 | dev->irq=pdev->irq; | 315 | dev->irq=pdev->irq; |
@@ -365,7 +365,7 @@ static int __devinit xl_probe(struct pci_dev *pdev, | |||
365 | 365 | ||
366 | static int __devinit xl_init(struct net_device *dev) | 366 | static int __devinit xl_init(struct net_device *dev) |
367 | { | 367 | { |
368 | struct xl_private *xl_priv = (struct xl_private *)dev->priv ; | 368 | struct xl_private *xl_priv = netdev_priv(dev); |
369 | 369 | ||
370 | printk(KERN_INFO "%s \n", version); | 370 | printk(KERN_INFO "%s \n", version); |
371 | printk(KERN_INFO "%s: I/O at %hx, MMIO at %p, using irq %d\n", | 371 | 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_device *dev) | |||
385 | 385 | ||
386 | static int xl_hw_reset(struct net_device *dev) | 386 | static int xl_hw_reset(struct net_device *dev) |
387 | { | 387 | { |
388 | struct xl_private *xl_priv = (struct xl_private *)dev->priv ; | 388 | struct xl_private *xl_priv = netdev_priv(dev); |
389 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; | 389 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; |
390 | unsigned long t ; | 390 | unsigned long t ; |
391 | u16 i ; | 391 | u16 i ; |
@@ -568,7 +568,7 @@ static int xl_hw_reset(struct net_device *dev) | |||
568 | 568 | ||
569 | static int xl_open(struct net_device *dev) | 569 | static int xl_open(struct net_device *dev) |
570 | { | 570 | { |
571 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 571 | struct xl_private *xl_priv=netdev_priv(dev); |
572 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; | 572 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; |
573 | u8 i ; | 573 | u8 i ; |
574 | u16 hwaddr[3] ; /* Should be u8[6] but we get word return values */ | 574 | u16 hwaddr[3] ; /* Should be u8[6] but we get word return values */ |
@@ -726,7 +726,7 @@ static int xl_open(struct net_device *dev) | |||
726 | 726 | ||
727 | static int xl_open_hw(struct net_device *dev) | 727 | static int xl_open_hw(struct net_device *dev) |
728 | { | 728 | { |
729 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 729 | struct xl_private *xl_priv=netdev_priv(dev); |
730 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; | 730 | u8 __iomem *xl_mmio = xl_priv->xl_mmio ; |
731 | u16 vsoff ; | 731 | u16 vsoff ; |
732 | char ver_str[33]; | 732 | char ver_str[33]; |
@@ -875,7 +875,7 @@ static int xl_open_hw(struct net_device *dev) | |||
875 | 875 | ||
876 | static void adv_rx_ring(struct net_device *dev) /* Advance rx_ring, cut down on bloat in xl_rx */ | 876 | static void adv_rx_ring(struct net_device *dev) /* Advance rx_ring, cut down on bloat in xl_rx */ |
877 | { | 877 | { |
878 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 878 | struct xl_private *xl_priv=netdev_priv(dev); |
879 | int prev_ring_loc ; | 879 | int prev_ring_loc ; |
880 | 880 | ||
881 | prev_ring_loc = (xl_priv->rx_ring_tail + XL_RX_RING_SIZE - 1) & (XL_RX_RING_SIZE - 1); | 881 | 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_device *dev) /* Advance rx_ring, cut down on | |||
890 | 890 | ||
891 | static void xl_rx(struct net_device *dev) | 891 | static void xl_rx(struct net_device *dev) |
892 | { | 892 | { |
893 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 893 | struct xl_private *xl_priv=netdev_priv(dev); |
894 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 894 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
895 | struct sk_buff *skb, *skb2 ; | 895 | struct sk_buff *skb, *skb2 ; |
896 | int frame_length = 0, copy_len = 0 ; | 896 | int frame_length = 0, copy_len = 0 ; |
@@ -997,7 +997,7 @@ static void xl_rx(struct net_device *dev) | |||
997 | 997 | ||
998 | static void xl_reset(struct net_device *dev) | 998 | static void xl_reset(struct net_device *dev) |
999 | { | 999 | { |
1000 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 1000 | struct xl_private *xl_priv=netdev_priv(dev); |
1001 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1001 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1002 | unsigned long t; | 1002 | unsigned long t; |
1003 | 1003 | ||
@@ -1020,7 +1020,7 @@ static void xl_reset(struct net_device *dev) | |||
1020 | 1020 | ||
1021 | static void xl_freemem(struct net_device *dev) | 1021 | static void xl_freemem(struct net_device *dev) |
1022 | { | 1022 | { |
1023 | struct xl_private *xl_priv=(struct xl_private *)dev->priv ; | 1023 | struct xl_private *xl_priv=netdev_priv(dev); |
1024 | int i ; | 1024 | int i ; |
1025 | 1025 | ||
1026 | for (i=0;i<XL_RX_RING_SIZE;i++) { | 1026 | for (i=0;i<XL_RX_RING_SIZE;i++) { |
@@ -1044,7 +1044,7 @@ static void xl_freemem(struct net_device *dev) | |||
1044 | static irqreturn_t xl_interrupt(int irq, void *dev_id) | 1044 | static irqreturn_t xl_interrupt(int irq, void *dev_id) |
1045 | { | 1045 | { |
1046 | struct net_device *dev = (struct net_device *)dev_id; | 1046 | struct net_device *dev = (struct net_device *)dev_id; |
1047 | struct xl_private *xl_priv =(struct xl_private *)dev->priv; | 1047 | struct xl_private *xl_priv =netdev_priv(dev); |
1048 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1048 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1049 | u16 intstatus, macstatus ; | 1049 | u16 intstatus, macstatus ; |
1050 | 1050 | ||
@@ -1171,7 +1171,7 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id) | |||
1171 | 1171 | ||
1172 | static int xl_xmit(struct sk_buff *skb, struct net_device *dev) | 1172 | static int xl_xmit(struct sk_buff *skb, struct net_device *dev) |
1173 | { | 1173 | { |
1174 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 1174 | struct xl_private *xl_priv=netdev_priv(dev); |
1175 | struct xl_tx_desc *txd ; | 1175 | struct xl_tx_desc *txd ; |
1176 | int tx_head, tx_tail, tx_prev ; | 1176 | int tx_head, tx_tail, tx_prev ; |
1177 | unsigned long flags ; | 1177 | unsigned long flags ; |
@@ -1232,7 +1232,7 @@ static int xl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1232 | 1232 | ||
1233 | static void xl_dn_comp(struct net_device *dev) | 1233 | static void xl_dn_comp(struct net_device *dev) |
1234 | { | 1234 | { |
1235 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 1235 | struct xl_private *xl_priv=netdev_priv(dev); |
1236 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1236 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1237 | struct xl_tx_desc *txd ; | 1237 | struct xl_tx_desc *txd ; |
1238 | 1238 | ||
@@ -1268,7 +1268,7 @@ static void xl_dn_comp(struct net_device *dev) | |||
1268 | 1268 | ||
1269 | static int xl_close(struct net_device *dev) | 1269 | static int xl_close(struct net_device *dev) |
1270 | { | 1270 | { |
1271 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1271 | struct xl_private *xl_priv = netdev_priv(dev); |
1272 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1272 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1273 | unsigned long t ; | 1273 | unsigned long t ; |
1274 | 1274 | ||
@@ -1366,7 +1366,7 @@ static int xl_close(struct net_device *dev) | |||
1366 | 1366 | ||
1367 | static void xl_set_rx_mode(struct net_device *dev) | 1367 | static void xl_set_rx_mode(struct net_device *dev) |
1368 | { | 1368 | { |
1369 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1369 | struct xl_private *xl_priv = netdev_priv(dev); |
1370 | struct dev_mc_list *dmi ; | 1370 | struct dev_mc_list *dmi ; |
1371 | unsigned char dev_mc_address[4] ; | 1371 | unsigned char dev_mc_address[4] ; |
1372 | u16 options ; | 1372 | u16 options ; |
@@ -1407,7 +1407,7 @@ static void xl_set_rx_mode(struct net_device *dev) | |||
1407 | 1407 | ||
1408 | static void xl_srb_bh(struct net_device *dev) | 1408 | static void xl_srb_bh(struct net_device *dev) |
1409 | { | 1409 | { |
1410 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1410 | struct xl_private *xl_priv = netdev_priv(dev); |
1411 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1411 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1412 | u8 srb_cmd, ret_code ; | 1412 | u8 srb_cmd, ret_code ; |
1413 | int i ; | 1413 | int i ; |
@@ -1476,14 +1476,14 @@ static void xl_srb_bh(struct net_device *dev) | |||
1476 | 1476 | ||
1477 | static struct net_device_stats * xl_get_stats(struct net_device *dev) | 1477 | static struct net_device_stats * xl_get_stats(struct net_device *dev) |
1478 | { | 1478 | { |
1479 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1479 | struct xl_private *xl_priv = netdev_priv(dev); |
1480 | return (struct net_device_stats *) &xl_priv->xl_stats; | 1480 | return (struct net_device_stats *) &xl_priv->xl_stats; |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | static int xl_set_mac_address (struct net_device *dev, void *addr) | 1483 | static int xl_set_mac_address (struct net_device *dev, void *addr) |
1484 | { | 1484 | { |
1485 | struct sockaddr *saddr = addr ; | 1485 | struct sockaddr *saddr = addr ; |
1486 | struct xl_private *xl_priv = (struct xl_private *)dev->priv ; | 1486 | struct xl_private *xl_priv = netdev_priv(dev); |
1487 | 1487 | ||
1488 | if (netif_running(dev)) { | 1488 | if (netif_running(dev)) { |
1489 | printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name) ; | 1489 | 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 net_device *dev, void *addr) | |||
1504 | 1504 | ||
1505 | static void xl_arb_cmd(struct net_device *dev) | 1505 | static void xl_arb_cmd(struct net_device *dev) |
1506 | { | 1506 | { |
1507 | struct xl_private *xl_priv = (struct xl_private *) dev->priv; | 1507 | struct xl_private *xl_priv = netdev_priv(dev); |
1508 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1508 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1509 | u8 arb_cmd ; | 1509 | u8 arb_cmd ; |
1510 | u16 lan_status, lan_status_diff ; | 1510 | u16 lan_status, lan_status_diff ; |
@@ -1632,7 +1632,7 @@ static void xl_arb_cmd(struct net_device *dev) | |||
1632 | 1632 | ||
1633 | static void xl_asb_cmd(struct net_device *dev) | 1633 | static void xl_asb_cmd(struct net_device *dev) |
1634 | { | 1634 | { |
1635 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1635 | struct xl_private *xl_priv = netdev_priv(dev); |
1636 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1636 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1637 | 1637 | ||
1638 | if (xl_priv->asb_queued == 1) | 1638 | if (xl_priv->asb_queued == 1) |
@@ -1663,7 +1663,7 @@ static void xl_asb_cmd(struct net_device *dev) | |||
1663 | */ | 1663 | */ |
1664 | static void xl_asb_bh(struct net_device *dev) | 1664 | static void xl_asb_bh(struct net_device *dev) |
1665 | { | 1665 | { |
1666 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1666 | struct xl_private *xl_priv = netdev_priv(dev); |
1667 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1667 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1668 | u8 ret_code ; | 1668 | u8 ret_code ; |
1669 | 1669 | ||
@@ -1691,7 +1691,7 @@ static void xl_asb_bh(struct net_device *dev) | |||
1691 | 1691 | ||
1692 | static void xl_srb_cmd(struct net_device *dev, int srb_cmd) | 1692 | static void xl_srb_cmd(struct net_device *dev, int srb_cmd) |
1693 | { | 1693 | { |
1694 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1694 | struct xl_private *xl_priv = netdev_priv(dev); |
1695 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1695 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1696 | 1696 | ||
1697 | switch (srb_cmd) { | 1697 | switch (srb_cmd) { |
@@ -1748,7 +1748,7 @@ static void xl_srb_cmd(struct net_device *dev, int srb_cmd) | |||
1748 | 1748 | ||
1749 | static void xl_wait_misr_flags(struct net_device *dev) | 1749 | static void xl_wait_misr_flags(struct net_device *dev) |
1750 | { | 1750 | { |
1751 | struct xl_private *xl_priv = (struct xl_private *) dev->priv ; | 1751 | struct xl_private *xl_priv = netdev_priv(dev); |
1752 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; | 1752 | u8 __iomem * xl_mmio = xl_priv->xl_mmio ; |
1753 | 1753 | ||
1754 | int i ; | 1754 | int i ; |
@@ -1773,7 +1773,7 @@ static void xl_wait_misr_flags(struct net_device *dev) | |||
1773 | 1773 | ||
1774 | static int xl_change_mtu(struct net_device *dev, int mtu) | 1774 | static int xl_change_mtu(struct net_device *dev, int mtu) |
1775 | { | 1775 | { |
1776 | struct xl_private *xl_priv = (struct xl_private *) dev->priv; | 1776 | struct xl_private *xl_priv = netdev_priv(dev); |
1777 | u16 max_mtu ; | 1777 | u16 max_mtu ; |
1778 | 1778 | ||
1779 | if (xl_priv->xl_ring_speed == 4) | 1779 | if (xl_priv->xl_ring_speed == 4) |
@@ -1795,7 +1795,7 @@ static int xl_change_mtu(struct net_device *dev, int mtu) | |||
1795 | static void __devexit xl_remove_one (struct pci_dev *pdev) | 1795 | static void __devexit xl_remove_one (struct pci_dev *pdev) |
1796 | { | 1796 | { |
1797 | struct net_device *dev = pci_get_drvdata(pdev); | 1797 | struct net_device *dev = pci_get_drvdata(pdev); |
1798 | struct xl_private *xl_priv=(struct xl_private *)dev->priv; | 1798 | struct xl_private *xl_priv=netdev_priv(dev); |
1799 | 1799 | ||
1800 | unregister_netdev(dev); | 1800 | unregister_netdev(dev); |
1801 | iounmap(xl_priv->xl_mmio) ; | 1801 | iounmap(xl_priv->xl_mmio) ; |