diff options
author | Wang Chen <wangchen@cn.fujitsu.com> | 2008-11-13 02:37:49 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-13 02:37:49 -0500 |
commit | 454d7c9b14e20fd1949e2686e9de4a2926e01476 (patch) | |
tree | fae8bd1bfb5fd496977a0639ad71c54a2ee278ae /drivers/net/3c505.c | |
parent | 7a12122c7a00347da9669cfcde82954c9e3d6f5e (diff) |
netdevice: safe convert to netdev_priv() #part-1
We have some reasons to kill netdev->priv:
1. netdev->priv is equal to netdev_priv().
2. netdev_priv() wraps the calculation of netdev->priv's offset, obviously
netdev_priv() is more flexible than netdev->priv.
But we cann't kill netdev->priv, because so many drivers reference to it
directly.
This patch is a safe convert for netdev->priv to netdev_priv(netdev).
Since all of the netdev->priv is only for read.
But it is too big to be sent in one mail.
I split it to 4 parts and make every part smaller than 100,000 bytes,
which is max size allowed by vger.
Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/3c505.c')
-rw-r--r-- | drivers/net/3c505.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c index e669da76ed09..6124605bef05 100644 --- a/drivers/net/3c505.c +++ b/drivers/net/3c505.c | |||
@@ -203,10 +203,10 @@ static inline int inb_command(unsigned int base_addr) | |||
203 | static inline void outb_control(unsigned char val, struct net_device *dev) | 203 | static inline void outb_control(unsigned char val, struct net_device *dev) |
204 | { | 204 | { |
205 | outb(val, dev->base_addr + PORT_CONTROL); | 205 | outb(val, dev->base_addr + PORT_CONTROL); |
206 | ((elp_device *)(dev->priv))->hcr_val = val; | 206 | ((elp_device *)(netdev_priv(dev)))->hcr_val = val; |
207 | } | 207 | } |
208 | 208 | ||
209 | #define HCR_VAL(x) (((elp_device *)((x)->priv))->hcr_val) | 209 | #define HCR_VAL(x) (((elp_device *)(netdev_priv(x)))->hcr_val) |
210 | 210 | ||
211 | static inline void outb_command(unsigned char val, unsigned int base_addr) | 211 | static inline void outb_command(unsigned char val, unsigned int base_addr) |
212 | { | 212 | { |
@@ -247,7 +247,7 @@ static inline int get_status(unsigned int base_addr) | |||
247 | 247 | ||
248 | static inline void set_hsf(struct net_device *dev, int hsf) | 248 | static inline void set_hsf(struct net_device *dev, int hsf) |
249 | { | 249 | { |
250 | elp_device *adapter = dev->priv; | 250 | elp_device *adapter = netdev_priv(dev); |
251 | unsigned long flags; | 251 | unsigned long flags; |
252 | 252 | ||
253 | spin_lock_irqsave(&adapter->lock, flags); | 253 | spin_lock_irqsave(&adapter->lock, flags); |
@@ -260,7 +260,7 @@ static bool start_receive(struct net_device *, pcb_struct *); | |||
260 | static inline void adapter_reset(struct net_device *dev) | 260 | static inline void adapter_reset(struct net_device *dev) |
261 | { | 261 | { |
262 | unsigned long timeout; | 262 | unsigned long timeout; |
263 | elp_device *adapter = dev->priv; | 263 | elp_device *adapter = netdev_priv(dev); |
264 | unsigned char orig_hcr = adapter->hcr_val; | 264 | unsigned char orig_hcr = adapter->hcr_val; |
265 | 265 | ||
266 | outb_control(0, dev); | 266 | outb_control(0, dev); |
@@ -293,7 +293,7 @@ static inline void adapter_reset(struct net_device *dev) | |||
293 | */ | 293 | */ |
294 | static inline void check_3c505_dma(struct net_device *dev) | 294 | static inline void check_3c505_dma(struct net_device *dev) |
295 | { | 295 | { |
296 | elp_device *adapter = dev->priv; | 296 | elp_device *adapter = netdev_priv(dev); |
297 | if (adapter->dmaing && time_after(jiffies, adapter->current_dma.start_time + 10)) { | 297 | if (adapter->dmaing && time_after(jiffies, adapter->current_dma.start_time + 10)) { |
298 | unsigned long flags, f; | 298 | unsigned long flags, f; |
299 | printk(KERN_ERR "%s: DMA %s timed out, %d bytes left\n", dev->name, adapter->current_dma.direction ? "download" : "upload", get_dma_residue(dev->dma)); | 299 | printk(KERN_ERR "%s: DMA %s timed out, %d bytes left\n", dev->name, adapter->current_dma.direction ? "download" : "upload", get_dma_residue(dev->dma)); |
@@ -340,7 +340,7 @@ static inline bool send_pcb_fast(unsigned int base_addr, unsigned char byte) | |||
340 | /* Check to see if the receiver needs restarting, and kick it if so */ | 340 | /* Check to see if the receiver needs restarting, and kick it if so */ |
341 | static inline void prime_rx(struct net_device *dev) | 341 | static inline void prime_rx(struct net_device *dev) |
342 | { | 342 | { |
343 | elp_device *adapter = dev->priv; | 343 | elp_device *adapter = netdev_priv(dev); |
344 | while (adapter->rx_active < ELP_RX_PCBS && netif_running(dev)) { | 344 | while (adapter->rx_active < ELP_RX_PCBS && netif_running(dev)) { |
345 | if (!start_receive(dev, &adapter->itx_pcb)) | 345 | if (!start_receive(dev, &adapter->itx_pcb)) |
346 | break; | 346 | break; |
@@ -375,7 +375,7 @@ static bool send_pcb(struct net_device *dev, pcb_struct * pcb) | |||
375 | { | 375 | { |
376 | int i; | 376 | int i; |
377 | unsigned long timeout; | 377 | unsigned long timeout; |
378 | elp_device *adapter = dev->priv; | 378 | elp_device *adapter = netdev_priv(dev); |
379 | unsigned long flags; | 379 | unsigned long flags; |
380 | 380 | ||
381 | check_3c505_dma(dev); | 381 | check_3c505_dma(dev); |
@@ -463,7 +463,7 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb) | |||
463 | unsigned long timeout; | 463 | unsigned long timeout; |
464 | unsigned long flags; | 464 | unsigned long flags; |
465 | 465 | ||
466 | elp_device *adapter = dev->priv; | 466 | elp_device *adapter = netdev_priv(dev); |
467 | 467 | ||
468 | set_hsf(dev, 0); | 468 | set_hsf(dev, 0); |
469 | 469 | ||
@@ -543,7 +543,7 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb) | |||
543 | static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb) | 543 | static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb) |
544 | { | 544 | { |
545 | bool status; | 545 | bool status; |
546 | elp_device *adapter = dev->priv; | 546 | elp_device *adapter = netdev_priv(dev); |
547 | 547 | ||
548 | if (elp_debug >= 3) | 548 | if (elp_debug >= 3) |
549 | printk(KERN_DEBUG "%s: restarting receiver\n", dev->name); | 549 | printk(KERN_DEBUG "%s: restarting receiver\n", dev->name); |
@@ -571,7 +571,7 @@ static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb) | |||
571 | static void receive_packet(struct net_device *dev, int len) | 571 | static void receive_packet(struct net_device *dev, int len) |
572 | { | 572 | { |
573 | int rlen; | 573 | int rlen; |
574 | elp_device *adapter = dev->priv; | 574 | elp_device *adapter = netdev_priv(dev); |
575 | void *target; | 575 | void *target; |
576 | struct sk_buff *skb; | 576 | struct sk_buff *skb; |
577 | unsigned long flags; | 577 | unsigned long flags; |
@@ -638,13 +638,10 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id) | |||
638 | int len; | 638 | int len; |
639 | int dlen; | 639 | int dlen; |
640 | int icount = 0; | 640 | int icount = 0; |
641 | struct net_device *dev; | 641 | struct net_device *dev = dev_id; |
642 | elp_device *adapter; | 642 | elp_device *adapter = netdev_priv(dev); |
643 | unsigned long timeout; | 643 | unsigned long timeout; |
644 | 644 | ||
645 | dev = dev_id; | ||
646 | adapter = (elp_device *) dev->priv; | ||
647 | |||
648 | spin_lock(&adapter->lock); | 645 | spin_lock(&adapter->lock); |
649 | 646 | ||
650 | do { | 647 | do { |
@@ -837,11 +834,9 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id) | |||
837 | 834 | ||
838 | static int elp_open(struct net_device *dev) | 835 | static int elp_open(struct net_device *dev) |
839 | { | 836 | { |
840 | elp_device *adapter; | 837 | elp_device *adapter = netdev_priv(dev); |
841 | int retval; | 838 | int retval; |
842 | 839 | ||
843 | adapter = dev->priv; | ||
844 | |||
845 | if (elp_debug >= 3) | 840 | if (elp_debug >= 3) |
846 | printk(KERN_DEBUG "%s: request to open device\n", dev->name); | 841 | printk(KERN_DEBUG "%s: request to open device\n", dev->name); |
847 | 842 | ||
@@ -970,7 +965,7 @@ static int elp_open(struct net_device *dev) | |||
970 | 965 | ||
971 | static bool send_packet(struct net_device *dev, struct sk_buff *skb) | 966 | static bool send_packet(struct net_device *dev, struct sk_buff *skb) |
972 | { | 967 | { |
973 | elp_device *adapter = dev->priv; | 968 | elp_device *adapter = netdev_priv(dev); |
974 | unsigned long target; | 969 | unsigned long target; |
975 | unsigned long flags; | 970 | unsigned long flags; |
976 | 971 | ||
@@ -1061,7 +1056,7 @@ static void elp_timeout(struct net_device *dev) | |||
1061 | static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev) | 1056 | static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev) |
1062 | { | 1057 | { |
1063 | unsigned long flags; | 1058 | unsigned long flags; |
1064 | elp_device *adapter = dev->priv; | 1059 | elp_device *adapter = netdev_priv(dev); |
1065 | 1060 | ||
1066 | spin_lock_irqsave(&adapter->lock, flags); | 1061 | spin_lock_irqsave(&adapter->lock, flags); |
1067 | check_3c505_dma(dev); | 1062 | check_3c505_dma(dev); |
@@ -1103,7 +1098,7 @@ static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1103 | 1098 | ||
1104 | static struct net_device_stats *elp_get_stats(struct net_device *dev) | 1099 | static struct net_device_stats *elp_get_stats(struct net_device *dev) |
1105 | { | 1100 | { |
1106 | elp_device *adapter = (elp_device *) dev->priv; | 1101 | elp_device *adapter = netdev_priv(dev); |
1107 | 1102 | ||
1108 | if (elp_debug >= 3) | 1103 | if (elp_debug >= 3) |
1109 | printk(KERN_DEBUG "%s: request for stats\n", dev->name); | 1104 | printk(KERN_DEBUG "%s: request for stats\n", dev->name); |
@@ -1165,9 +1160,7 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
1165 | 1160 | ||
1166 | static int elp_close(struct net_device *dev) | 1161 | static int elp_close(struct net_device *dev) |
1167 | { | 1162 | { |
1168 | elp_device *adapter; | 1163 | elp_device *adapter = netdev_priv(dev); |
1169 | |||
1170 | adapter = dev->priv; | ||
1171 | 1164 | ||
1172 | if (elp_debug >= 3) | 1165 | if (elp_debug >= 3) |
1173 | printk(KERN_DEBUG "%s: request to close device\n", dev->name); | 1166 | printk(KERN_DEBUG "%s: request to close device\n", dev->name); |
@@ -1208,7 +1201,7 @@ static int elp_close(struct net_device *dev) | |||
1208 | 1201 | ||
1209 | static void elp_set_mc_list(struct net_device *dev) | 1202 | static void elp_set_mc_list(struct net_device *dev) |
1210 | { | 1203 | { |
1211 | elp_device *adapter = (elp_device *) dev->priv; | 1204 | elp_device *adapter = netdev_priv(dev); |
1212 | struct dev_mc_list *dmi = dev->mc_list; | 1205 | struct dev_mc_list *dmi = dev->mc_list; |
1213 | int i; | 1206 | int i; |
1214 | unsigned long flags; | 1207 | unsigned long flags; |
@@ -1379,7 +1372,7 @@ static int __init elp_autodetect(struct net_device *dev) | |||
1379 | 1372 | ||
1380 | static int __init elplus_setup(struct net_device *dev) | 1373 | static int __init elplus_setup(struct net_device *dev) |
1381 | { | 1374 | { |
1382 | elp_device *adapter = dev->priv; | 1375 | elp_device *adapter = netdev_priv(dev); |
1383 | int i, tries, tries1, okay; | 1376 | int i, tries, tries1, okay; |
1384 | unsigned long timeout; | 1377 | unsigned long timeout; |
1385 | unsigned long cookie = 0; | 1378 | unsigned long cookie = 0; |