diff options
Diffstat (limited to 'drivers/net/ethernet/natsemi')
-rw-r--r-- | drivers/net/ethernet/natsemi/natsemi.c | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c index d38e48d4f430..5b61d12f8b91 100644 --- a/drivers/net/ethernet/natsemi/natsemi.c +++ b/drivers/net/ethernet/natsemi/natsemi.c | |||
@@ -547,6 +547,7 @@ struct netdev_private { | |||
547 | struct sk_buff *tx_skbuff[TX_RING_SIZE]; | 547 | struct sk_buff *tx_skbuff[TX_RING_SIZE]; |
548 | dma_addr_t tx_dma[TX_RING_SIZE]; | 548 | dma_addr_t tx_dma[TX_RING_SIZE]; |
549 | struct net_device *dev; | 549 | struct net_device *dev; |
550 | void __iomem *ioaddr; | ||
550 | struct napi_struct napi; | 551 | struct napi_struct napi; |
551 | /* Media monitoring timer */ | 552 | /* Media monitoring timer */ |
552 | struct timer_list timer; | 553 | struct timer_list timer; |
@@ -699,7 +700,9 @@ static ssize_t natsemi_set_dspcfg_workaround(struct device *dev, | |||
699 | 700 | ||
700 | static inline void __iomem *ns_ioaddr(struct net_device *dev) | 701 | static inline void __iomem *ns_ioaddr(struct net_device *dev) |
701 | { | 702 | { |
702 | return (void __iomem *) dev->base_addr; | 703 | struct netdev_private *np = netdev_priv(dev); |
704 | |||
705 | return np->ioaddr; | ||
703 | } | 706 | } |
704 | 707 | ||
705 | static inline void natsemi_irq_enable(struct net_device *dev) | 708 | static inline void natsemi_irq_enable(struct net_device *dev) |
@@ -863,10 +866,9 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev, | |||
863 | /* Store MAC Address in perm_addr */ | 866 | /* Store MAC Address in perm_addr */ |
864 | memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN); | 867 | memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN); |
865 | 868 | ||
866 | dev->base_addr = (unsigned long __force) ioaddr; | ||
867 | dev->irq = irq; | ||
868 | |||
869 | np = netdev_priv(dev); | 869 | np = netdev_priv(dev); |
870 | np->ioaddr = ioaddr; | ||
871 | |||
870 | netif_napi_add(dev, &np->napi, natsemi_poll, 64); | 872 | netif_napi_add(dev, &np->napi, natsemi_poll, 64); |
871 | np->dev = dev; | 873 | np->dev = dev; |
872 | 874 | ||
@@ -914,9 +916,6 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev, | |||
914 | } | 916 | } |
915 | 917 | ||
916 | option = find_cnt < MAX_UNITS ? options[find_cnt] : 0; | 918 | option = find_cnt < MAX_UNITS ? options[find_cnt] : 0; |
917 | if (dev->mem_start) | ||
918 | option = dev->mem_start; | ||
919 | |||
920 | /* The lower four bits are the media type. */ | 919 | /* The lower four bits are the media type. */ |
921 | if (option) { | 920 | if (option) { |
922 | if (option & 0x200) | 921 | if (option & 0x200) |
@@ -1532,20 +1531,21 @@ static int netdev_open(struct net_device *dev) | |||
1532 | { | 1531 | { |
1533 | struct netdev_private *np = netdev_priv(dev); | 1532 | struct netdev_private *np = netdev_priv(dev); |
1534 | void __iomem * ioaddr = ns_ioaddr(dev); | 1533 | void __iomem * ioaddr = ns_ioaddr(dev); |
1534 | const int irq = np->pci_dev->irq; | ||
1535 | int i; | 1535 | int i; |
1536 | 1536 | ||
1537 | /* Reset the chip, just in case. */ | 1537 | /* Reset the chip, just in case. */ |
1538 | natsemi_reset(dev); | 1538 | natsemi_reset(dev); |
1539 | 1539 | ||
1540 | i = request_irq(dev->irq, intr_handler, IRQF_SHARED, dev->name, dev); | 1540 | i = request_irq(irq, intr_handler, IRQF_SHARED, dev->name, dev); |
1541 | if (i) return i; | 1541 | if (i) return i; |
1542 | 1542 | ||
1543 | if (netif_msg_ifup(np)) | 1543 | if (netif_msg_ifup(np)) |
1544 | printk(KERN_DEBUG "%s: netdev_open() irq %d.\n", | 1544 | printk(KERN_DEBUG "%s: netdev_open() irq %d.\n", |
1545 | dev->name, dev->irq); | 1545 | dev->name, irq); |
1546 | i = alloc_ring(dev); | 1546 | i = alloc_ring(dev); |
1547 | if (i < 0) { | 1547 | if (i < 0) { |
1548 | free_irq(dev->irq, dev); | 1548 | free_irq(irq, dev); |
1549 | return i; | 1549 | return i; |
1550 | } | 1550 | } |
1551 | napi_enable(&np->napi); | 1551 | napi_enable(&np->napi); |
@@ -1794,6 +1794,7 @@ static void netdev_timer(unsigned long data) | |||
1794 | struct netdev_private *np = netdev_priv(dev); | 1794 | struct netdev_private *np = netdev_priv(dev); |
1795 | void __iomem * ioaddr = ns_ioaddr(dev); | 1795 | void __iomem * ioaddr = ns_ioaddr(dev); |
1796 | int next_tick = NATSEMI_TIMER_FREQ; | 1796 | int next_tick = NATSEMI_TIMER_FREQ; |
1797 | const int irq = np->pci_dev->irq; | ||
1797 | 1798 | ||
1798 | if (netif_msg_timer(np)) { | 1799 | if (netif_msg_timer(np)) { |
1799 | /* DO NOT read the IntrStatus register, | 1800 | /* DO NOT read the IntrStatus register, |
@@ -1817,14 +1818,14 @@ static void netdev_timer(unsigned long data) | |||
1817 | if (netif_msg_drv(np)) | 1818 | if (netif_msg_drv(np)) |
1818 | printk(KERN_NOTICE "%s: possible phy reset: " | 1819 | printk(KERN_NOTICE "%s: possible phy reset: " |
1819 | "re-initializing\n", dev->name); | 1820 | "re-initializing\n", dev->name); |
1820 | disable_irq(dev->irq); | 1821 | disable_irq(irq); |
1821 | spin_lock_irq(&np->lock); | 1822 | spin_lock_irq(&np->lock); |
1822 | natsemi_stop_rxtx(dev); | 1823 | natsemi_stop_rxtx(dev); |
1823 | dump_ring(dev); | 1824 | dump_ring(dev); |
1824 | reinit_ring(dev); | 1825 | reinit_ring(dev); |
1825 | init_registers(dev); | 1826 | init_registers(dev); |
1826 | spin_unlock_irq(&np->lock); | 1827 | spin_unlock_irq(&np->lock); |
1827 | enable_irq(dev->irq); | 1828 | enable_irq(irq); |
1828 | } else { | 1829 | } else { |
1829 | /* hurry back */ | 1830 | /* hurry back */ |
1830 | next_tick = HZ; | 1831 | next_tick = HZ; |
@@ -1841,10 +1842,10 @@ static void netdev_timer(unsigned long data) | |||
1841 | spin_unlock_irq(&np->lock); | 1842 | spin_unlock_irq(&np->lock); |
1842 | } | 1843 | } |
1843 | if (np->oom) { | 1844 | if (np->oom) { |
1844 | disable_irq(dev->irq); | 1845 | disable_irq(irq); |
1845 | np->oom = 0; | 1846 | np->oom = 0; |
1846 | refill_rx(dev); | 1847 | refill_rx(dev); |
1847 | enable_irq(dev->irq); | 1848 | enable_irq(irq); |
1848 | if (!np->oom) { | 1849 | if (!np->oom) { |
1849 | writel(RxOn, ioaddr + ChipCmd); | 1850 | writel(RxOn, ioaddr + ChipCmd); |
1850 | } else { | 1851 | } else { |
@@ -1885,8 +1886,9 @@ static void ns_tx_timeout(struct net_device *dev) | |||
1885 | { | 1886 | { |
1886 | struct netdev_private *np = netdev_priv(dev); | 1887 | struct netdev_private *np = netdev_priv(dev); |
1887 | void __iomem * ioaddr = ns_ioaddr(dev); | 1888 | void __iomem * ioaddr = ns_ioaddr(dev); |
1889 | const int irq = np->pci_dev->irq; | ||
1888 | 1890 | ||
1889 | disable_irq(dev->irq); | 1891 | disable_irq(irq); |
1890 | spin_lock_irq(&np->lock); | 1892 | spin_lock_irq(&np->lock); |
1891 | if (!np->hands_off) { | 1893 | if (!np->hands_off) { |
1892 | if (netif_msg_tx_err(np)) | 1894 | if (netif_msg_tx_err(np)) |
@@ -1905,7 +1907,7 @@ static void ns_tx_timeout(struct net_device *dev) | |||
1905 | dev->name); | 1907 | dev->name); |
1906 | } | 1908 | } |
1907 | spin_unlock_irq(&np->lock); | 1909 | spin_unlock_irq(&np->lock); |
1908 | enable_irq(dev->irq); | 1910 | enable_irq(irq); |
1909 | 1911 | ||
1910 | dev->trans_start = jiffies; /* prevent tx timeout */ | 1912 | dev->trans_start = jiffies; /* prevent tx timeout */ |
1911 | dev->stats.tx_errors++; | 1913 | dev->stats.tx_errors++; |
@@ -2470,9 +2472,12 @@ static struct net_device_stats *get_stats(struct net_device *dev) | |||
2470 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2472 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2471 | static void natsemi_poll_controller(struct net_device *dev) | 2473 | static void natsemi_poll_controller(struct net_device *dev) |
2472 | { | 2474 | { |
2473 | disable_irq(dev->irq); | 2475 | struct netdev_private *np = netdev_priv(dev); |
2474 | intr_handler(dev->irq, dev); | 2476 | const int irq = np->pci_dev->irq; |
2475 | enable_irq(dev->irq); | 2477 | |
2478 | disable_irq(irq); | ||
2479 | intr_handler(irq, dev); | ||
2480 | enable_irq(irq); | ||
2476 | } | 2481 | } |
2477 | #endif | 2482 | #endif |
2478 | 2483 | ||
@@ -2523,8 +2528,9 @@ static int natsemi_change_mtu(struct net_device *dev, int new_mtu) | |||
2523 | if (netif_running(dev)) { | 2528 | if (netif_running(dev)) { |
2524 | struct netdev_private *np = netdev_priv(dev); | 2529 | struct netdev_private *np = netdev_priv(dev); |
2525 | void __iomem * ioaddr = ns_ioaddr(dev); | 2530 | void __iomem * ioaddr = ns_ioaddr(dev); |
2531 | const int irq = np->pci_dev->irq; | ||
2526 | 2532 | ||
2527 | disable_irq(dev->irq); | 2533 | disable_irq(irq); |
2528 | spin_lock(&np->lock); | 2534 | spin_lock(&np->lock); |
2529 | /* stop engines */ | 2535 | /* stop engines */ |
2530 | natsemi_stop_rxtx(dev); | 2536 | natsemi_stop_rxtx(dev); |
@@ -2537,7 +2543,7 @@ static int natsemi_change_mtu(struct net_device *dev, int new_mtu) | |||
2537 | /* restart engines */ | 2543 | /* restart engines */ |
2538 | writel(RxOn | TxOn, ioaddr + ChipCmd); | 2544 | writel(RxOn | TxOn, ioaddr + ChipCmd); |
2539 | spin_unlock(&np->lock); | 2545 | spin_unlock(&np->lock); |
2540 | enable_irq(dev->irq); | 2546 | enable_irq(irq); |
2541 | } | 2547 | } |
2542 | return 0; | 2548 | return 0; |
2543 | } | 2549 | } |
@@ -3135,6 +3141,7 @@ static int netdev_close(struct net_device *dev) | |||
3135 | { | 3141 | { |
3136 | void __iomem * ioaddr = ns_ioaddr(dev); | 3142 | void __iomem * ioaddr = ns_ioaddr(dev); |
3137 | struct netdev_private *np = netdev_priv(dev); | 3143 | struct netdev_private *np = netdev_priv(dev); |
3144 | const int irq = np->pci_dev->irq; | ||
3138 | 3145 | ||
3139 | if (netif_msg_ifdown(np)) | 3146 | if (netif_msg_ifdown(np)) |
3140 | printk(KERN_DEBUG | 3147 | printk(KERN_DEBUG |
@@ -3156,14 +3163,14 @@ static int netdev_close(struct net_device *dev) | |||
3156 | */ | 3163 | */ |
3157 | 3164 | ||
3158 | del_timer_sync(&np->timer); | 3165 | del_timer_sync(&np->timer); |
3159 | disable_irq(dev->irq); | 3166 | disable_irq(irq); |
3160 | spin_lock_irq(&np->lock); | 3167 | spin_lock_irq(&np->lock); |
3161 | natsemi_irq_disable(dev); | 3168 | natsemi_irq_disable(dev); |
3162 | np->hands_off = 1; | 3169 | np->hands_off = 1; |
3163 | spin_unlock_irq(&np->lock); | 3170 | spin_unlock_irq(&np->lock); |
3164 | enable_irq(dev->irq); | 3171 | enable_irq(irq); |
3165 | 3172 | ||
3166 | free_irq(dev->irq, dev); | 3173 | free_irq(irq, dev); |
3167 | 3174 | ||
3168 | /* Interrupt disabled, interrupt handler released, | 3175 | /* Interrupt disabled, interrupt handler released, |
3169 | * queue stopped, timer deleted, rtnl_lock held | 3176 | * queue stopped, timer deleted, rtnl_lock held |
@@ -3256,9 +3263,11 @@ static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state) | |||
3256 | 3263 | ||
3257 | rtnl_lock(); | 3264 | rtnl_lock(); |
3258 | if (netif_running (dev)) { | 3265 | if (netif_running (dev)) { |
3266 | const int irq = np->pci_dev->irq; | ||
3267 | |||
3259 | del_timer_sync(&np->timer); | 3268 | del_timer_sync(&np->timer); |
3260 | 3269 | ||
3261 | disable_irq(dev->irq); | 3270 | disable_irq(irq); |
3262 | spin_lock_irq(&np->lock); | 3271 | spin_lock_irq(&np->lock); |
3263 | 3272 | ||
3264 | natsemi_irq_disable(dev); | 3273 | natsemi_irq_disable(dev); |
@@ -3267,7 +3276,7 @@ static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state) | |||
3267 | netif_stop_queue(dev); | 3276 | netif_stop_queue(dev); |
3268 | 3277 | ||
3269 | spin_unlock_irq(&np->lock); | 3278 | spin_unlock_irq(&np->lock); |
3270 | enable_irq(dev->irq); | 3279 | enable_irq(irq); |
3271 | 3280 | ||
3272 | napi_disable(&np->napi); | 3281 | napi_disable(&np->napi); |
3273 | 3282 | ||
@@ -3307,6 +3316,8 @@ static int natsemi_resume (struct pci_dev *pdev) | |||
3307 | if (netif_device_present(dev)) | 3316 | if (netif_device_present(dev)) |
3308 | goto out; | 3317 | goto out; |
3309 | if (netif_running(dev)) { | 3318 | if (netif_running(dev)) { |
3319 | const int irq = np->pci_dev->irq; | ||
3320 | |||
3310 | BUG_ON(!np->hands_off); | 3321 | BUG_ON(!np->hands_off); |
3311 | ret = pci_enable_device(pdev); | 3322 | ret = pci_enable_device(pdev); |
3312 | if (ret < 0) { | 3323 | if (ret < 0) { |
@@ -3320,13 +3331,13 @@ static int natsemi_resume (struct pci_dev *pdev) | |||
3320 | 3331 | ||
3321 | natsemi_reset(dev); | 3332 | natsemi_reset(dev); |
3322 | init_ring(dev); | 3333 | init_ring(dev); |
3323 | disable_irq(dev->irq); | 3334 | disable_irq(irq); |
3324 | spin_lock_irq(&np->lock); | 3335 | spin_lock_irq(&np->lock); |
3325 | np->hands_off = 0; | 3336 | np->hands_off = 0; |
3326 | init_registers(dev); | 3337 | init_registers(dev); |
3327 | netif_device_attach(dev); | 3338 | netif_device_attach(dev); |
3328 | spin_unlock_irq(&np->lock); | 3339 | spin_unlock_irq(&np->lock); |
3329 | enable_irq(dev->irq); | 3340 | enable_irq(irq); |
3330 | 3341 | ||
3331 | mod_timer(&np->timer, round_jiffies(jiffies + 1*HZ)); | 3342 | mod_timer(&np->timer, round_jiffies(jiffies + 1*HZ)); |
3332 | } | 3343 | } |