diff options
Diffstat (limited to 'drivers/net/r6040.c')
-rw-r--r-- | drivers/net/r6040.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c index 15d5373dc8f3..3cc7befa3eb1 100644 --- a/drivers/net/r6040.c +++ b/drivers/net/r6040.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/timer.h> | 29 | #include <linux/timer.h> |
30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
31 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
32 | #include <linux/slab.h> | ||
33 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
34 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
35 | #include <linux/netdevice.h> | 34 | #include <linux/netdevice.h> |
@@ -135,7 +134,7 @@ | |||
135 | #define RX_DESC_SIZE (RX_DCNT * sizeof(struct r6040_descriptor)) | 134 | #define RX_DESC_SIZE (RX_DCNT * sizeof(struct r6040_descriptor)) |
136 | #define TX_DESC_SIZE (TX_DCNT * sizeof(struct r6040_descriptor)) | 135 | #define TX_DESC_SIZE (TX_DCNT * sizeof(struct r6040_descriptor)) |
137 | #define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */ | 136 | #define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */ |
138 | #define MCAST_MAX 4 /* Max number multicast addresses to filter */ | 137 | #define MCAST_MAX 3 /* Max number multicast addresses to filter */ |
139 | 138 | ||
140 | /* Descriptor status */ | 139 | /* Descriptor status */ |
141 | #define DSC_OWNER_MAC 0x8000 /* MAC is the owner of this descriptor */ | 140 | #define DSC_OWNER_MAC 0x8000 /* MAC is the owner of this descriptor */ |
@@ -331,7 +330,7 @@ static int r6040_alloc_rxbufs(struct net_device *dev) | |||
331 | do { | 330 | do { |
332 | skb = netdev_alloc_skb(dev, MAX_BUF_SIZE); | 331 | skb = netdev_alloc_skb(dev, MAX_BUF_SIZE); |
333 | if (!skb) { | 332 | if (!skb) { |
334 | printk(KERN_ERR DRV_NAME "%s: failed to alloc skb for rx\n", dev->name); | 333 | netdev_err(dev, "failed to alloc skb for rx\n"); |
335 | rc = -ENOMEM; | 334 | rc = -ENOMEM; |
336 | goto err_exit; | 335 | goto err_exit; |
337 | } | 336 | } |
@@ -411,9 +410,9 @@ static void r6040_tx_timeout(struct net_device *dev) | |||
411 | struct r6040_private *priv = netdev_priv(dev); | 410 | struct r6040_private *priv = netdev_priv(dev); |
412 | void __iomem *ioaddr = priv->base; | 411 | void __iomem *ioaddr = priv->base; |
413 | 412 | ||
414 | printk(KERN_WARNING "%s: transmit timed out, int enable %4.4x " | 413 | netdev_warn(dev, "transmit timed out, int enable %4.4x " |
415 | "status %4.4x, PHY status %4.4x\n", | 414 | "status %4.4x, PHY status %4.4x\n", |
416 | dev->name, ioread16(ioaddr + MIER), | 415 | ioread16(ioaddr + MIER), |
417 | ioread16(ioaddr + MISR), | 416 | ioread16(ioaddr + MISR), |
418 | r6040_mdio_read(dev, priv->mii_if.phy_id, MII_BMSR)); | 417 | r6040_mdio_read(dev, priv->mii_if.phy_id, MII_BMSR)); |
419 | 418 | ||
@@ -898,7 +897,7 @@ static netdev_tx_t r6040_start_xmit(struct sk_buff *skb, | |||
898 | if (!lp->tx_free_desc) { | 897 | if (!lp->tx_free_desc) { |
899 | spin_unlock_irqrestore(&lp->lock, flags); | 898 | spin_unlock_irqrestore(&lp->lock, flags); |
900 | netif_stop_queue(dev); | 899 | netif_stop_queue(dev); |
901 | printk(KERN_ERR DRV_NAME ": no tx descriptor\n"); | 900 | netdev_err(dev, ": no tx descriptor\n"); |
902 | return NETDEV_TX_BUSY; | 901 | return NETDEV_TX_BUSY; |
903 | } | 902 | } |
904 | 903 | ||
@@ -925,7 +924,6 @@ static netdev_tx_t r6040_start_xmit(struct sk_buff *skb, | |||
925 | if (!lp->tx_free_desc) | 924 | if (!lp->tx_free_desc) |
926 | netif_stop_queue(dev); | 925 | netif_stop_queue(dev); |
927 | 926 | ||
928 | dev->trans_start = jiffies; | ||
929 | spin_unlock_irqrestore(&lp->lock, flags); | 927 | spin_unlock_irqrestore(&lp->lock, flags); |
930 | 928 | ||
931 | return NETDEV_TX_OK; | 929 | return NETDEV_TX_OK; |
@@ -938,7 +936,7 @@ static void r6040_multicast_list(struct net_device *dev) | |||
938 | u16 *adrp; | 936 | u16 *adrp; |
939 | u16 reg; | 937 | u16 reg; |
940 | unsigned long flags; | 938 | unsigned long flags; |
941 | struct dev_mc_list *dmi; | 939 | struct netdev_hw_addr *ha; |
942 | int i; | 940 | int i; |
943 | 941 | ||
944 | /* MAC Address */ | 942 | /* MAC Address */ |
@@ -973,8 +971,8 @@ static void r6040_multicast_list(struct net_device *dev) | |||
973 | for (i = 0; i < 4; i++) | 971 | for (i = 0; i < 4; i++) |
974 | hash_table[i] = 0; | 972 | hash_table[i] = 0; |
975 | 973 | ||
976 | netdev_for_each_mc_addr(dmi, dev) { | 974 | netdev_for_each_mc_addr(ha, dev) { |
977 | char *addrs = dmi->dmi_addr; | 975 | char *addrs = ha->addr; |
978 | 976 | ||
979 | if (!(*addrs & 1)) | 977 | if (!(*addrs & 1)) |
980 | continue; | 978 | continue; |
@@ -983,9 +981,6 @@ static void r6040_multicast_list(struct net_device *dev) | |||
983 | crc >>= 26; | 981 | crc >>= 26; |
984 | hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); | 982 | hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); |
985 | } | 983 | } |
986 | /* Write the index of the hash table */ | ||
987 | for (i = 0; i < 4; i++) | ||
988 | iowrite16(hash_table[i] << 14, ioaddr + MCR1); | ||
989 | /* Fill the MAC hash tables with their values */ | 984 | /* Fill the MAC hash tables with their values */ |
990 | iowrite16(hash_table[0], ioaddr + MAR0); | 985 | iowrite16(hash_table[0], ioaddr + MAR0); |
991 | iowrite16(hash_table[1], ioaddr + MAR1); | 986 | iowrite16(hash_table[1], ioaddr + MAR1); |
@@ -994,16 +989,16 @@ static void r6040_multicast_list(struct net_device *dev) | |||
994 | } | 989 | } |
995 | /* Multicast Address 1~4 case */ | 990 | /* Multicast Address 1~4 case */ |
996 | i = 0; | 991 | i = 0; |
997 | netdev_for_each_mc_addr(dmi, dev) { | 992 | netdev_for_each_mc_addr(ha, dev) { |
998 | if (i < MCAST_MAX) { | 993 | if (i < MCAST_MAX) { |
999 | adrp = (u16 *) dmi->dmi_addr; | 994 | adrp = (u16 *) ha->addr; |
1000 | iowrite16(adrp[0], ioaddr + MID_1L + 8 * i); | 995 | iowrite16(adrp[0], ioaddr + MID_1L + 8 * i); |
1001 | iowrite16(adrp[1], ioaddr + MID_1M + 8 * i); | 996 | iowrite16(adrp[1], ioaddr + MID_1M + 8 * i); |
1002 | iowrite16(adrp[2], ioaddr + MID_1H + 8 * i); | 997 | iowrite16(adrp[2], ioaddr + MID_1H + 8 * i); |
1003 | } else { | 998 | } else { |
1004 | iowrite16(0xffff, ioaddr + MID_0L + 8 * i); | 999 | iowrite16(0xffff, ioaddr + MID_1L + 8 * i); |
1005 | iowrite16(0xffff, ioaddr + MID_0M + 8 * i); | 1000 | iowrite16(0xffff, ioaddr + MID_1M + 8 * i); |
1006 | iowrite16(0xffff, ioaddr + MID_0H + 8 * i); | 1001 | iowrite16(0xffff, ioaddr + MID_1H + 8 * i); |
1007 | } | 1002 | } |
1008 | i++; | 1003 | i++; |
1009 | } | 1004 | } |
@@ -1094,20 +1089,20 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, | |||
1094 | /* this should always be supported */ | 1089 | /* this should always be supported */ |
1095 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 1090 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
1096 | if (err) { | 1091 | if (err) { |
1097 | printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses" | 1092 | dev_err(&pdev->dev, "32-bit PCI DMA addresses" |
1098 | "not supported by the card\n"); | 1093 | "not supported by the card\n"); |
1099 | goto err_out; | 1094 | goto err_out; |
1100 | } | 1095 | } |
1101 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); | 1096 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
1102 | if (err) { | 1097 | if (err) { |
1103 | printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses" | 1098 | dev_err(&pdev->dev, "32-bit PCI DMA addresses" |
1104 | "not supported by the card\n"); | 1099 | "not supported by the card\n"); |
1105 | goto err_out; | 1100 | goto err_out; |
1106 | } | 1101 | } |
1107 | 1102 | ||
1108 | /* IO Size check */ | 1103 | /* IO Size check */ |
1109 | if (pci_resource_len(pdev, bar) < io_size) { | 1104 | if (pci_resource_len(pdev, bar) < io_size) { |
1110 | printk(KERN_ERR DRV_NAME ": Insufficient PCI resources, aborting\n"); | 1105 | dev_err(&pdev->dev, "Insufficient PCI resources, aborting\n"); |
1111 | err = -EIO; | 1106 | err = -EIO; |
1112 | goto err_out; | 1107 | goto err_out; |
1113 | } | 1108 | } |
@@ -1116,7 +1111,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, | |||
1116 | 1111 | ||
1117 | dev = alloc_etherdev(sizeof(struct r6040_private)); | 1112 | dev = alloc_etherdev(sizeof(struct r6040_private)); |
1118 | if (!dev) { | 1113 | if (!dev) { |
1119 | printk(KERN_ERR DRV_NAME ": Failed to allocate etherdev\n"); | 1114 | dev_err(&pdev->dev, "Failed to allocate etherdev\n"); |
1120 | err = -ENOMEM; | 1115 | err = -ENOMEM; |
1121 | goto err_out; | 1116 | goto err_out; |
1122 | } | 1117 | } |
@@ -1126,14 +1121,13 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, | |||
1126 | err = pci_request_regions(pdev, DRV_NAME); | 1121 | err = pci_request_regions(pdev, DRV_NAME); |
1127 | 1122 | ||
1128 | if (err) { | 1123 | if (err) { |
1129 | printk(KERN_ERR DRV_NAME ": Failed to request PCI regions\n"); | 1124 | dev_err(&pdev->dev, "Failed to request PCI regions\n"); |
1130 | goto err_out_free_dev; | 1125 | goto err_out_free_dev; |
1131 | } | 1126 | } |
1132 | 1127 | ||
1133 | ioaddr = pci_iomap(pdev, bar, io_size); | 1128 | ioaddr = pci_iomap(pdev, bar, io_size); |
1134 | if (!ioaddr) { | 1129 | if (!ioaddr) { |
1135 | printk(KERN_ERR DRV_NAME ": ioremap failed for device %s\n", | 1130 | dev_err(&pdev->dev, "ioremap failed for device\n"); |
1136 | pci_name(pdev)); | ||
1137 | err = -EIO; | 1131 | err = -EIO; |
1138 | goto err_out_free_res; | 1132 | goto err_out_free_res; |
1139 | } | 1133 | } |
@@ -1160,7 +1154,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, | |||
1160 | /* Some bootloader/BIOSes do not initialize | 1154 | /* Some bootloader/BIOSes do not initialize |
1161 | * MAC address, warn about that */ | 1155 | * MAC address, warn about that */ |
1162 | if (!(adrp[0] || adrp[1] || adrp[2])) { | 1156 | if (!(adrp[0] || adrp[1] || adrp[2])) { |
1163 | printk(KERN_WARNING DRV_NAME ": MAC address not initialized, generating random\n"); | 1157 | netdev_warn(dev, "MAC address not initialized, generating random\n"); |
1164 | random_ether_addr(dev->dev_addr); | 1158 | random_ether_addr(dev->dev_addr); |
1165 | } | 1159 | } |
1166 | 1160 | ||
@@ -1188,7 +1182,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, | |||
1188 | 1182 | ||
1189 | /* Check the vendor ID on the PHY, if 0xffff assume none attached */ | 1183 | /* Check the vendor ID on the PHY, if 0xffff assume none attached */ |
1190 | if (r6040_phy_read(ioaddr, lp->phy_addr, 2) == 0xffff) { | 1184 | if (r6040_phy_read(ioaddr, lp->phy_addr, 2) == 0xffff) { |
1191 | printk(KERN_ERR DRV_NAME ": Failed to detect an attached PHY\n"); | 1185 | dev_err(&pdev->dev, "Failed to detect an attached PHY\n"); |
1192 | err = -ENODEV; | 1186 | err = -ENODEV; |
1193 | goto err_out_unmap; | 1187 | goto err_out_unmap; |
1194 | } | 1188 | } |
@@ -1196,7 +1190,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, | |||
1196 | /* Register net device. After this dev->name assign */ | 1190 | /* Register net device. After this dev->name assign */ |
1197 | err = register_netdev(dev); | 1191 | err = register_netdev(dev); |
1198 | if (err) { | 1192 | if (err) { |
1199 | printk(KERN_ERR DRV_NAME ": Failed to register net device\n"); | 1193 | dev_err(&pdev->dev, "Failed to register net device\n"); |
1200 | goto err_out_unmap; | 1194 | goto err_out_unmap; |
1201 | } | 1195 | } |
1202 | return 0; | 1196 | return 0; |