aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/r6040.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/r6040.c')
-rw-r--r--drivers/net/r6040.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index cf3a082bc89d..b2dcdb5ed8bd 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -49,8 +49,8 @@
49#include <asm/processor.h> 49#include <asm/processor.h>
50 50
51#define DRV_NAME "r6040" 51#define DRV_NAME "r6040"
52#define DRV_VERSION "0.20" 52#define DRV_VERSION "0.21"
53#define DRV_RELDATE "07Jan2009" 53#define DRV_RELDATE "09Jan2009"
54 54
55/* PHY CHIP Address */ 55/* PHY CHIP Address */
56#define PHY1_ADDR 1 /* For MAC1 */ 56#define PHY1_ADDR 1 /* For MAC1 */
@@ -438,7 +438,6 @@ static void r6040_down(struct net_device *dev)
438{ 438{
439 struct r6040_private *lp = netdev_priv(dev); 439 struct r6040_private *lp = netdev_priv(dev);
440 void __iomem *ioaddr = lp->base; 440 void __iomem *ioaddr = lp->base;
441 struct pci_dev *pdev = lp->pdev;
442 int limit = 2048; 441 int limit = 2048;
443 u16 *adrp; 442 u16 *adrp;
444 u16 cmd; 443 u16 cmd;
@@ -457,22 +456,12 @@ static void r6040_down(struct net_device *dev)
457 iowrite16(adrp[0], ioaddr + MID_0L); 456 iowrite16(adrp[0], ioaddr + MID_0L);
458 iowrite16(adrp[1], ioaddr + MID_0M); 457 iowrite16(adrp[1], ioaddr + MID_0M);
459 iowrite16(adrp[2], ioaddr + MID_0H); 458 iowrite16(adrp[2], ioaddr + MID_0H);
460 free_irq(dev->irq, dev);
461
462 /* Free RX buffer */
463 r6040_free_rxbufs(dev);
464
465 /* Free TX buffer */
466 r6040_free_txbufs(dev);
467
468 /* Free Descriptor memory */
469 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
470 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
471} 459}
472 460
473static int r6040_close(struct net_device *dev) 461static int r6040_close(struct net_device *dev)
474{ 462{
475 struct r6040_private *lp = netdev_priv(dev); 463 struct r6040_private *lp = netdev_priv(dev);
464 struct pci_dev *pdev = lp->pdev;
476 465
477 /* deleted timer */ 466 /* deleted timer */
478 del_timer_sync(&lp->timer); 467 del_timer_sync(&lp->timer);
@@ -481,8 +470,28 @@ static int r6040_close(struct net_device *dev)
481 napi_disable(&lp->napi); 470 napi_disable(&lp->napi);
482 netif_stop_queue(dev); 471 netif_stop_queue(dev);
483 r6040_down(dev); 472 r6040_down(dev);
473
474 free_irq(dev->irq, dev);
475
476 /* Free RX buffer */
477 r6040_free_rxbufs(dev);
478
479 /* Free TX buffer */
480 r6040_free_txbufs(dev);
481
484 spin_unlock_irq(&lp->lock); 482 spin_unlock_irq(&lp->lock);
485 483
484 /* Free Descriptor memory */
485 if (lp->rx_ring) {
486 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
487 lp->rx_ring = 0;
488 }
489
490 if (lp->tx_ring) {
491 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
492 lp->tx_ring = 0;
493 }
494
486 return 0; 495 return 0;
487} 496}
488 497
@@ -1049,6 +1058,7 @@ static const struct net_device_ops r6040_netdev_ops = {
1049 .ndo_set_multicast_list = r6040_multicast_list, 1058 .ndo_set_multicast_list = r6040_multicast_list,
1050 .ndo_change_mtu = eth_change_mtu, 1059 .ndo_change_mtu = eth_change_mtu,
1051 .ndo_validate_addr = eth_validate_addr, 1060 .ndo_validate_addr = eth_validate_addr,
1061 .ndo_set_mac_address = eth_mac_addr,
1052 .ndo_do_ioctl = r6040_ioctl, 1062 .ndo_do_ioctl = r6040_ioctl,
1053 .ndo_tx_timeout = r6040_tx_timeout, 1063 .ndo_tx_timeout = r6040_tx_timeout,
1054#ifdef CONFIG_NET_POLL_CONTROLLER 1064#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1143,8 +1153,10 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1143 1153
1144 /* Some bootloader/BIOSes do not initialize 1154 /* Some bootloader/BIOSes do not initialize
1145 * MAC address, warn about that */ 1155 * MAC address, warn about that */
1146 if (!(adrp[0] || adrp[1] || adrp[2])) 1156 if (!(adrp[0] || adrp[1] || adrp[2])) {
1147 printk(KERN_WARNING DRV_NAME ": MAC address not initialized\n"); 1157 printk(KERN_WARNING DRV_NAME ": MAC address not initialized, generating random\n");
1158 random_ether_addr(dev->dev_addr);
1159 }
1148 1160
1149 /* Link new device into r6040_root_dev */ 1161 /* Link new device into r6040_root_dev */
1150 lp->pdev = pdev; 1162 lp->pdev = pdev;