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/lanstreamer.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/lanstreamer.c')
-rw-r--r-- | drivers/net/tokenring/lanstreamer.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c index fc4495581f96..49c4270ef5f7 100644 --- a/drivers/net/tokenring/lanstreamer.c +++ b/drivers/net/tokenring/lanstreamer.c | |||
@@ -246,7 +246,7 @@ static int __devinit streamer_init_one(struct pci_dev *pdev, | |||
246 | } | 246 | } |
247 | 247 | ||
248 | SET_MODULE_OWNER(dev); | 248 | SET_MODULE_OWNER(dev); |
249 | streamer_priv = dev->priv; | 249 | streamer_priv = netdev_priv(dev); |
250 | 250 | ||
251 | #if STREAMER_NETWORK_MONITOR | 251 | #if STREAMER_NETWORK_MONITOR |
252 | #ifdef CONFIG_PROC_FS | 252 | #ifdef CONFIG_PROC_FS |
@@ -405,7 +405,7 @@ static void __devexit streamer_remove_one(struct pci_dev *pdev) | |||
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | 407 | ||
408 | streamer_priv=dev->priv; | 408 | streamer_priv=netdev_priv(dev); |
409 | if (streamer_priv == NULL) { | 409 | if (streamer_priv == NULL) { |
410 | printk(KERN_ERR "lanstreamer::streamer_remove_one, ERROR dev->priv is NULL\n"); | 410 | printk(KERN_ERR "lanstreamer::streamer_remove_one, ERROR dev->priv is NULL\n"); |
411 | return; | 411 | return; |
@@ -449,7 +449,7 @@ static int streamer_reset(struct net_device *dev) | |||
449 | struct sk_buff *skb = NULL; | 449 | struct sk_buff *skb = NULL; |
450 | __u16 misr; | 450 | __u16 misr; |
451 | 451 | ||
452 | streamer_priv = (struct streamer_private *) dev->priv; | 452 | streamer_priv = netdev_priv(dev); |
453 | streamer_mmio = streamer_priv->streamer_mmio; | 453 | streamer_mmio = streamer_priv->streamer_mmio; |
454 | 454 | ||
455 | writew(readw(streamer_mmio + BCTL) | BCTL_SOFTRESET, streamer_mmio + BCTL); | 455 | writew(readw(streamer_mmio + BCTL) | BCTL_SOFTRESET, streamer_mmio + BCTL); |
@@ -588,7 +588,7 @@ static int streamer_reset(struct net_device *dev) | |||
588 | 588 | ||
589 | static int streamer_open(struct net_device *dev) | 589 | static int streamer_open(struct net_device *dev) |
590 | { | 590 | { |
591 | struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv; | 591 | struct streamer_private *streamer_priv = netdev_priv(dev); |
592 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 592 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
593 | unsigned long flags; | 593 | unsigned long flags; |
594 | char open_error[255]; | 594 | char open_error[255]; |
@@ -905,7 +905,7 @@ static int streamer_open(struct net_device *dev) | |||
905 | static void streamer_rx(struct net_device *dev) | 905 | static void streamer_rx(struct net_device *dev) |
906 | { | 906 | { |
907 | struct streamer_private *streamer_priv = | 907 | struct streamer_private *streamer_priv = |
908 | (struct streamer_private *) dev->priv; | 908 | netdev_priv(dev); |
909 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 909 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
910 | struct streamer_rx_desc *rx_desc; | 910 | struct streamer_rx_desc *rx_desc; |
911 | int rx_ring_last_received, length, frame_length, buffer_cnt = 0; | 911 | int rx_ring_last_received, length, frame_length, buffer_cnt = 0; |
@@ -1030,7 +1030,7 @@ static irqreturn_t streamer_interrupt(int irq, void *dev_id) | |||
1030 | { | 1030 | { |
1031 | struct net_device *dev = (struct net_device *) dev_id; | 1031 | struct net_device *dev = (struct net_device *) dev_id; |
1032 | struct streamer_private *streamer_priv = | 1032 | struct streamer_private *streamer_priv = |
1033 | (struct streamer_private *) dev->priv; | 1033 | netdev_priv(dev); |
1034 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1034 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1035 | __u16 sisr; | 1035 | __u16 sisr; |
1036 | __u16 misr; | 1036 | __u16 misr; |
@@ -1153,7 +1153,7 @@ static irqreturn_t streamer_interrupt(int irq, void *dev_id) | |||
1153 | static int streamer_xmit(struct sk_buff *skb, struct net_device *dev) | 1153 | static int streamer_xmit(struct sk_buff *skb, struct net_device *dev) |
1154 | { | 1154 | { |
1155 | struct streamer_private *streamer_priv = | 1155 | struct streamer_private *streamer_priv = |
1156 | (struct streamer_private *) dev->priv; | 1156 | netdev_priv(dev); |
1157 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1157 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1158 | unsigned long flags ; | 1158 | unsigned long flags ; |
1159 | 1159 | ||
@@ -1204,7 +1204,7 @@ static int streamer_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1204 | static int streamer_close(struct net_device *dev) | 1204 | static int streamer_close(struct net_device *dev) |
1205 | { | 1205 | { |
1206 | struct streamer_private *streamer_priv = | 1206 | struct streamer_private *streamer_priv = |
1207 | (struct streamer_private *) dev->priv; | 1207 | netdev_priv(dev); |
1208 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1208 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1209 | unsigned long flags; | 1209 | unsigned long flags; |
1210 | int i; | 1210 | int i; |
@@ -1270,7 +1270,7 @@ static int streamer_close(struct net_device *dev) | |||
1270 | static void streamer_set_rx_mode(struct net_device *dev) | 1270 | static void streamer_set_rx_mode(struct net_device *dev) |
1271 | { | 1271 | { |
1272 | struct streamer_private *streamer_priv = | 1272 | struct streamer_private *streamer_priv = |
1273 | (struct streamer_private *) dev->priv; | 1273 | netdev_priv(dev); |
1274 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1274 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1275 | __u8 options = 0; | 1275 | __u8 options = 0; |
1276 | struct dev_mc_list *dmi; | 1276 | struct dev_mc_list *dmi; |
@@ -1329,7 +1329,7 @@ static void streamer_set_rx_mode(struct net_device *dev) | |||
1329 | 1329 | ||
1330 | static void streamer_srb_bh(struct net_device *dev) | 1330 | static void streamer_srb_bh(struct net_device *dev) |
1331 | { | 1331 | { |
1332 | struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv; | 1332 | struct streamer_private *streamer_priv = netdev_priv(dev); |
1333 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1333 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1334 | __u16 srb_word; | 1334 | __u16 srb_word; |
1335 | 1335 | ||
@@ -1494,14 +1494,14 @@ static void streamer_srb_bh(struct net_device *dev) | |||
1494 | static struct net_device_stats *streamer_get_stats(struct net_device *dev) | 1494 | static struct net_device_stats *streamer_get_stats(struct net_device *dev) |
1495 | { | 1495 | { |
1496 | struct streamer_private *streamer_priv; | 1496 | struct streamer_private *streamer_priv; |
1497 | streamer_priv = (struct streamer_private *) dev->priv; | 1497 | streamer_priv = netdev_priv(dev); |
1498 | return (struct net_device_stats *) &streamer_priv->streamer_stats; | 1498 | return (struct net_device_stats *) &streamer_priv->streamer_stats; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | static int streamer_set_mac_address(struct net_device *dev, void *addr) | 1501 | static int streamer_set_mac_address(struct net_device *dev, void *addr) |
1502 | { | 1502 | { |
1503 | struct sockaddr *saddr = addr; | 1503 | struct sockaddr *saddr = addr; |
1504 | struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv; | 1504 | struct streamer_private *streamer_priv = netdev_priv(dev); |
1505 | 1505 | ||
1506 | if (netif_running(dev)) | 1506 | if (netif_running(dev)) |
1507 | { | 1507 | { |
@@ -1526,7 +1526,7 @@ static int streamer_set_mac_address(struct net_device *dev, void *addr) | |||
1526 | static void streamer_arb_cmd(struct net_device *dev) | 1526 | static void streamer_arb_cmd(struct net_device *dev) |
1527 | { | 1527 | { |
1528 | struct streamer_private *streamer_priv = | 1528 | struct streamer_private *streamer_priv = |
1529 | (struct streamer_private *) dev->priv; | 1529 | netdev_priv(dev); |
1530 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1530 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1531 | __u8 header_len; | 1531 | __u8 header_len; |
1532 | __u16 frame_len, buffer_len; | 1532 | __u16 frame_len, buffer_len; |
@@ -1741,7 +1741,7 @@ drop_frame: | |||
1741 | static void streamer_asb_bh(struct net_device *dev) | 1741 | static void streamer_asb_bh(struct net_device *dev) |
1742 | { | 1742 | { |
1743 | struct streamer_private *streamer_priv = | 1743 | struct streamer_private *streamer_priv = |
1744 | (struct streamer_private *) dev->priv; | 1744 | netdev_priv(dev); |
1745 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1745 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1746 | 1746 | ||
1747 | if (streamer_priv->asb_queued == 1) | 1747 | if (streamer_priv->asb_queued == 1) |
@@ -1785,7 +1785,7 @@ static void streamer_asb_bh(struct net_device *dev) | |||
1785 | static int streamer_change_mtu(struct net_device *dev, int mtu) | 1785 | static int streamer_change_mtu(struct net_device *dev, int mtu) |
1786 | { | 1786 | { |
1787 | struct streamer_private *streamer_priv = | 1787 | struct streamer_private *streamer_priv = |
1788 | (struct streamer_private *) dev->priv; | 1788 | netdev_priv(dev); |
1789 | __u16 max_mtu; | 1789 | __u16 max_mtu; |
1790 | 1790 | ||
1791 | if (streamer_priv->streamer_ring_speed == 4) | 1791 | if (streamer_priv->streamer_ring_speed == 4) |
@@ -1849,7 +1849,7 @@ static int streamer_proc_info(char *buffer, char **start, off_t offset, | |||
1849 | static int sprintf_info(char *buffer, struct net_device *dev) | 1849 | static int sprintf_info(char *buffer, struct net_device *dev) |
1850 | { | 1850 | { |
1851 | struct streamer_private *streamer_priv = | 1851 | struct streamer_private *streamer_priv = |
1852 | (struct streamer_private *) dev->priv; | 1852 | netdev_priv(dev); |
1853 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; | 1853 | __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; |
1854 | struct streamer_adapter_addr_table sat; | 1854 | struct streamer_adapter_addr_table sat; |
1855 | struct streamer_parameters_table spt; | 1855 | struct streamer_parameters_table spt; |