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/olympic.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/olympic.c')
-rw-r--r-- | drivers/net/tokenring/olympic.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c index c323101a895b..b57f65b2591a 100644 --- a/drivers/net/tokenring/olympic.c +++ b/drivers/net/tokenring/olympic.c | |||
@@ -220,14 +220,14 @@ static int __devinit olympic_probe(struct pci_dev *pdev, const struct pci_device | |||
220 | goto op_release_dev; | 220 | goto op_release_dev; |
221 | } | 221 | } |
222 | 222 | ||
223 | olympic_priv = dev->priv ; | 223 | olympic_priv = netdev_priv(dev) ; |
224 | 224 | ||
225 | spin_lock_init(&olympic_priv->olympic_lock) ; | 225 | spin_lock_init(&olympic_priv->olympic_lock) ; |
226 | 226 | ||
227 | init_waitqueue_head(&olympic_priv->srb_wait); | 227 | init_waitqueue_head(&olympic_priv->srb_wait); |
228 | init_waitqueue_head(&olympic_priv->trb_wait); | 228 | init_waitqueue_head(&olympic_priv->trb_wait); |
229 | #if OLYMPIC_DEBUG | 229 | #if OLYMPIC_DEBUG |
230 | printk(KERN_INFO "pci_device: %p, dev:%p, dev->priv: %p\n", pdev, dev, dev->priv); | 230 | printk(KERN_INFO "pci_device: %p, dev:%p, dev->priv: %p\n", pdev, dev, netdev_priv(dev)); |
231 | #endif | 231 | #endif |
232 | dev->irq=pdev->irq; | 232 | dev->irq=pdev->irq; |
233 | dev->base_addr=pci_resource_start(pdev, 0); | 233 | dev->base_addr=pci_resource_start(pdev, 0); |
@@ -298,7 +298,7 @@ static int __devinit olympic_init(struct net_device *dev) | |||
298 | unsigned long t; | 298 | unsigned long t; |
299 | unsigned int uaa_addr; | 299 | unsigned int uaa_addr; |
300 | 300 | ||
301 | olympic_priv=(struct olympic_private *)dev->priv; | 301 | olympic_priv=netdev_priv(dev); |
302 | olympic_mmio=olympic_priv->olympic_mmio; | 302 | olympic_mmio=olympic_priv->olympic_mmio; |
303 | 303 | ||
304 | printk("%s \n", version); | 304 | printk("%s \n", version); |
@@ -436,7 +436,7 @@ static int __devinit olympic_init(struct net_device *dev) | |||
436 | 436 | ||
437 | static int olympic_open(struct net_device *dev) | 437 | static int olympic_open(struct net_device *dev) |
438 | { | 438 | { |
439 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 439 | struct olympic_private *olympic_priv=netdev_priv(dev); |
440 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*init_srb; | 440 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*init_srb; |
441 | unsigned long flags, t; | 441 | unsigned long flags, t; |
442 | int i, open_finished = 1 ; | 442 | int i, open_finished = 1 ; |
@@ -756,7 +756,7 @@ out: | |||
756 | */ | 756 | */ |
757 | static void olympic_rx(struct net_device *dev) | 757 | static void olympic_rx(struct net_device *dev) |
758 | { | 758 | { |
759 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 759 | struct olympic_private *olympic_priv=netdev_priv(dev); |
760 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; | 760 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; |
761 | struct olympic_rx_status *rx_status; | 761 | struct olympic_rx_status *rx_status; |
762 | struct olympic_rx_desc *rx_desc ; | 762 | struct olympic_rx_desc *rx_desc ; |
@@ -898,7 +898,7 @@ static void olympic_rx(struct net_device *dev) | |||
898 | 898 | ||
899 | static void olympic_freemem(struct net_device *dev) | 899 | static void olympic_freemem(struct net_device *dev) |
900 | { | 900 | { |
901 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 901 | struct olympic_private *olympic_priv=netdev_priv(dev); |
902 | int i; | 902 | int i; |
903 | 903 | ||
904 | for(i=0;i<OLYMPIC_RX_RING_SIZE;i++) { | 904 | for(i=0;i<OLYMPIC_RX_RING_SIZE;i++) { |
@@ -931,7 +931,7 @@ static void olympic_freemem(struct net_device *dev) | |||
931 | static irqreturn_t olympic_interrupt(int irq, void *dev_id) | 931 | static irqreturn_t olympic_interrupt(int irq, void *dev_id) |
932 | { | 932 | { |
933 | struct net_device *dev= (struct net_device *)dev_id; | 933 | struct net_device *dev= (struct net_device *)dev_id; |
934 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 934 | struct olympic_private *olympic_priv=netdev_priv(dev); |
935 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; | 935 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; |
936 | u32 sisr; | 936 | u32 sisr; |
937 | u8 __iomem *adapter_check_area ; | 937 | u8 __iomem *adapter_check_area ; |
@@ -1047,7 +1047,7 @@ static irqreturn_t olympic_interrupt(int irq, void *dev_id) | |||
1047 | 1047 | ||
1048 | static int olympic_xmit(struct sk_buff *skb, struct net_device *dev) | 1048 | static int olympic_xmit(struct sk_buff *skb, struct net_device *dev) |
1049 | { | 1049 | { |
1050 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 1050 | struct olympic_private *olympic_priv=netdev_priv(dev); |
1051 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; | 1051 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; |
1052 | unsigned long flags ; | 1052 | unsigned long flags ; |
1053 | 1053 | ||
@@ -1078,7 +1078,7 @@ static int olympic_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1078 | 1078 | ||
1079 | static int olympic_close(struct net_device *dev) | 1079 | static int olympic_close(struct net_device *dev) |
1080 | { | 1080 | { |
1081 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 1081 | struct olympic_private *olympic_priv=netdev_priv(dev); |
1082 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*srb; | 1082 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio,*srb; |
1083 | unsigned long t,flags; | 1083 | unsigned long t,flags; |
1084 | 1084 | ||
@@ -1148,7 +1148,7 @@ static int olympic_close(struct net_device *dev) | |||
1148 | 1148 | ||
1149 | static void olympic_set_rx_mode(struct net_device *dev) | 1149 | static void olympic_set_rx_mode(struct net_device *dev) |
1150 | { | 1150 | { |
1151 | struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv ; | 1151 | struct olympic_private *olympic_priv = netdev_priv(dev); |
1152 | u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ; | 1152 | u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ; |
1153 | u8 options = 0; | 1153 | u8 options = 0; |
1154 | u8 __iomem *srb; | 1154 | u8 __iomem *srb; |
@@ -1216,7 +1216,7 @@ static void olympic_set_rx_mode(struct net_device *dev) | |||
1216 | 1216 | ||
1217 | static void olympic_srb_bh(struct net_device *dev) | 1217 | static void olympic_srb_bh(struct net_device *dev) |
1218 | { | 1218 | { |
1219 | struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv ; | 1219 | struct olympic_private *olympic_priv = netdev_priv(dev); |
1220 | u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ; | 1220 | u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ; |
1221 | u8 __iomem *srb; | 1221 | u8 __iomem *srb; |
1222 | 1222 | ||
@@ -1362,14 +1362,14 @@ static void olympic_srb_bh(struct net_device *dev) | |||
1362 | static struct net_device_stats * olympic_get_stats(struct net_device *dev) | 1362 | static struct net_device_stats * olympic_get_stats(struct net_device *dev) |
1363 | { | 1363 | { |
1364 | struct olympic_private *olympic_priv ; | 1364 | struct olympic_private *olympic_priv ; |
1365 | olympic_priv=(struct olympic_private *) dev->priv; | 1365 | olympic_priv=netdev_priv(dev); |
1366 | return (struct net_device_stats *) &olympic_priv->olympic_stats; | 1366 | return (struct net_device_stats *) &olympic_priv->olympic_stats; |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | static int olympic_set_mac_address (struct net_device *dev, void *addr) | 1369 | static int olympic_set_mac_address (struct net_device *dev, void *addr) |
1370 | { | 1370 | { |
1371 | struct sockaddr *saddr = addr ; | 1371 | struct sockaddr *saddr = addr ; |
1372 | struct olympic_private *olympic_priv = (struct olympic_private *)dev->priv ; | 1372 | struct olympic_private *olympic_priv = netdev_priv(dev); |
1373 | 1373 | ||
1374 | if (netif_running(dev)) { | 1374 | if (netif_running(dev)) { |
1375 | printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name) ; | 1375 | printk(KERN_WARNING "%s: Cannot set mac/laa address while card is open\n", dev->name) ; |
@@ -1390,7 +1390,7 @@ static int olympic_set_mac_address (struct net_device *dev, void *addr) | |||
1390 | 1390 | ||
1391 | static void olympic_arb_cmd(struct net_device *dev) | 1391 | static void olympic_arb_cmd(struct net_device *dev) |
1392 | { | 1392 | { |
1393 | struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv; | 1393 | struct olympic_private *olympic_priv = netdev_priv(dev); |
1394 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; | 1394 | u8 __iomem *olympic_mmio=olympic_priv->olympic_mmio; |
1395 | u8 __iomem *arb_block, *asb_block, *srb ; | 1395 | u8 __iomem *arb_block, *asb_block, *srb ; |
1396 | u8 header_len ; | 1396 | u8 header_len ; |
@@ -1576,7 +1576,7 @@ drop_frame: | |||
1576 | 1576 | ||
1577 | static void olympic_asb_bh(struct net_device *dev) | 1577 | static void olympic_asb_bh(struct net_device *dev) |
1578 | { | 1578 | { |
1579 | struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv ; | 1579 | struct olympic_private *olympic_priv = netdev_priv(dev); |
1580 | u8 __iomem *arb_block, *asb_block ; | 1580 | u8 __iomem *arb_block, *asb_block ; |
1581 | 1581 | ||
1582 | arb_block = (olympic_priv->olympic_lap + olympic_priv->arb) ; | 1582 | arb_block = (olympic_priv->olympic_lap + olympic_priv->arb) ; |
@@ -1616,7 +1616,7 @@ static void olympic_asb_bh(struct net_device *dev) | |||
1616 | 1616 | ||
1617 | static int olympic_change_mtu(struct net_device *dev, int mtu) | 1617 | static int olympic_change_mtu(struct net_device *dev, int mtu) |
1618 | { | 1618 | { |
1619 | struct olympic_private *olympic_priv = (struct olympic_private *) dev->priv; | 1619 | struct olympic_private *olympic_priv = netdev_priv(dev); |
1620 | u16 max_mtu ; | 1620 | u16 max_mtu ; |
1621 | 1621 | ||
1622 | if (olympic_priv->olympic_ring_speed == 4) | 1622 | if (olympic_priv->olympic_ring_speed == 4) |
@@ -1638,7 +1638,7 @@ static int olympic_change_mtu(struct net_device *dev, int mtu) | |||
1638 | static int olympic_proc_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data) | 1638 | static int olympic_proc_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data) |
1639 | { | 1639 | { |
1640 | struct net_device *dev = (struct net_device *)data ; | 1640 | struct net_device *dev = (struct net_device *)data ; |
1641 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 1641 | struct olympic_private *olympic_priv=netdev_priv(dev); |
1642 | u8 __iomem *oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr) ; | 1642 | u8 __iomem *oat = (olympic_priv->olympic_lap + olympic_priv->olympic_addr_table_addr) ; |
1643 | u8 __iomem *opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr) ; | 1643 | u8 __iomem *opt = (olympic_priv->olympic_lap + olympic_priv->olympic_parms_addr) ; |
1644 | int size = 0 ; | 1644 | int size = 0 ; |
@@ -1749,7 +1749,7 @@ static int olympic_proc_info(char *buffer, char **start, off_t offset, int lengt | |||
1749 | static void __devexit olympic_remove_one(struct pci_dev *pdev) | 1749 | static void __devexit olympic_remove_one(struct pci_dev *pdev) |
1750 | { | 1750 | { |
1751 | struct net_device *dev = pci_get_drvdata(pdev) ; | 1751 | struct net_device *dev = pci_get_drvdata(pdev) ; |
1752 | struct olympic_private *olympic_priv=(struct olympic_private *)dev->priv; | 1752 | struct olympic_private *olympic_priv=netdev_priv(dev); |
1753 | 1753 | ||
1754 | if (olympic_priv->olympic_network_monitor) { | 1754 | if (olympic_priv->olympic_network_monitor) { |
1755 | char proc_name[20] ; | 1755 | char proc_name[20] ; |