aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/b44.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/b44.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/b44.c')
-rw-r--r--drivers/net/b44.c98
1 files changed, 48 insertions, 50 deletions
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 2a9132343b66..69d9f3d368ae 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -10,6 +10,8 @@
10 * Distribute under GPL. 10 * Distribute under GPL.
11 */ 11 */
12 12
13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14
13#include <linux/kernel.h> 15#include <linux/kernel.h>
14#include <linux/module.h> 16#include <linux/module.h>
15#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
@@ -25,6 +27,7 @@
25#include <linux/init.h> 27#include <linux/init.h>
26#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
27#include <linux/ssb/ssb.h> 29#include <linux/ssb/ssb.h>
30#include <linux/slab.h>
28 31
29#include <asm/uaccess.h> 32#include <asm/uaccess.h>
30#include <asm/io.h> 33#include <asm/io.h>
@@ -34,7 +37,6 @@
34#include "b44.h" 37#include "b44.h"
35 38
36#define DRV_MODULE_NAME "b44" 39#define DRV_MODULE_NAME "b44"
37#define PFX DRV_MODULE_NAME ": "
38#define DRV_MODULE_VERSION "2.0" 40#define DRV_MODULE_VERSION "2.0"
39 41
40#define B44_DEF_MSG_ENABLE \ 42#define B44_DEF_MSG_ENABLE \
@@ -102,7 +104,7 @@ MODULE_PARM_DESC(b44_debug, "B44 bitmapped debugging message enable value");
102 104
103 105
104#ifdef CONFIG_B44_PCI 106#ifdef CONFIG_B44_PCI
105static const struct pci_device_id b44_pci_tbl[] = { 107static DEFINE_PCI_DEVICE_TABLE(b44_pci_tbl) = {
106 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401) }, 108 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401) },
107 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B0) }, 109 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B0) },
108 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B1) }, 110 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B1) },
@@ -189,11 +191,10 @@ static int b44_wait_bit(struct b44 *bp, unsigned long reg,
189 udelay(10); 191 udelay(10);
190 } 192 }
191 if (i == timeout) { 193 if (i == timeout) {
192 printk(KERN_ERR PFX "%s: BUG! Timeout waiting for bit %08x of register " 194 if (net_ratelimit())
193 "%lx to %s.\n", 195 netdev_err(bp->dev, "BUG! Timeout waiting for bit %08x of register %lx to %s\n",
194 bp->dev->name, 196 bit, reg, clear ? "clear" : "set");
195 bit, reg, 197
196 (clear ? "clear" : "set"));
197 return -ENODEV; 198 return -ENODEV;
198 } 199 }
199 return 0; 200 return 0;
@@ -333,13 +334,12 @@ static int b44_phy_reset(struct b44 *bp)
333 err = b44_readphy(bp, MII_BMCR, &val); 334 err = b44_readphy(bp, MII_BMCR, &val);
334 if (!err) { 335 if (!err) {
335 if (val & BMCR_RESET) { 336 if (val & BMCR_RESET) {
336 printk(KERN_ERR PFX "%s: PHY Reset would not complete.\n", 337 netdev_err(bp->dev, "PHY Reset would not complete\n");
337 bp->dev->name);
338 err = -ENODEV; 338 err = -ENODEV;
339 } 339 }
340 } 340 }
341 341
342 return 0; 342 return err;
343} 343}
344 344
345static void __b44_set_flow_ctrl(struct b44 *bp, u32 pause_flags) 345static void __b44_set_flow_ctrl(struct b44 *bp, u32 pause_flags)
@@ -413,7 +413,7 @@ static void b44_wap54g10_workaround(struct b44 *bp)
413 } 413 }
414 return; 414 return;
415error: 415error:
416 printk(KERN_WARNING PFX "PHY: cannot reset MII transceiver isolate bit.\n"); 416 pr_warning("PHY: cannot reset MII transceiver isolate bit\n");
417} 417}
418#else 418#else
419static inline void b44_wap54g10_workaround(struct b44 *bp) 419static inline void b44_wap54g10_workaround(struct b44 *bp)
@@ -506,18 +506,15 @@ static void b44_stats_update(struct b44 *bp)
506static void b44_link_report(struct b44 *bp) 506static void b44_link_report(struct b44 *bp)
507{ 507{
508 if (!netif_carrier_ok(bp->dev)) { 508 if (!netif_carrier_ok(bp->dev)) {
509 printk(KERN_INFO PFX "%s: Link is down.\n", bp->dev->name); 509 netdev_info(bp->dev, "Link is down\n");
510 } else { 510 } else {
511 printk(KERN_INFO PFX "%s: Link is up at %d Mbps, %s duplex.\n", 511 netdev_info(bp->dev, "Link is up at %d Mbps, %s duplex\n",
512 bp->dev->name, 512 (bp->flags & B44_FLAG_100_BASE_T) ? 100 : 10,
513 (bp->flags & B44_FLAG_100_BASE_T) ? 100 : 10, 513 (bp->flags & B44_FLAG_FULL_DUPLEX) ? "full" : "half");
514 (bp->flags & B44_FLAG_FULL_DUPLEX) ? "full" : "half"); 514
515 515 netdev_info(bp->dev, "Flow control is %s for TX and %s for RX\n",
516 printk(KERN_INFO PFX "%s: Flow control is %s for TX and " 516 (bp->flags & B44_FLAG_TX_PAUSE) ? "on" : "off",
517 "%s for RX.\n", 517 (bp->flags & B44_FLAG_RX_PAUSE) ? "on" : "off");
518 bp->dev->name,
519 (bp->flags & B44_FLAG_TX_PAUSE) ? "on" : "off",
520 (bp->flags & B44_FLAG_RX_PAUSE) ? "on" : "off");
521 } 518 }
522} 519}
523 520
@@ -576,11 +573,9 @@ static void b44_check_phy(struct b44 *bp)
576 } 573 }
577 574
578 if (bmsr & BMSR_RFAULT) 575 if (bmsr & BMSR_RFAULT)
579 printk(KERN_WARNING PFX "%s: Remote fault detected in PHY\n", 576 netdev_warn(bp->dev, "Remote fault detected in PHY\n");
580 bp->dev->name);
581 if (bmsr & BMSR_JCD) 577 if (bmsr & BMSR_JCD)
582 printk(KERN_WARNING PFX "%s: Jabber detected in PHY\n", 578 netdev_warn(bp->dev, "Jabber detected in PHY\n");
583 bp->dev->name);
584 } 579 }
585} 580}
586 581
@@ -815,7 +810,7 @@ static int b44_rx(struct b44 *bp, int budget)
815 struct sk_buff *copy_skb; 810 struct sk_buff *copy_skb;
816 811
817 b44_recycle_rx(bp, cons, bp->rx_prod); 812 b44_recycle_rx(bp, cons, bp->rx_prod);
818 copy_skb = dev_alloc_skb(len + 2); 813 copy_skb = netdev_alloc_skb(bp->dev, len + 2);
819 if (copy_skb == NULL) 814 if (copy_skb == NULL)
820 goto drop_it_no_recycle; 815 goto drop_it_no_recycle;
821 816
@@ -901,7 +896,7 @@ static irqreturn_t b44_interrupt(int irq, void *dev_id)
901 handled = 1; 896 handled = 1;
902 897
903 if (unlikely(!netif_running(dev))) { 898 if (unlikely(!netif_running(dev))) {
904 printk(KERN_INFO "%s: late interrupt.\n", dev->name); 899 netdev_info(dev, "late interrupt\n");
905 goto irq_ack; 900 goto irq_ack;
906 } 901 }
907 902
@@ -926,8 +921,7 @@ static void b44_tx_timeout(struct net_device *dev)
926{ 921{
927 struct b44 *bp = netdev_priv(dev); 922 struct b44 *bp = netdev_priv(dev);
928 923
929 printk(KERN_ERR PFX "%s: transmit timed out, resetting\n", 924 netdev_err(dev, "transmit timed out, resetting\n");
930 dev->name);
931 925
932 spin_lock_irq(&bp->lock); 926 spin_lock_irq(&bp->lock);
933 927
@@ -956,8 +950,7 @@ static netdev_tx_t b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
956 /* This is a hard error, log it. */ 950 /* This is a hard error, log it. */
957 if (unlikely(TX_BUFFS_AVAIL(bp) < 1)) { 951 if (unlikely(TX_BUFFS_AVAIL(bp) < 1)) {
958 netif_stop_queue(dev); 952 netif_stop_queue(dev);
959 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n", 953 netdev_err(dev, "BUG! Tx Ring full when queue awake!\n");
960 dev->name);
961 goto err_out; 954 goto err_out;
962 } 955 }
963 956
@@ -1333,7 +1326,7 @@ static void b44_halt(struct b44 *bp)
1333 /* reset PHY */ 1326 /* reset PHY */
1334 b44_phy_reset(bp); 1327 b44_phy_reset(bp);
1335 /* power down PHY */ 1328 /* power down PHY */
1336 printk(KERN_INFO PFX "%s: powering down PHY\n", bp->dev->name); 1329 netdev_info(bp->dev, "powering down PHY\n");
1337 bw32(bp, B44_MAC_CTRL, MAC_CTRL_PHY_PDOWN); 1330 bw32(bp, B44_MAC_CTRL, MAC_CTRL_PHY_PDOWN);
1338 /* now reset the chip, but without enabling the MAC&PHY 1331 /* now reset the chip, but without enabling the MAC&PHY
1339 * part of it. This has to be done _after_ we shut down the PHY */ 1332 * part of it. This has to be done _after_ we shut down the PHY */
@@ -1505,8 +1498,7 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset)
1505 for (k = 0; k< ethaddr_bytes; k++) { 1498 for (k = 0; k< ethaddr_bytes; k++) {
1506 ppattern[offset + magicsync + 1499 ppattern[offset + magicsync +
1507 (j * ETH_ALEN) + k] = macaddr[k]; 1500 (j * ETH_ALEN) + k] = macaddr[k];
1508 len++; 1501 set_bit(len++, (unsigned long *) pmask);
1509 set_bit(len, (unsigned long *) pmask);
1510 } 1502 }
1511 } 1503 }
1512 return len - 1; 1504 return len - 1;
@@ -1525,7 +1517,7 @@ static void b44_setup_pseudo_magicp(struct b44 *bp)
1525 1517
1526 pwol_pattern = kzalloc(B44_PATTERN_SIZE, GFP_KERNEL); 1518 pwol_pattern = kzalloc(B44_PATTERN_SIZE, GFP_KERNEL);
1527 if (!pwol_pattern) { 1519 if (!pwol_pattern) {
1528 printk(KERN_ERR PFX "Memory not available for WOL\n"); 1520 pr_err("Memory not available for WOL\n");
1529 return; 1521 return;
1530 } 1522 }
1531 1523
@@ -1692,10 +1684,12 @@ static int __b44_load_mcast(struct b44 *bp, struct net_device *dev)
1692 struct dev_mc_list *mclist; 1684 struct dev_mc_list *mclist;
1693 int i, num_ents; 1685 int i, num_ents;
1694 1686
1695 num_ents = min_t(int, dev->mc_count, B44_MCAST_TABLE_SIZE); 1687 num_ents = min_t(int, netdev_mc_count(dev), B44_MCAST_TABLE_SIZE);
1696 mclist = dev->mc_list; 1688 i = 0;
1697 for (i = 0; mclist && i < num_ents; i++, mclist = mclist->next) { 1689 netdev_for_each_mc_addr(mclist, dev) {
1698 __b44_cam_write(bp, mclist->dmi_addr, i + 1); 1690 if (i == num_ents)
1691 break;
1692 __b44_cam_write(bp, mclist->dmi_addr, i++ + 1);
1699 } 1693 }
1700 return i+1; 1694 return i+1;
1701} 1695}
@@ -1717,7 +1711,7 @@ static void __b44_set_rx_mode(struct net_device *dev)
1717 __b44_set_mac_addr(bp); 1711 __b44_set_mac_addr(bp);
1718 1712
1719 if ((dev->flags & IFF_ALLMULTI) || 1713 if ((dev->flags & IFF_ALLMULTI) ||
1720 (dev->mc_count > B44_MCAST_TABLE_SIZE)) 1714 (netdev_mc_count(dev) > B44_MCAST_TABLE_SIZE))
1721 val |= RXCONFIG_ALLMULTI; 1715 val |= RXCONFIG_ALLMULTI;
1722 else 1716 else
1723 i = __b44_load_mcast(bp, dev); 1717 i = __b44_load_mcast(bp, dev);
@@ -2098,7 +2092,7 @@ static int __devinit b44_get_invariants(struct b44 *bp)
2098 memcpy(bp->dev->dev_addr, addr, 6); 2092 memcpy(bp->dev->dev_addr, addr, 6);
2099 2093
2100 if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){ 2094 if (!is_valid_ether_addr(&bp->dev->dev_addr[0])){
2101 printk(KERN_ERR PFX "Invalid MAC address found in EEPROM\n"); 2095 pr_err("Invalid MAC address found in EEPROM\n");
2102 return -EINVAL; 2096 return -EINVAL;
2103 } 2097 }
2104 2098
@@ -2143,12 +2137,12 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2143 instance++; 2137 instance++;
2144 2138
2145 if (b44_version_printed++ == 0) 2139 if (b44_version_printed++ == 0)
2146 printk(KERN_INFO "%s", version); 2140 pr_info("%s", version);
2147 2141
2148 2142
2149 dev = alloc_etherdev(sizeof(*bp)); 2143 dev = alloc_etherdev(sizeof(*bp));
2150 if (!dev) { 2144 if (!dev) {
2151 dev_err(sdev->dev, "Etherdev alloc failed, aborting.\n"); 2145 dev_err(sdev->dev, "Etherdev alloc failed, aborting\n");
2152 err = -ENOMEM; 2146 err = -ENOMEM;
2153 goto out; 2147 goto out;
2154 } 2148 }
@@ -2187,13 +2181,13 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2187 err = ssb_dma_set_mask(sdev, DMA_BIT_MASK(30)); 2181 err = ssb_dma_set_mask(sdev, DMA_BIT_MASK(30));
2188 if (err) { 2182 if (err) {
2189 dev_err(sdev->dev, 2183 dev_err(sdev->dev,
2190 "Required 30BIT DMA mask unsupported by the system.\n"); 2184 "Required 30BIT DMA mask unsupported by the system\n");
2191 goto err_out_powerdown; 2185 goto err_out_powerdown;
2192 } 2186 }
2193 err = b44_get_invariants(bp); 2187 err = b44_get_invariants(bp);
2194 if (err) { 2188 if (err) {
2195 dev_err(sdev->dev, 2189 dev_err(sdev->dev,
2196 "Problem fetching invariants of chip, aborting.\n"); 2190 "Problem fetching invariants of chip, aborting\n");
2197 goto err_out_powerdown; 2191 goto err_out_powerdown;
2198 } 2192 }
2199 2193
@@ -2213,7 +2207,7 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2213 2207
2214 err = register_netdev(dev); 2208 err = register_netdev(dev);
2215 if (err) { 2209 if (err) {
2216 dev_err(sdev->dev, "Cannot register net device, aborting.\n"); 2210 dev_err(sdev->dev, "Cannot register net device, aborting\n");
2217 goto err_out_powerdown; 2211 goto err_out_powerdown;
2218 } 2212 }
2219 2213
@@ -2224,8 +2218,12 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2224 */ 2218 */
2225 b44_chip_reset(bp, B44_CHIP_RESET_FULL); 2219 b44_chip_reset(bp, B44_CHIP_RESET_FULL);
2226 2220
2227 printk(KERN_INFO "%s: Broadcom 44xx/47xx 10/100BaseT Ethernet %pM\n", 2221 /* do a phy reset to test if there is an active phy */
2228 dev->name, dev->dev_addr); 2222 if (b44_phy_reset(bp) < 0)
2223 bp->phy_addr = B44_PHY_ADDR_NO_PHY;
2224
2225 netdev_info(dev, "Broadcom 44xx/47xx 10/100BaseT Ethernet %pM\n",
2226 dev->dev_addr);
2229 2227
2230 return 0; 2228 return 0;
2231 2229
@@ -2298,7 +2296,7 @@ static int b44_resume(struct ssb_device *sdev)
2298 2296
2299 rc = request_irq(dev->irq, b44_interrupt, IRQF_SHARED, dev->name, dev); 2297 rc = request_irq(dev->irq, b44_interrupt, IRQF_SHARED, dev->name, dev);
2300 if (rc) { 2298 if (rc) {
2301 printk(KERN_ERR PFX "%s: request_irq failed\n", dev->name); 2299 netdev_err(dev, "request_irq failed\n");
2302 return rc; 2300 return rc;
2303 } 2301 }
2304 2302