aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-01-18 17:06:44 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-01-18 17:06:44 -0500
commit8b2d1833a29e9dc8bccad348396ad08666379d77 (patch)
treea7bb3bb922bb744934cc0d0bcce043ad8129ab0e
parentc9daa2722a3f1967e3e9750fd4cb6a7352a3cd63 (diff)
parentba596a01886b236c8171fc28d53842da0128224e (diff)
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (31 commits) Replace cpmac fix dl2k: the rest dl2k: MSCR, MSSR, ESR, PHY_SCR fixes dl2k: BMSR fixes dl2k: ANAR, ANLPAR fixes dl2k: BMCR_t fixes 3c574, 3c515 bitfields abuse sbni endian fixes wan/lmc bitfields fixes dscc4 endian fixes S2io: Fixed synchronization between scheduling of napi with card reset and close atl1: fix frame length bug Documentation: add a guideline for hard_start_xmit method Revert "sky2: remove check for PCI wakeup setting from BIOS" e1000e Kconfig: remove ref to nonexistant docs bonding: Don't hold lock when calling rtnl_unlock bonding: fix lock ordering for rtnl and bonding_rwsem bonding: Fix up parameter parsing bonding: release slaves when master removed via sysfs bonding: fix locking during alb failover and slave removal ...
-rw-r--r--Documentation/networking/driver.txt5
-rw-r--r--drivers/net/3c515.c60
-rw-r--r--drivers/net/Kconfig3
-rw-r--r--drivers/net/atl1/atl1_main.c8
-rw-r--r--drivers/net/bonding/bond_alb.c23
-rw-r--r--drivers/net/bonding/bond_main.c64
-rw-r--r--drivers/net/bonding/bond_sysfs.c66
-rw-r--r--drivers/net/bonding/bonding.h4
-rw-r--r--drivers/net/cpmac.c2
-rw-r--r--drivers/net/dl2k.c215
-rw-r--r--drivers/net/dl2k.h157
-rw-r--r--drivers/net/ipg.c36
-rw-r--r--drivers/net/pcmcia/3c574_cs.c31
-rw-r--r--drivers/net/s2io.c17
-rw-r--r--drivers/net/sky2.c24
-rw-r--r--drivers/net/wan/dscc4.c94
-rw-r--r--drivers/net/wan/lmc/lmc_media.c12
-rw-r--r--drivers/net/wan/sbni.h12
-rw-r--r--drivers/net/wireless/b43/rfkill.c11
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c6
-rw-r--r--drivers/net/wireless/ipw2200.c2
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c11
24 files changed, 387 insertions, 482 deletions
diff --git a/Documentation/networking/driver.txt b/Documentation/networking/driver.txt
index 4f7da5a2bf4f..ea72d2e66ca8 100644
--- a/Documentation/networking/driver.txt
+++ b/Documentation/networking/driver.txt
@@ -61,7 +61,10 @@ Transmit path guidelines:
612) Do not forget to update netdev->trans_start to jiffies after 612) Do not forget to update netdev->trans_start to jiffies after
62 each new tx packet is given to the hardware. 62 each new tx packet is given to the hardware.
63 63
643) Do not forget that once you return 0 from your hard_start_xmit 643) A hard_start_xmit method must not modify the shared parts of a
65 cloned SKB.
66
674) Do not forget that once you return 0 from your hard_start_xmit
65 method, it is your driver's responsibility to free up the SKB 68 method, it is your driver's responsibility to free up the SKB
66 and in some finite amount of time. 69 and in some finite amount of time.
67 70
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index 275e7510ebaf..684bab781015 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -243,14 +243,16 @@ enum eeprom_offset {
243enum Window3 { /* Window 3: MAC/config bits. */ 243enum Window3 { /* Window 3: MAC/config bits. */
244 Wn3_Config = 0, Wn3_MAC_Ctrl = 6, Wn3_Options = 8, 244 Wn3_Config = 0, Wn3_MAC_Ctrl = 6, Wn3_Options = 8,
245}; 245};
246union wn3_config { 246enum wn3_config {
247 int i; 247 Ram_size = 7,
248 struct w3_config_fields { 248 Ram_width = 8,
249 unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2; 249 Ram_speed = 0x30,
250 int pad8:8; 250 Rom_size = 0xc0,
251 unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1; 251 Ram_split_shift = 16,
252 int pad24:7; 252 Ram_split = 3 << Ram_split_shift,
253 } u; 253 Xcvr_shift = 20,
254 Xcvr = 7 << Xcvr_shift,
255 Autoselect = 0x1000000,
254}; 256};
255 257
256enum Window4 { 258enum Window4 {
@@ -614,7 +616,7 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
614 /* Read the station address from the EEPROM. */ 616 /* Read the station address from the EEPROM. */
615 EL3WINDOW(0); 617 EL3WINDOW(0);
616 for (i = 0; i < 0x18; i++) { 618 for (i = 0; i < 0x18; i++) {
617 short *phys_addr = (short *) dev->dev_addr; 619 __be16 *phys_addr = (__be16 *) dev->dev_addr;
618 int timer; 620 int timer;
619 outw(EEPROM_Read + i, ioaddr + Wn0EepromCmd); 621 outw(EEPROM_Read + i, ioaddr + Wn0EepromCmd);
620 /* Pause for at least 162 us. for the read to take place. */ 622 /* Pause for at least 162 us. for the read to take place. */
@@ -646,22 +648,22 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
646 648
647 { 649 {
648 char *ram_split[] = { "5:3", "3:1", "1:1", "3:5" }; 650 char *ram_split[] = { "5:3", "3:1", "1:1", "3:5" };
649 union wn3_config config; 651 __u32 config;
650 EL3WINDOW(3); 652 EL3WINDOW(3);
651 vp->available_media = inw(ioaddr + Wn3_Options); 653 vp->available_media = inw(ioaddr + Wn3_Options);
652 config.i = inl(ioaddr + Wn3_Config); 654 config = inl(ioaddr + Wn3_Config);
653 if (corkscrew_debug > 1) 655 if (corkscrew_debug > 1)
654 printk(KERN_INFO " Internal config register is %4.4x, transceivers %#x.\n", 656 printk(KERN_INFO " Internal config register is %4.4x, transceivers %#x.\n",
655 config.i, inw(ioaddr + Wn3_Options)); 657 config, inw(ioaddr + Wn3_Options));
656 printk(KERN_INFO " %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n", 658 printk(KERN_INFO " %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",
657 8 << config.u.ram_size, 659 8 << config & Ram_size,
658 config.u.ram_width ? "word" : "byte", 660 config & Ram_width ? "word" : "byte",
659 ram_split[config.u.ram_split], 661 ram_split[(config & Ram_split) >> Ram_split_shift],
660 config.u.autoselect ? "autoselect/" : "", 662 config & Autoselect ? "autoselect/" : "",
661 media_tbl[config.u.xcvr].name); 663 media_tbl[(config & Xcvr) >> Xcvr_shift].name);
662 dev->if_port = config.u.xcvr; 664 vp->default_media = (config & Xcvr) >> Xcvr_shift;
663 vp->default_media = config.u.xcvr; 665 vp->autoselect = config & Autoselect ? 1 : 0;
664 vp->autoselect = config.u.autoselect; 666 dev->if_port = vp->default_media;
665 } 667 }
666 if (vp->media_override != 7) { 668 if (vp->media_override != 7) {
667 printk(KERN_INFO " Media override to transceiver type %d (%s).\n", 669 printk(KERN_INFO " Media override to transceiver type %d (%s).\n",
@@ -694,14 +696,14 @@ static int corkscrew_open(struct net_device *dev)
694{ 696{
695 int ioaddr = dev->base_addr; 697 int ioaddr = dev->base_addr;
696 struct corkscrew_private *vp = netdev_priv(dev); 698 struct corkscrew_private *vp = netdev_priv(dev);
697 union wn3_config config; 699 __u32 config;
698 int i; 700 int i;
699 701
700 /* Before initializing select the active media port. */ 702 /* Before initializing select the active media port. */
701 EL3WINDOW(3); 703 EL3WINDOW(3);
702 if (vp->full_duplex) 704 if (vp->full_duplex)
703 outb(0x20, ioaddr + Wn3_MAC_Ctrl); /* Set the full-duplex bit. */ 705 outb(0x20, ioaddr + Wn3_MAC_Ctrl); /* Set the full-duplex bit. */
704 config.i = inl(ioaddr + Wn3_Config); 706 config = inl(ioaddr + Wn3_Config);
705 707
706 if (vp->media_override != 7) { 708 if (vp->media_override != 7) {
707 if (corkscrew_debug > 1) 709 if (corkscrew_debug > 1)
@@ -727,12 +729,12 @@ static int corkscrew_open(struct net_device *dev)
727 } else 729 } else
728 dev->if_port = vp->default_media; 730 dev->if_port = vp->default_media;
729 731
730 config.u.xcvr = dev->if_port; 732 config = (config & ~Xcvr) | (dev->if_port << Xcvr_shift);
731 outl(config.i, ioaddr + Wn3_Config); 733 outl(config, ioaddr + Wn3_Config);
732 734
733 if (corkscrew_debug > 1) { 735 if (corkscrew_debug > 1) {
734 printk("%s: corkscrew_open() InternalConfig %8.8x.\n", 736 printk("%s: corkscrew_open() InternalConfig %8.8x.\n",
735 dev->name, config.i); 737 dev->name, config);
736 } 738 }
737 739
738 outw(TxReset, ioaddr + EL3_CMD); 740 outw(TxReset, ioaddr + EL3_CMD);
@@ -901,7 +903,7 @@ static void corkscrew_timer(unsigned long data)
901 ok = 1; 903 ok = 1;
902 } 904 }
903 if (!ok) { 905 if (!ok) {
904 union wn3_config config; 906 __u32 config;
905 907
906 do { 908 do {
907 dev->if_port = 909 dev->if_port =
@@ -928,9 +930,9 @@ static void corkscrew_timer(unsigned long data)
928 ioaddr + Wn4_Media); 930 ioaddr + Wn4_Media);
929 931
930 EL3WINDOW(3); 932 EL3WINDOW(3);
931 config.i = inl(ioaddr + Wn3_Config); 933 config = inl(ioaddr + Wn3_Config);
932 config.u.xcvr = dev->if_port; 934 config = (config & ~Xcvr) | (dev->if_port << Xcvr_shift);
933 outl(config.i, ioaddr + Wn3_Config); 935 outl(config, ioaddr + Wn3_Config);
934 936
935 outw(dev->if_port == 3 ? StartCoax : StopCoax, 937 outw(dev->if_port == 3 ? StartCoax : StopCoax,
936 ioaddr + EL3_CMD); 938 ioaddr + EL3_CMD);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 114771a2a133..9ae3166e3162 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1976,9 +1976,6 @@ config E1000E
1976 1976
1977 <http://support.intel.com> 1977 <http://support.intel.com>
1978 1978
1979 More specific information on configuring the driver is in
1980 <file:Documentation/networking/e1000e.txt>.
1981
1982 To compile this driver as a module, choose M here. The module 1979 To compile this driver as a module, choose M here. The module
1983 will be called e1000e. 1980 will be called e1000e.
1984 1981
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c
index 35b0a7dd4ef4..9200ee59d854 100644
--- a/drivers/net/atl1/atl1_main.c
+++ b/drivers/net/atl1/atl1_main.c
@@ -120,7 +120,7 @@ static int __devinit atl1_sw_init(struct atl1_adapter *adapter)
120 struct atl1_hw *hw = &adapter->hw; 120 struct atl1_hw *hw = &adapter->hw;
121 struct net_device *netdev = adapter->netdev; 121 struct net_device *netdev = adapter->netdev;
122 122
123 hw->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 123 hw->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
124 hw->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 124 hw->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
125 125
126 adapter->wol = 0; 126 adapter->wol = 0;
@@ -688,7 +688,7 @@ static int atl1_change_mtu(struct net_device *netdev, int new_mtu)
688{ 688{
689 struct atl1_adapter *adapter = netdev_priv(netdev); 689 struct atl1_adapter *adapter = netdev_priv(netdev);
690 int old_mtu = netdev->mtu; 690 int old_mtu = netdev->mtu;
691 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; 691 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
692 692
693 if ((max_frame < ETH_ZLEN + ETH_FCS_LEN) || 693 if ((max_frame < ETH_ZLEN + ETH_FCS_LEN) ||
694 (max_frame > MAX_JUMBO_FRAME_SIZE)) { 694 (max_frame > MAX_JUMBO_FRAME_SIZE)) {
@@ -853,8 +853,8 @@ static u32 atl1_configure(struct atl1_adapter *adapter)
853 /* set Interrupt Clear Timer */ 853 /* set Interrupt Clear Timer */
854 iowrite16(adapter->ict, hw->hw_addr + REG_CMBDISDMA_TIMER); 854 iowrite16(adapter->ict, hw->hw_addr + REG_CMBDISDMA_TIMER);
855 855
856 /* set MTU, 4 : VLAN */ 856 /* set max frame size hw will accept */
857 iowrite32(hw->max_frame_size + 4, hw->hw_addr + REG_MTU); 857 iowrite32(hw->max_frame_size, hw->hw_addr + REG_MTU);
858 858
859 /* jumbo size & rrd retirement timer */ 859 /* jumbo size & rrd retirement timer */
860 value = (((u32) hw->rx_jumbo_th & RXQ_JMBOSZ_TH_MASK) 860 value = (((u32) hw->rx_jumbo_th & RXQ_JMBOSZ_TH_MASK)
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 25b8dbf6cfd7..b57bc9467dbe 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -979,7 +979,7 @@ static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct
979/* 979/*
980 * Send learning packets after MAC address swap. 980 * Send learning packets after MAC address swap.
981 * 981 *
982 * Called with RTNL and bond->lock held for read. 982 * Called with RTNL and no other locks
983 */ 983 */
984static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, 984static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
985 struct slave *slave2) 985 struct slave *slave2)
@@ -987,6 +987,8 @@ static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
987 int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2)); 987 int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2));
988 struct slave *disabled_slave = NULL; 988 struct slave *disabled_slave = NULL;
989 989
990 ASSERT_RTNL();
991
990 /* fasten the change in the switch */ 992 /* fasten the change in the switch */
991 if (SLAVE_IS_OK(slave1)) { 993 if (SLAVE_IS_OK(slave1)) {
992 alb_send_learning_packets(slave1, slave1->dev->dev_addr); 994 alb_send_learning_packets(slave1, slave1->dev->dev_addr);
@@ -1031,7 +1033,7 @@ static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1,
1031 * a slave that has @slave's permanet address as its current address. 1033 * a slave that has @slave's permanet address as its current address.
1032 * We'll make sure that that slave no longer uses @slave's permanent address. 1034 * We'll make sure that that slave no longer uses @slave's permanent address.
1033 * 1035 *
1034 * Caller must hold bond lock 1036 * Caller must hold RTNL and no other locks
1035 */ 1037 */
1036static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave) 1038static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *slave)
1037{ 1039{
@@ -1542,7 +1544,12 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
1542 return 0; 1544 return 0;
1543} 1545}
1544 1546
1545/* Caller must hold bond lock for write */ 1547/*
1548 * Remove slave from tlb and rlb hash tables, and fix up MAC addresses
1549 * if necessary.
1550 *
1551 * Caller must hold RTNL and no other locks
1552 */
1546void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave) 1553void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
1547{ 1554{
1548 if (bond->slave_cnt > 1) { 1555 if (bond->slave_cnt > 1) {
@@ -1601,9 +1608,6 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
1601 struct slave *swap_slave; 1608 struct slave *swap_slave;
1602 int i; 1609 int i;
1603 1610
1604 if (new_slave)
1605 ASSERT_RTNL();
1606
1607 if (bond->curr_active_slave == new_slave) { 1611 if (bond->curr_active_slave == new_slave) {
1608 return; 1612 return;
1609 } 1613 }
@@ -1649,6 +1653,8 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
1649 write_unlock_bh(&bond->curr_slave_lock); 1653 write_unlock_bh(&bond->curr_slave_lock);
1650 read_unlock(&bond->lock); 1654 read_unlock(&bond->lock);
1651 1655
1656 ASSERT_RTNL();
1657
1652 /* curr_active_slave must be set before calling alb_swap_mac_addr */ 1658 /* curr_active_slave must be set before calling alb_swap_mac_addr */
1653 if (swap_slave) { 1659 if (swap_slave) {
1654 /* swap mac address */ 1660 /* swap mac address */
@@ -1659,12 +1665,11 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
1659 bond->alb_info.rlb_enabled); 1665 bond->alb_info.rlb_enabled);
1660 } 1666 }
1661 1667
1662 read_lock(&bond->lock);
1663
1664 if (swap_slave) { 1668 if (swap_slave) {
1665 alb_fasten_mac_swap(bond, swap_slave, new_slave); 1669 alb_fasten_mac_swap(bond, swap_slave, new_slave);
1670 read_lock(&bond->lock);
1666 } else { 1671 } else {
1667 /* fasten bond mac on new current slave */ 1672 read_lock(&bond->lock);
1668 alb_send_learning_packets(new_slave, bond->dev->dev_addr); 1673 alb_send_learning_packets(new_slave, bond->dev->dev_addr);
1669 } 1674 }
1670 1675
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b0b26036266b..49a198206e3d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1746,7 +1746,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1746 * has been cleared (if our_slave == old_current), 1746 * has been cleared (if our_slave == old_current),
1747 * but before a new active slave is selected. 1747 * but before a new active slave is selected.
1748 */ 1748 */
1749 write_unlock_bh(&bond->lock);
1749 bond_alb_deinit_slave(bond, slave); 1750 bond_alb_deinit_slave(bond, slave);
1751 write_lock_bh(&bond->lock);
1750 } 1752 }
1751 1753
1752 if (oldcurrent == slave) { 1754 if (oldcurrent == slave) {
@@ -1905,6 +1907,12 @@ static int bond_release_all(struct net_device *bond_dev)
1905 slave_dev = slave->dev; 1907 slave_dev = slave->dev;
1906 bond_detach_slave(bond, slave); 1908 bond_detach_slave(bond, slave);
1907 1909
1910 /* now that the slave is detached, unlock and perform
1911 * all the undo steps that should not be called from
1912 * within a lock.
1913 */
1914 write_unlock_bh(&bond->lock);
1915
1908 if ((bond->params.mode == BOND_MODE_TLB) || 1916 if ((bond->params.mode == BOND_MODE_TLB) ||
1909 (bond->params.mode == BOND_MODE_ALB)) { 1917 (bond->params.mode == BOND_MODE_ALB)) {
1910 /* must be called only after the slave 1918 /* must be called only after the slave
@@ -1915,12 +1923,6 @@ static int bond_release_all(struct net_device *bond_dev)
1915 1923
1916 bond_compute_features(bond); 1924 bond_compute_features(bond);
1917 1925
1918 /* now that the slave is detached, unlock and perform
1919 * all the undo steps that should not be called from
1920 * within a lock.
1921 */
1922 write_unlock_bh(&bond->lock);
1923
1924 bond_destroy_slave_symlinks(bond_dev, slave_dev); 1926 bond_destroy_slave_symlinks(bond_dev, slave_dev);
1925 bond_del_vlans_from_slave(bond, slave_dev); 1927 bond_del_vlans_from_slave(bond, slave_dev);
1926 1928
@@ -2384,7 +2386,9 @@ void bond_mii_monitor(struct work_struct *work)
2384 rtnl_lock(); 2386 rtnl_lock();
2385 read_lock(&bond->lock); 2387 read_lock(&bond->lock);
2386 __bond_mii_monitor(bond, 1); 2388 __bond_mii_monitor(bond, 1);
2387 rtnl_unlock(); 2389 read_unlock(&bond->lock);
2390 rtnl_unlock(); /* might sleep, hold no other locks */
2391 read_lock(&bond->lock);
2388 } 2392 }
2389 2393
2390 delay = ((bond->params.miimon * HZ) / 1000) ? : 1; 2394 delay = ((bond->params.miimon * HZ) / 1000) ? : 1;
@@ -3399,9 +3403,7 @@ static int bond_master_netdev_event(unsigned long event, struct net_device *bond
3399 case NETDEV_CHANGENAME: 3403 case NETDEV_CHANGENAME:
3400 return bond_event_changename(event_bond); 3404 return bond_event_changename(event_bond);
3401 case NETDEV_UNREGISTER: 3405 case NETDEV_UNREGISTER:
3402 /* 3406 bond_release_all(event_bond->dev);
3403 * TODO: remove a bond from the list?
3404 */
3405 break; 3407 break;
3406 default: 3408 default:
3407 break; 3409 break;
@@ -4540,18 +4542,27 @@ static void bond_free_all(void)
4540 4542
4541/* 4543/*
4542 * Convert string input module parms. Accept either the 4544 * Convert string input module parms. Accept either the
4543 * number of the mode or its string name. 4545 * number of the mode or its string name. A bit complicated because
4546 * some mode names are substrings of other names, and calls from sysfs
4547 * may have whitespace in the name (trailing newlines, for example).
4544 */ 4548 */
4545int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) 4549int bond_parse_parm(const char *buf, struct bond_parm_tbl *tbl)
4546{ 4550{
4547 int i; 4551 int mode = -1, i, rv;
4552 char modestr[BOND_MAX_MODENAME_LEN + 1] = { 0, };
4553
4554 rv = sscanf(buf, "%d", &mode);
4555 if (!rv) {
4556 rv = sscanf(buf, "%20s", modestr);
4557 if (!rv)
4558 return -1;
4559 }
4548 4560
4549 for (i = 0; tbl[i].modename; i++) { 4561 for (i = 0; tbl[i].modename; i++) {
4550 if ((isdigit(*mode_arg) && 4562 if (mode == tbl[i].mode)
4551 tbl[i].mode == simple_strtol(mode_arg, NULL, 0)) || 4563 return tbl[i].mode;
4552 (strcmp(mode_arg, tbl[i].modename) == 0)) { 4564 if (strcmp(modestr, tbl[i].modename) == 0)
4553 return tbl[i].mode; 4565 return tbl[i].mode;
4554 }
4555 } 4566 }
4556 4567
4557 return -1; 4568 return -1;
@@ -4865,9 +4876,22 @@ static struct lock_class_key bonding_netdev_xmit_lock_key;
4865int bond_create(char *name, struct bond_params *params, struct bonding **newbond) 4876int bond_create(char *name, struct bond_params *params, struct bonding **newbond)
4866{ 4877{
4867 struct net_device *bond_dev; 4878 struct net_device *bond_dev;
4879 struct bonding *bond, *nxt;
4868 int res; 4880 int res;
4869 4881
4870 rtnl_lock(); 4882 rtnl_lock();
4883 down_write(&bonding_rwsem);
4884
4885 /* Check to see if the bond already exists. */
4886 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list)
4887 if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) {
4888 printk(KERN_ERR DRV_NAME
4889 ": cannot add bond %s; it already exists\n",
4890 name);
4891 res = -EPERM;
4892 goto out_rtnl;
4893 }
4894
4871 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "", 4895 bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "",
4872 ether_setup); 4896 ether_setup);
4873 if (!bond_dev) { 4897 if (!bond_dev) {
@@ -4906,10 +4930,12 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
4906 4930
4907 netif_carrier_off(bond_dev); 4931 netif_carrier_off(bond_dev);
4908 4932
4933 up_write(&bonding_rwsem);
4909 rtnl_unlock(); /* allows sysfs registration of net device */ 4934 rtnl_unlock(); /* allows sysfs registration of net device */
4910 res = bond_create_sysfs_entry(bond_dev->priv); 4935 res = bond_create_sysfs_entry(bond_dev->priv);
4911 if (res < 0) { 4936 if (res < 0) {
4912 rtnl_lock(); 4937 rtnl_lock();
4938 down_write(&bonding_rwsem);
4913 goto out_bond; 4939 goto out_bond;
4914 } 4940 }
4915 4941
@@ -4920,6 +4946,7 @@ out_bond:
4920out_netdev: 4946out_netdev:
4921 free_netdev(bond_dev); 4947 free_netdev(bond_dev);
4922out_rtnl: 4948out_rtnl:
4949 up_write(&bonding_rwsem);
4923 rtnl_unlock(); 4950 rtnl_unlock();
4924 return res; 4951 return res;
4925} 4952}
@@ -4940,6 +4967,9 @@ static int __init bonding_init(void)
4940#ifdef CONFIG_PROC_FS 4967#ifdef CONFIG_PROC_FS
4941 bond_create_proc_dir(); 4968 bond_create_proc_dir();
4942#endif 4969#endif
4970
4971 init_rwsem(&bonding_rwsem);
4972
4943 for (i = 0; i < max_bonds; i++) { 4973 for (i = 0; i < max_bonds; i++) {
4944 res = bond_create(NULL, &bonding_defaults, NULL); 4974 res = bond_create(NULL, &bonding_defaults, NULL);
4945 if (res) 4975 if (res)
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 11b76b352415..90a1f31e8e63 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -109,11 +109,10 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
109{ 109{
110 char command[IFNAMSIZ + 1] = {0, }; 110 char command[IFNAMSIZ + 1] = {0, };
111 char *ifname; 111 char *ifname;
112 int res = count; 112 int rv, res = count;
113 struct bonding *bond; 113 struct bonding *bond;
114 struct bonding *nxt; 114 struct bonding *nxt;
115 115
116 down_write(&(bonding_rwsem));
117 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ 116 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
118 ifname = command + 1; 117 ifname = command + 1;
119 if ((strlen(command) <= 1) || 118 if ((strlen(command) <= 1) ||
@@ -121,39 +120,28 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
121 goto err_no_cmd; 120 goto err_no_cmd;
122 121
123 if (command[0] == '+') { 122 if (command[0] == '+') {
124
125 /* Check to see if the bond already exists. */
126 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list)
127 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) {
128 printk(KERN_ERR DRV_NAME
129 ": cannot add bond %s; it already exists\n",
130 ifname);
131 res = -EPERM;
132 goto out;
133 }
134
135 printk(KERN_INFO DRV_NAME 123 printk(KERN_INFO DRV_NAME
136 ": %s is being created...\n", ifname); 124 ": %s is being created...\n", ifname);
137 if (bond_create(ifname, &bonding_defaults, &bond)) { 125 rv = bond_create(ifname, &bonding_defaults, &bond);
138 printk(KERN_INFO DRV_NAME 126 if (rv) {
139 ": %s interface already exists. Bond creation failed.\n", 127 printk(KERN_INFO DRV_NAME ": Bond creation failed.\n");
140 ifname); 128 res = rv;
141 res = -EPERM;
142 } 129 }
143 goto out; 130 goto out;
144 } 131 }
145 132
146 if (command[0] == '-') { 133 if (command[0] == '-') {
134 rtnl_lock();
135 down_write(&bonding_rwsem);
136
147 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) 137 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list)
148 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { 138 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) {
149 rtnl_lock();
150 /* check the ref count on the bond's kobject. 139 /* check the ref count on the bond's kobject.
151 * If it's > expected, then there's a file open, 140 * If it's > expected, then there's a file open,
152 * and we have to fail. 141 * and we have to fail.
153 */ 142 */
154 if (atomic_read(&bond->dev->dev.kobj.kref.refcount) 143 if (atomic_read(&bond->dev->dev.kobj.kref.refcount)
155 > expected_refcount){ 144 > expected_refcount){
156 rtnl_unlock();
157 printk(KERN_INFO DRV_NAME 145 printk(KERN_INFO DRV_NAME
158 ": Unable remove bond %s due to open references.\n", 146 ": Unable remove bond %s due to open references.\n",
159 ifname); 147 ifname);
@@ -164,6 +152,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
164 ": %s is being deleted...\n", 152 ": %s is being deleted...\n",
165 bond->dev->name); 153 bond->dev->name);
166 bond_destroy(bond); 154 bond_destroy(bond);
155 up_write(&bonding_rwsem);
167 rtnl_unlock(); 156 rtnl_unlock();
168 goto out; 157 goto out;
169 } 158 }
@@ -171,6 +160,8 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
171 printk(KERN_ERR DRV_NAME 160 printk(KERN_ERR DRV_NAME
172 ": unable to delete non-existent bond %s\n", ifname); 161 ": unable to delete non-existent bond %s\n", ifname);
173 res = -ENODEV; 162 res = -ENODEV;
163 up_write(&bonding_rwsem);
164 rtnl_unlock();
174 goto out; 165 goto out;
175 } 166 }
176 167
@@ -183,7 +174,6 @@ err_no_cmd:
183 * get called forever, which is bad. 174 * get called forever, which is bad.
184 */ 175 */
185out: 176out:
186 up_write(&(bonding_rwsem));
187 return res; 177 return res;
188} 178}
189/* class attribute for bond_masters file. This ends up in /sys/class/net */ 179/* class attribute for bond_masters file. This ends up in /sys/class/net */
@@ -271,6 +261,9 @@ static ssize_t bonding_store_slaves(struct device *d,
271 261
272 /* Note: We can't hold bond->lock here, as bond_create grabs it. */ 262 /* Note: We can't hold bond->lock here, as bond_create grabs it. */
273 263
264 rtnl_lock();
265 down_write(&(bonding_rwsem));
266
274 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ 267 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
275 ifname = command + 1; 268 ifname = command + 1;
276 if ((strlen(command) <= 1) || 269 if ((strlen(command) <= 1) ||
@@ -336,12 +329,10 @@ static ssize_t bonding_store_slaves(struct device *d,
336 dev->mtu = bond->dev->mtu; 329 dev->mtu = bond->dev->mtu;
337 } 330 }
338 } 331 }
339 rtnl_lock();
340 res = bond_enslave(bond->dev, dev); 332 res = bond_enslave(bond->dev, dev);
341 bond_for_each_slave(bond, slave, i) 333 bond_for_each_slave(bond, slave, i)
342 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) 334 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0)
343 slave->original_mtu = original_mtu; 335 slave->original_mtu = original_mtu;
344 rtnl_unlock();
345 if (res) { 336 if (res) {
346 ret = res; 337 ret = res;
347 } 338 }
@@ -359,12 +350,10 @@ static ssize_t bonding_store_slaves(struct device *d,
359 if (dev) { 350 if (dev) {
360 printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", 351 printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n",
361 bond->dev->name, dev->name); 352 bond->dev->name, dev->name);
362 rtnl_lock();
363 if (bond->setup_by_slave) 353 if (bond->setup_by_slave)
364 res = bond_release_and_destroy(bond->dev, dev); 354 res = bond_release_and_destroy(bond->dev, dev);
365 else 355 else
366 res = bond_release(bond->dev, dev); 356 res = bond_release(bond->dev, dev);
367 rtnl_unlock();
368 if (res) { 357 if (res) {
369 ret = res; 358 ret = res;
370 goto out; 359 goto out;
@@ -389,6 +378,8 @@ err_no_cmd:
389 ret = -EPERM; 378 ret = -EPERM;
390 379
391out: 380out:
381 up_write(&(bonding_rwsem));
382 rtnl_unlock();
392 return ret; 383 return ret;
393} 384}
394 385
@@ -423,7 +414,7 @@ static ssize_t bonding_store_mode(struct device *d,
423 goto out; 414 goto out;
424 } 415 }
425 416
426 new_value = bond_parse_parm((char *)buf, bond_mode_tbl); 417 new_value = bond_parse_parm(buf, bond_mode_tbl);
427 if (new_value < 0) { 418 if (new_value < 0) {
428 printk(KERN_ERR DRV_NAME 419 printk(KERN_ERR DRV_NAME
429 ": %s: Ignoring invalid mode value %.*s.\n", 420 ": %s: Ignoring invalid mode value %.*s.\n",
@@ -478,7 +469,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
478 goto out; 469 goto out;
479 } 470 }
480 471
481 new_value = bond_parse_parm((char *)buf, xmit_hashtype_tbl); 472 new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
482 if (new_value < 0) { 473 if (new_value < 0) {
483 printk(KERN_ERR DRV_NAME 474 printk(KERN_ERR DRV_NAME
484 ": %s: Ignoring invalid xmit hash policy value %.*s.\n", 475 ": %s: Ignoring invalid xmit hash policy value %.*s.\n",
@@ -518,7 +509,7 @@ static ssize_t bonding_store_arp_validate(struct device *d,
518 int new_value; 509 int new_value;
519 struct bonding *bond = to_bond(d); 510 struct bonding *bond = to_bond(d);
520 511
521 new_value = bond_parse_parm((char *)buf, arp_validate_tbl); 512 new_value = bond_parse_parm(buf, arp_validate_tbl);
522 if (new_value < 0) { 513 if (new_value < 0) {
523 printk(KERN_ERR DRV_NAME 514 printk(KERN_ERR DRV_NAME
524 ": %s: Ignoring invalid arp_validate value %s\n", 515 ": %s: Ignoring invalid arp_validate value %s\n",
@@ -941,7 +932,7 @@ static ssize_t bonding_store_lacp(struct device *d,
941 goto out; 932 goto out;
942 } 933 }
943 934
944 new_value = bond_parse_parm((char *)buf, bond_lacp_tbl); 935 new_value = bond_parse_parm(buf, bond_lacp_tbl);
945 936
946 if ((new_value == 1) || (new_value == 0)) { 937 if ((new_value == 1) || (new_value == 0)) {
947 bond->params.lacp_fast = new_value; 938 bond->params.lacp_fast = new_value;
@@ -1075,7 +1066,10 @@ static ssize_t bonding_store_primary(struct device *d,
1075 struct slave *slave; 1066 struct slave *slave;
1076 struct bonding *bond = to_bond(d); 1067 struct bonding *bond = to_bond(d);
1077 1068
1078 write_lock_bh(&bond->lock); 1069 rtnl_lock();
1070 read_lock(&bond->lock);
1071 write_lock_bh(&bond->curr_slave_lock);
1072
1079 if (!USES_PRIMARY(bond->params.mode)) { 1073 if (!USES_PRIMARY(bond->params.mode)) {
1080 printk(KERN_INFO DRV_NAME 1074 printk(KERN_INFO DRV_NAME
1081 ": %s: Unable to set primary slave; %s is in mode %d\n", 1075 ": %s: Unable to set primary slave; %s is in mode %d\n",
@@ -1109,8 +1103,8 @@ static ssize_t bonding_store_primary(struct device *d,
1109 } 1103 }
1110 } 1104 }
1111out: 1105out:
1112 write_unlock_bh(&bond->lock); 1106 write_unlock_bh(&bond->curr_slave_lock);
1113 1107 read_unlock(&bond->lock);
1114 rtnl_unlock(); 1108 rtnl_unlock();
1115 1109
1116 return count; 1110 return count;
@@ -1190,7 +1184,8 @@ static ssize_t bonding_store_active_slave(struct device *d,
1190 struct bonding *bond = to_bond(d); 1184 struct bonding *bond = to_bond(d);
1191 1185
1192 rtnl_lock(); 1186 rtnl_lock();
1193 write_lock_bh(&bond->lock); 1187 read_lock(&bond->lock);
1188 write_lock_bh(&bond->curr_slave_lock);
1194 1189
1195 if (!USES_PRIMARY(bond->params.mode)) { 1190 if (!USES_PRIMARY(bond->params.mode)) {
1196 printk(KERN_INFO DRV_NAME 1191 printk(KERN_INFO DRV_NAME
@@ -1247,7 +1242,8 @@ static ssize_t bonding_store_active_slave(struct device *d,
1247 } 1242 }
1248 } 1243 }
1249out: 1244out:
1250 write_unlock_bh(&bond->lock); 1245 write_unlock_bh(&bond->curr_slave_lock);
1246 read_unlock(&bond->lock);
1251 rtnl_unlock(); 1247 rtnl_unlock();
1252 1248
1253 return count; 1249 return count;
@@ -1418,8 +1414,6 @@ int bond_create_sysfs(void)
1418 int ret = 0; 1414 int ret = 0;
1419 struct bonding *firstbond; 1415 struct bonding *firstbond;
1420 1416
1421 init_rwsem(&bonding_rwsem);
1422
1423 /* get the netdev class pointer */ 1417 /* get the netdev class pointer */
1424 firstbond = container_of(bond_dev_list.next, struct bonding, bond_list); 1418 firstbond = container_of(bond_dev_list.next, struct bonding, bond_list);
1425 if (!firstbond) 1419 if (!firstbond)
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index e1e4734e23ce..6d83be49899a 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -141,6 +141,8 @@ struct bond_parm_tbl {
141 int mode; 141 int mode;
142}; 142};
143 143
144#define BOND_MAX_MODENAME_LEN 20
145
144struct vlan_entry { 146struct vlan_entry {
145 struct list_head vlan_list; 147 struct list_head vlan_list;
146 __be32 vlan_ip; 148 __be32 vlan_ip;
@@ -314,7 +316,7 @@ void bond_mii_monitor(struct work_struct *);
314void bond_loadbalance_arp_mon(struct work_struct *); 316void bond_loadbalance_arp_mon(struct work_struct *);
315void bond_activebackup_arp_mon(struct work_struct *); 317void bond_activebackup_arp_mon(struct work_struct *);
316void bond_set_mode_ops(struct bonding *bond, int mode); 318void bond_set_mode_ops(struct bonding *bond, int mode);
317int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl); 319int bond_parse_parm(const char *mode_arg, struct bond_parm_tbl *tbl);
318void bond_select_active_slave(struct bonding *bond); 320void bond_select_active_slave(struct bonding *bond);
319void bond_change_active_slave(struct bonding *bond, struct slave *new_active); 321void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
320void bond_register_arp(struct bonding *); 322void bond_register_arp(struct bonding *);
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 6fd95a2c8cec..6e12d48351b8 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -459,7 +459,7 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev)
459 return NETDEV_TX_OK; 459 return NETDEV_TX_OK;
460 460
461 len = max(skb->len, ETH_ZLEN); 461 len = max(skb->len, ETH_ZLEN);
462 queue = skb->queue_mapping; 462 queue = skb_get_queue_mapping(skb);
463#ifdef CONFIG_NETDEVICES_MULTIQUEUE 463#ifdef CONFIG_NETDEVICES_MULTIQUEUE
464 netif_stop_subqueue(dev, queue); 464 netif_stop_subqueue(dev, queue);
465#else 465#else
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index 47cce9cad30f..e233d04a2132 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -1316,9 +1316,10 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1316 ("%02x:cur:%08x next:%08x status:%08x frag1:%08x frag0:%08x", 1316 ("%02x:cur:%08x next:%08x status:%08x frag1:%08x frag0:%08x",
1317 i, 1317 i,
1318 (u32) (np->tx_ring_dma + i * sizeof (*desc)), 1318 (u32) (np->tx_ring_dma + i * sizeof (*desc)),
1319 (u32) desc->next_desc, 1319 (u32)le64_to_cpu(desc->next_desc),
1320 (u32) desc->status, (u32) (desc->fraginfo >> 32), 1320 (u32)le64_to_cpu(desc->status),
1321 (u32) desc->fraginfo); 1321 (u32)(le64_to_cpu(desc->fraginfo) >> 32),
1322 (u32)le64_to_cpu(desc->fraginfo));
1322 printk ("\n"); 1323 printk ("\n");
1323 } 1324 }
1324 printk ("\n"); 1325 printk ("\n");
@@ -1435,7 +1436,7 @@ mii_write (struct net_device *dev, int phy_addr, int reg_num, u16 data)
1435static int 1436static int
1436mii_wait_link (struct net_device *dev, int wait) 1437mii_wait_link (struct net_device *dev, int wait)
1437{ 1438{
1438 BMSR_t bmsr; 1439 __u16 bmsr;
1439 int phy_addr; 1440 int phy_addr;
1440 struct netdev_private *np; 1441 struct netdev_private *np;
1441 1442
@@ -1443,8 +1444,8 @@ mii_wait_link (struct net_device *dev, int wait)
1443 phy_addr = np->phy_addr; 1444 phy_addr = np->phy_addr;
1444 1445
1445 do { 1446 do {
1446 bmsr.image = mii_read (dev, phy_addr, MII_BMSR); 1447 bmsr = mii_read (dev, phy_addr, MII_BMSR);
1447 if (bmsr.bits.link_status) 1448 if (bmsr & MII_BMSR_LINK_STATUS)
1448 return 0; 1449 return 0;
1449 mdelay (1); 1450 mdelay (1);
1450 } while (--wait > 0); 1451 } while (--wait > 0);
@@ -1453,70 +1454,72 @@ mii_wait_link (struct net_device *dev, int wait)
1453static int 1454static int
1454mii_get_media (struct net_device *dev) 1455mii_get_media (struct net_device *dev)
1455{ 1456{
1456 ANAR_t negotiate; 1457 __u16 negotiate;
1457 BMSR_t bmsr; 1458 __u16 bmsr;
1458 BMCR_t bmcr; 1459 __u16 mscr;
1459 MSCR_t mscr; 1460 __u16 mssr;
1460 MSSR_t mssr;
1461 int phy_addr; 1461 int phy_addr;
1462 struct netdev_private *np; 1462 struct netdev_private *np;
1463 1463
1464 np = netdev_priv(dev); 1464 np = netdev_priv(dev);
1465 phy_addr = np->phy_addr; 1465 phy_addr = np->phy_addr;
1466 1466
1467 bmsr.image = mii_read (dev, phy_addr, MII_BMSR); 1467 bmsr = mii_read (dev, phy_addr, MII_BMSR);
1468 if (np->an_enable) { 1468 if (np->an_enable) {
1469 if (!bmsr.bits.an_complete) { 1469 if (!(bmsr & MII_BMSR_AN_COMPLETE)) {
1470 /* Auto-Negotiation not completed */ 1470 /* Auto-Negotiation not completed */
1471 return -1; 1471 return -1;
1472 } 1472 }
1473 negotiate.image = mii_read (dev, phy_addr, MII_ANAR) & 1473 negotiate = mii_read (dev, phy_addr, MII_ANAR) &
1474 mii_read (dev, phy_addr, MII_ANLPAR); 1474 mii_read (dev, phy_addr, MII_ANLPAR);
1475 mscr.image = mii_read (dev, phy_addr, MII_MSCR); 1475 mscr = mii_read (dev, phy_addr, MII_MSCR);
1476 mssr.image = mii_read (dev, phy_addr, MII_MSSR); 1476 mssr = mii_read (dev, phy_addr, MII_MSSR);
1477 if (mscr.bits.media_1000BT_FD & mssr.bits.lp_1000BT_FD) { 1477 if (mscr & MII_MSCR_1000BT_FD && mssr & MII_MSSR_LP_1000BT_FD) {
1478 np->speed = 1000; 1478 np->speed = 1000;
1479 np->full_duplex = 1; 1479 np->full_duplex = 1;
1480 printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); 1480 printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n");
1481 } else if (mscr.bits.media_1000BT_HD & mssr.bits.lp_1000BT_HD) { 1481 } else if (mscr & MII_MSCR_1000BT_HD && mssr & MII_MSSR_LP_1000BT_HD) {
1482 np->speed = 1000; 1482 np->speed = 1000;
1483 np->full_duplex = 0; 1483 np->full_duplex = 0;
1484 printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n"); 1484 printk (KERN_INFO "Auto 1000 Mbps, Half duplex\n");
1485 } else if (negotiate.bits.media_100BX_FD) { 1485 } else if (negotiate & MII_ANAR_100BX_FD) {
1486 np->speed = 100; 1486 np->speed = 100;
1487 np->full_duplex = 1; 1487 np->full_duplex = 1;
1488 printk (KERN_INFO "Auto 100 Mbps, Full duplex\n"); 1488 printk (KERN_INFO "Auto 100 Mbps, Full duplex\n");
1489 } else if (negotiate.bits.media_100BX_HD) { 1489 } else if (negotiate & MII_ANAR_100BX_HD) {
1490 np->speed = 100; 1490 np->speed = 100;
1491 np->full_duplex = 0; 1491 np->full_duplex = 0;
1492 printk (KERN_INFO "Auto 100 Mbps, Half duplex\n"); 1492 printk (KERN_INFO "Auto 100 Mbps, Half duplex\n");
1493 } else if (negotiate.bits.media_10BT_FD) { 1493 } else if (negotiate & MII_ANAR_10BT_FD) {
1494 np->speed = 10; 1494 np->speed = 10;
1495 np->full_duplex = 1; 1495 np->full_duplex = 1;
1496 printk (KERN_INFO "Auto 10 Mbps, Full duplex\n"); 1496 printk (KERN_INFO "Auto 10 Mbps, Full duplex\n");
1497 } else if (negotiate.bits.media_10BT_HD) { 1497 } else if (negotiate & MII_ANAR_10BT_HD) {
1498 np->speed = 10; 1498 np->speed = 10;
1499 np->full_duplex = 0; 1499 np->full_duplex = 0;
1500 printk (KERN_INFO "Auto 10 Mbps, Half duplex\n"); 1500 printk (KERN_INFO "Auto 10 Mbps, Half duplex\n");
1501 } 1501 }
1502 if (negotiate.bits.pause) { 1502 if (negotiate & MII_ANAR_PAUSE) {
1503 np->tx_flow &= 1; 1503 np->tx_flow &= 1;
1504 np->rx_flow &= 1; 1504 np->rx_flow &= 1;
1505 } else if (negotiate.bits.asymmetric) { 1505 } else if (negotiate & MII_ANAR_ASYMMETRIC) {
1506 np->tx_flow = 0; 1506 np->tx_flow = 0;
1507 np->rx_flow &= 1; 1507 np->rx_flow &= 1;
1508 } 1508 }
1509 /* else tx_flow, rx_flow = user select */ 1509 /* else tx_flow, rx_flow = user select */
1510 } else { 1510 } else {
1511 bmcr.image = mii_read (dev, phy_addr, MII_BMCR); 1511 __u16 bmcr = mii_read (dev, phy_addr, MII_BMCR);
1512 if (bmcr.bits.speed100 == 1 && bmcr.bits.speed1000 == 0) { 1512 switch (bmcr & (MII_BMCR_SPEED_100 | MII_BMCR_SPEED_1000)) {
1513 case MII_BMCR_SPEED_1000:
1514 printk (KERN_INFO "Operating at 1000 Mbps, ");
1515 break;
1516 case MII_BMCR_SPEED_100:
1513 printk (KERN_INFO "Operating at 100 Mbps, "); 1517 printk (KERN_INFO "Operating at 100 Mbps, ");
1514 } else if (bmcr.bits.speed100 == 0 && bmcr.bits.speed1000 == 0) { 1518 break;
1519 case 0:
1515 printk (KERN_INFO "Operating at 10 Mbps, "); 1520 printk (KERN_INFO "Operating at 10 Mbps, ");
1516 } else if (bmcr.bits.speed100 == 0 && bmcr.bits.speed1000 == 1) {
1517 printk (KERN_INFO "Operating at 1000 Mbps, ");
1518 } 1521 }
1519 if (bmcr.bits.duplex_mode) { 1522 if (bmcr & MII_BMCR_DUPLEX_MODE) {
1520 printk ("Full duplex\n"); 1523 printk ("Full duplex\n");
1521 } else { 1524 } else {
1522 printk ("Half duplex\n"); 1525 printk ("Half duplex\n");
@@ -1537,10 +1540,10 @@ mii_get_media (struct net_device *dev)
1537static int 1540static int
1538mii_set_media (struct net_device *dev) 1541mii_set_media (struct net_device *dev)
1539{ 1542{
1540 PHY_SCR_t pscr; 1543 __u16 pscr;
1541 BMCR_t bmcr; 1544 __u16 bmcr;
1542 BMSR_t bmsr; 1545 __u16 bmsr;
1543 ANAR_t anar; 1546 __u16 anar;
1544 int phy_addr; 1547 int phy_addr;
1545 struct netdev_private *np; 1548 struct netdev_private *np;
1546 np = netdev_priv(dev); 1549 np = netdev_priv(dev);
@@ -1549,76 +1552,77 @@ mii_set_media (struct net_device *dev)
1549 /* Does user set speed? */ 1552 /* Does user set speed? */
1550 if (np->an_enable) { 1553 if (np->an_enable) {
1551 /* Advertise capabilities */ 1554 /* Advertise capabilities */
1552 bmsr.image = mii_read (dev, phy_addr, MII_BMSR); 1555 bmsr = mii_read (dev, phy_addr, MII_BMSR);
1553 anar.image = mii_read (dev, phy_addr, MII_ANAR); 1556 anar = mii_read (dev, phy_addr, MII_ANAR) &
1554 anar.bits.media_100BX_FD = bmsr.bits.media_100BX_FD; 1557 ~MII_ANAR_100BX_FD &
1555 anar.bits.media_100BX_HD = bmsr.bits.media_100BX_HD; 1558 ~MII_ANAR_100BX_HD &
1556 anar.bits.media_100BT4 = bmsr.bits.media_100BT4; 1559 ~MII_ANAR_100BT4 &
1557 anar.bits.media_10BT_FD = bmsr.bits.media_10BT_FD; 1560 ~MII_ANAR_10BT_FD &
1558 anar.bits.media_10BT_HD = bmsr.bits.media_10BT_HD; 1561 ~MII_ANAR_10BT_HD;
1559 anar.bits.pause = 1; 1562 if (bmsr & MII_BMSR_100BX_FD)
1560 anar.bits.asymmetric = 1; 1563 anar |= MII_ANAR_100BX_FD;
1561 mii_write (dev, phy_addr, MII_ANAR, anar.image); 1564 if (bmsr & MII_BMSR_100BX_HD)
1565 anar |= MII_ANAR_100BX_HD;
1566 if (bmsr & MII_BMSR_100BT4)
1567 anar |= MII_ANAR_100BT4;
1568 if (bmsr & MII_BMSR_10BT_FD)
1569 anar |= MII_ANAR_10BT_FD;
1570 if (bmsr & MII_BMSR_10BT_HD)
1571 anar |= MII_ANAR_10BT_HD;
1572 anar |= MII_ANAR_PAUSE | MII_ANAR_ASYMMETRIC;
1573 mii_write (dev, phy_addr, MII_ANAR, anar);
1562 1574
1563 /* Enable Auto crossover */ 1575 /* Enable Auto crossover */
1564 pscr.image = mii_read (dev, phy_addr, MII_PHY_SCR); 1576 pscr = mii_read (dev, phy_addr, MII_PHY_SCR);
1565 pscr.bits.mdi_crossover_mode = 3; /* 11'b */ 1577 pscr |= 3 << 5; /* 11'b */
1566 mii_write (dev, phy_addr, MII_PHY_SCR, pscr.image); 1578 mii_write (dev, phy_addr, MII_PHY_SCR, pscr);
1567 1579
1568 /* Soft reset PHY */ 1580 /* Soft reset PHY */
1569 mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET); 1581 mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET);
1570 bmcr.image = 0; 1582 bmcr = MII_BMCR_AN_ENABLE | MII_BMCR_RESTART_AN | MII_BMCR_RESET;
1571 bmcr.bits.an_enable = 1; 1583 mii_write (dev, phy_addr, MII_BMCR, bmcr);
1572 bmcr.bits.restart_an = 1;
1573 bmcr.bits.reset = 1;
1574 mii_write (dev, phy_addr, MII_BMCR, bmcr.image);
1575 mdelay(1); 1584 mdelay(1);
1576 } else { 1585 } else {
1577 /* Force speed setting */ 1586 /* Force speed setting */
1578 /* 1) Disable Auto crossover */ 1587 /* 1) Disable Auto crossover */
1579 pscr.image = mii_read (dev, phy_addr, MII_PHY_SCR); 1588 pscr = mii_read (dev, phy_addr, MII_PHY_SCR);
1580 pscr.bits.mdi_crossover_mode = 0; 1589 pscr &= ~(3 << 5);
1581 mii_write (dev, phy_addr, MII_PHY_SCR, pscr.image); 1590 mii_write (dev, phy_addr, MII_PHY_SCR, pscr);
1582 1591
1583 /* 2) PHY Reset */ 1592 /* 2) PHY Reset */
1584 bmcr.image = mii_read (dev, phy_addr, MII_BMCR); 1593 bmcr = mii_read (dev, phy_addr, MII_BMCR);
1585 bmcr.bits.reset = 1; 1594 bmcr |= MII_BMCR_RESET;
1586 mii_write (dev, phy_addr, MII_BMCR, bmcr.image); 1595 mii_write (dev, phy_addr, MII_BMCR, bmcr);
1587 1596
1588 /* 3) Power Down */ 1597 /* 3) Power Down */
1589 bmcr.image = 0x1940; /* must be 0x1940 */ 1598 bmcr = 0x1940; /* must be 0x1940 */
1590 mii_write (dev, phy_addr, MII_BMCR, bmcr.image); 1599 mii_write (dev, phy_addr, MII_BMCR, bmcr);
1591 mdelay (100); /* wait a certain time */ 1600 mdelay (100); /* wait a certain time */
1592 1601
1593 /* 4) Advertise nothing */ 1602 /* 4) Advertise nothing */
1594 mii_write (dev, phy_addr, MII_ANAR, 0); 1603 mii_write (dev, phy_addr, MII_ANAR, 0);
1595 1604
1596 /* 5) Set media and Power Up */ 1605 /* 5) Set media and Power Up */
1597 bmcr.image = 0; 1606 bmcr = MII_BMCR_POWER_DOWN;
1598 bmcr.bits.power_down = 1;
1599 if (np->speed == 100) { 1607 if (np->speed == 100) {
1600 bmcr.bits.speed100 = 1; 1608 bmcr |= MII_BMCR_SPEED_100;
1601 bmcr.bits.speed1000 = 0;
1602 printk (KERN_INFO "Manual 100 Mbps, "); 1609 printk (KERN_INFO "Manual 100 Mbps, ");
1603 } else if (np->speed == 10) { 1610 } else if (np->speed == 10) {
1604 bmcr.bits.speed100 = 0;
1605 bmcr.bits.speed1000 = 0;
1606 printk (KERN_INFO "Manual 10 Mbps, "); 1611 printk (KERN_INFO "Manual 10 Mbps, ");
1607 } 1612 }
1608 if (np->full_duplex) { 1613 if (np->full_duplex) {
1609 bmcr.bits.duplex_mode = 1; 1614 bmcr |= MII_BMCR_DUPLEX_MODE;
1610 printk ("Full duplex\n"); 1615 printk ("Full duplex\n");
1611 } else { 1616 } else {
1612 bmcr.bits.duplex_mode = 0;
1613 printk ("Half duplex\n"); 1617 printk ("Half duplex\n");
1614 } 1618 }
1615#if 0 1619#if 0
1616 /* Set 1000BaseT Master/Slave setting */ 1620 /* Set 1000BaseT Master/Slave setting */
1617 mscr.image = mii_read (dev, phy_addr, MII_MSCR); 1621 mscr = mii_read (dev, phy_addr, MII_MSCR);
1618 mscr.bits.cfg_enable = 1; 1622 mscr |= MII_MSCR_CFG_ENABLE;
1619 mscr.bits.cfg_value = 0; 1623 mscr &= ~MII_MSCR_CFG_VALUE = 0;
1620#endif 1624#endif
1621 mii_write (dev, phy_addr, MII_BMCR, bmcr.image); 1625 mii_write (dev, phy_addr, MII_BMCR, bmcr);
1622 mdelay(10); 1626 mdelay(10);
1623 } 1627 }
1624 return 0; 1628 return 0;
@@ -1627,43 +1631,42 @@ mii_set_media (struct net_device *dev)
1627static int 1631static int
1628mii_get_media_pcs (struct net_device *dev) 1632mii_get_media_pcs (struct net_device *dev)
1629{ 1633{
1630 ANAR_PCS_t negotiate; 1634 __u16 negotiate;
1631 BMSR_t bmsr; 1635 __u16 bmsr;
1632 BMCR_t bmcr;
1633 int phy_addr; 1636 int phy_addr;
1634 struct netdev_private *np; 1637 struct netdev_private *np;
1635 1638
1636 np = netdev_priv(dev); 1639 np = netdev_priv(dev);
1637 phy_addr = np->phy_addr; 1640 phy_addr = np->phy_addr;
1638 1641
1639 bmsr.image = mii_read (dev, phy_addr, PCS_BMSR); 1642 bmsr = mii_read (dev, phy_addr, PCS_BMSR);
1640 if (np->an_enable) { 1643 if (np->an_enable) {
1641 if (!bmsr.bits.an_complete) { 1644 if (!(bmsr & MII_BMSR_AN_COMPLETE)) {
1642 /* Auto-Negotiation not completed */ 1645 /* Auto-Negotiation not completed */
1643 return -1; 1646 return -1;
1644 } 1647 }
1645 negotiate.image = mii_read (dev, phy_addr, PCS_ANAR) & 1648 negotiate = mii_read (dev, phy_addr, PCS_ANAR) &
1646 mii_read (dev, phy_addr, PCS_ANLPAR); 1649 mii_read (dev, phy_addr, PCS_ANLPAR);
1647 np->speed = 1000; 1650 np->speed = 1000;
1648 if (negotiate.bits.full_duplex) { 1651 if (negotiate & PCS_ANAR_FULL_DUPLEX) {
1649 printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n"); 1652 printk (KERN_INFO "Auto 1000 Mbps, Full duplex\n");
1650 np->full_duplex = 1; 1653 np->full_duplex = 1;
1651 } else { 1654 } else {
1652 printk (KERN_INFO "Auto 1000 Mbps, half duplex\n"); 1655 printk (KERN_INFO "Auto 1000 Mbps, half duplex\n");
1653 np->full_duplex = 0; 1656 np->full_duplex = 0;
1654 } 1657 }
1655 if (negotiate.bits.pause) { 1658 if (negotiate & PCS_ANAR_PAUSE) {
1656 np->tx_flow &= 1; 1659 np->tx_flow &= 1;
1657 np->rx_flow &= 1; 1660 np->rx_flow &= 1;
1658 } else if (negotiate.bits.asymmetric) { 1661 } else if (negotiate & PCS_ANAR_ASYMMETRIC) {
1659 np->tx_flow = 0; 1662 np->tx_flow = 0;
1660 np->rx_flow &= 1; 1663 np->rx_flow &= 1;
1661 } 1664 }
1662 /* else tx_flow, rx_flow = user select */ 1665 /* else tx_flow, rx_flow = user select */
1663 } else { 1666 } else {
1664 bmcr.image = mii_read (dev, phy_addr, PCS_BMCR); 1667 __u16 bmcr = mii_read (dev, phy_addr, PCS_BMCR);
1665 printk (KERN_INFO "Operating at 1000 Mbps, "); 1668 printk (KERN_INFO "Operating at 1000 Mbps, ");
1666 if (bmcr.bits.duplex_mode) { 1669 if (bmcr & MII_BMCR_DUPLEX_MODE) {
1667 printk ("Full duplex\n"); 1670 printk ("Full duplex\n");
1668 } else { 1671 } else {
1669 printk ("Half duplex\n"); 1672 printk ("Half duplex\n");
@@ -1684,9 +1687,9 @@ mii_get_media_pcs (struct net_device *dev)
1684static int 1687static int
1685mii_set_media_pcs (struct net_device *dev) 1688mii_set_media_pcs (struct net_device *dev)
1686{ 1689{
1687 BMCR_t bmcr; 1690 __u16 bmcr;
1688 ESR_t esr; 1691 __u16 esr;
1689 ANAR_PCS_t anar; 1692 __u16 anar;
1690 int phy_addr; 1693 int phy_addr;
1691 struct netdev_private *np; 1694 struct netdev_private *np;
1692 np = netdev_priv(dev); 1695 np = netdev_priv(dev);
@@ -1695,41 +1698,37 @@ mii_set_media_pcs (struct net_device *dev)
1695 /* Auto-Negotiation? */ 1698 /* Auto-Negotiation? */
1696 if (np->an_enable) { 1699 if (np->an_enable) {
1697 /* Advertise capabilities */ 1700 /* Advertise capabilities */
1698 esr.image = mii_read (dev, phy_addr, PCS_ESR); 1701 esr = mii_read (dev, phy_addr, PCS_ESR);
1699 anar.image = mii_read (dev, phy_addr, MII_ANAR); 1702 anar = mii_read (dev, phy_addr, MII_ANAR) &
1700 anar.bits.half_duplex = 1703 ~PCS_ANAR_HALF_DUPLEX &
1701 esr.bits.media_1000BT_HD | esr.bits.media_1000BX_HD; 1704 ~PCS_ANAR_FULL_DUPLEX;
1702 anar.bits.full_duplex = 1705 if (esr & (MII_ESR_1000BT_HD | MII_ESR_1000BX_HD))
1703 esr.bits.media_1000BT_FD | esr.bits.media_1000BX_FD; 1706 anar |= PCS_ANAR_HALF_DUPLEX;
1704 anar.bits.pause = 1; 1707 if (esr & (MII_ESR_1000BT_FD | MII_ESR_1000BX_FD))
1705 anar.bits.asymmetric = 1; 1708 anar |= PCS_ANAR_FULL_DUPLEX;
1706 mii_write (dev, phy_addr, MII_ANAR, anar.image); 1709 anar |= PCS_ANAR_PAUSE | PCS_ANAR_ASYMMETRIC;
1710 mii_write (dev, phy_addr, MII_ANAR, anar);
1707 1711
1708 /* Soft reset PHY */ 1712 /* Soft reset PHY */
1709 mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET); 1713 mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET);
1710 bmcr.image = 0; 1714 bmcr = MII_BMCR_AN_ENABLE | MII_BMCR_RESTART_AN |
1711 bmcr.bits.an_enable = 1; 1715 MII_BMCR_RESET;
1712 bmcr.bits.restart_an = 1; 1716 mii_write (dev, phy_addr, MII_BMCR, bmcr);
1713 bmcr.bits.reset = 1;
1714 mii_write (dev, phy_addr, MII_BMCR, bmcr.image);
1715 mdelay(1); 1717 mdelay(1);
1716 } else { 1718 } else {
1717 /* Force speed setting */ 1719 /* Force speed setting */
1718 /* PHY Reset */ 1720 /* PHY Reset */
1719 bmcr.image = 0; 1721 bmcr = MII_BMCR_RESET;
1720 bmcr.bits.reset = 1; 1722 mii_write (dev, phy_addr, MII_BMCR, bmcr);
1721 mii_write (dev, phy_addr, MII_BMCR, bmcr.image);
1722 mdelay(10); 1723 mdelay(10);
1723 bmcr.image = 0;
1724 bmcr.bits.an_enable = 0;
1725 if (np->full_duplex) { 1724 if (np->full_duplex) {
1726 bmcr.bits.duplex_mode = 1; 1725 bmcr = MII_BMCR_DUPLEX_MODE;
1727 printk (KERN_INFO "Manual full duplex\n"); 1726 printk (KERN_INFO "Manual full duplex\n");
1728 } else { 1727 } else {
1729 bmcr.bits.duplex_mode = 0; 1728 bmcr = 0;
1730 printk (KERN_INFO "Manual half duplex\n"); 1729 printk (KERN_INFO "Manual half duplex\n");
1731 } 1730 }
1732 mii_write (dev, phy_addr, MII_BMCR, bmcr.image); 1731 mii_write (dev, phy_addr, MII_BMCR, bmcr);
1733 mdelay(10); 1732 mdelay(10);
1734 1733
1735 /* Advertise nothing */ 1734 /* Advertise nothing */
diff --git a/drivers/net/dl2k.h b/drivers/net/dl2k.h
index 014b77ce96df..d66c605b4075 100644
--- a/drivers/net/dl2k.h
+++ b/drivers/net/dl2k.h
@@ -298,23 +298,6 @@ enum _pcs_reg {
298}; 298};
299 299
300/* Basic Mode Control Register */ 300/* Basic Mode Control Register */
301typedef union t_MII_BMCR {
302 u16 image;
303 struct {
304 u16 _bit_5_0:6; // bit 5:0
305 u16 speed1000:1; // bit 6
306 u16 col_test_enable:1; // bit 7
307 u16 duplex_mode:1; // bit 8
308 u16 restart_an:1; // bit 9
309 u16 isolate:1; // bit 10
310 u16 power_down:1; // bit 11
311 u16 an_enable:1; // bit 12
312 u16 speed100:1; // bit 13
313 u16 loopback:1; // bit 14
314 u16 reset:1; // bit 15
315 } bits;
316} BMCR_t, *PBMCR_t;
317
318enum _mii_bmcr { 301enum _mii_bmcr {
319 MII_BMCR_RESET = 0x8000, 302 MII_BMCR_RESET = 0x8000,
320 MII_BMCR_LOOP_BACK = 0x4000, 303 MII_BMCR_LOOP_BACK = 0x4000,
@@ -333,28 +316,6 @@ enum _mii_bmcr {
333}; 316};
334 317
335/* Basic Mode Status Register */ 318/* Basic Mode Status Register */
336typedef union t_MII_BMSR {
337 u16 image;
338 struct {
339 u16 ext_capability:1; // bit 0
340 u16 japper_detect:1; // bit 1
341 u16 link_status:1; // bit 2
342 u16 an_ability:1; // bit 3
343 u16 remote_fault:1; // bit 4
344 u16 an_complete:1; // bit 5
345 u16 preamble_supp:1; // bit 6
346 u16 _bit_7:1; // bit 7
347 u16 ext_status:1; // bit 8
348 u16 media_100BT2_HD:1; // bit 9
349 u16 media_100BT2_FD:1; // bit 10
350 u16 media_10BT_HD:1; // bit 11
351 u16 media_10BT_FD:1; // bit 12
352 u16 media_100BX_HD:1; // bit 13
353 u16 media_100BX_FD:1; // bit 14
354 u16 media_100BT4:1; // bit 15
355 } bits;
356} BMSR_t, *PBMSR_t;
357
358enum _mii_bmsr { 319enum _mii_bmsr {
359 MII_BMSR_100BT4 = 0x8000, 320 MII_BMSR_100BT4 = 0x8000,
360 MII_BMSR_100BX_FD = 0x4000, 321 MII_BMSR_100BX_FD = 0x4000,
@@ -374,24 +335,6 @@ enum _mii_bmsr {
374}; 335};
375 336
376/* ANAR */ 337/* ANAR */
377typedef union t_MII_ANAR {
378 u16 image;
379 struct {
380 u16 selector:5; // bit 4:0
381 u16 media_10BT_HD:1; // bit 5
382 u16 media_10BT_FD:1; // bit 6
383 u16 media_100BX_HD:1; // bit 7
384 u16 media_100BX_FD:1; // bit 8
385 u16 media_100BT4:1; // bit 9
386 u16 pause:1; // bit 10
387 u16 asymmetric:1; // bit 11
388 u16 _bit12:1; // bit 12
389 u16 remote_fault:1; // bit 13
390 u16 _bit14:1; // bit 14
391 u16 next_page:1; // bit 15
392 } bits;
393} ANAR_t, *PANAR_t;
394
395enum _mii_anar { 338enum _mii_anar {
396 MII_ANAR_NEXT_PAGE = 0x8000, 339 MII_ANAR_NEXT_PAGE = 0x8000,
397 MII_ANAR_REMOTE_FAULT = 0x4000, 340 MII_ANAR_REMOTE_FAULT = 0x4000,
@@ -407,24 +350,6 @@ enum _mii_anar {
407}; 350};
408 351
409/* ANLPAR */ 352/* ANLPAR */
410typedef union t_MII_ANLPAR {
411 u16 image;
412 struct {
413 u16 selector:5; // bit 4:0
414 u16 media_10BT_HD:1; // bit 5
415 u16 media_10BT_FD:1; // bit 6
416 u16 media_100BX_HD:1; // bit 7
417 u16 media_100BX_FD:1; // bit 8
418 u16 media_100BT4:1; // bit 9
419 u16 pause:1; // bit 10
420 u16 asymmetric:1; // bit 11
421 u16 _bit12:1; // bit 12
422 u16 remote_fault:1; // bit 13
423 u16 _bit14:1; // bit 14
424 u16 next_page:1; // bit 15
425 } bits;
426} ANLPAR_t, *PANLPAR_t;
427
428enum _mii_anlpar { 353enum _mii_anlpar {
429 MII_ANLPAR_NEXT_PAGE = MII_ANAR_NEXT_PAGE, 354 MII_ANLPAR_NEXT_PAGE = MII_ANAR_NEXT_PAGE,
430 MII_ANLPAR_REMOTE_FAULT = MII_ANAR_REMOTE_FAULT, 355 MII_ANLPAR_REMOTE_FAULT = MII_ANAR_REMOTE_FAULT,
@@ -439,18 +364,6 @@ enum _mii_anlpar {
439}; 364};
440 365
441/* Auto-Negotiation Expansion Register */ 366/* Auto-Negotiation Expansion Register */
442typedef union t_MII_ANER {
443 u16 image;
444 struct {
445 u16 lp_negotiable:1; // bit 0
446 u16 page_received:1; // bit 1
447 u16 nextpagable:1; // bit 2
448 u16 lp_nextpagable:1; // bit 3
449 u16 pdetect_fault:1; // bit 4
450 u16 _bit15_5:11; // bit 15:5
451 } bits;
452} ANER_t, *PANER_t;
453
454enum _mii_aner { 367enum _mii_aner {
455 MII_ANER_PAR_DETECT_FAULT = 0x0010, 368 MII_ANER_PAR_DETECT_FAULT = 0x0010,
456 MII_ANER_LP_NEXTPAGABLE = 0x0008, 369 MII_ANER_LP_NEXTPAGABLE = 0x0008,
@@ -460,19 +373,6 @@ enum _mii_aner {
460}; 373};
461 374
462/* MASTER-SLAVE Control Register */ 375/* MASTER-SLAVE Control Register */
463typedef union t_MII_MSCR {
464 u16 image;
465 struct {
466 u16 _bit_7_0:8; // bit 7:0
467 u16 media_1000BT_HD:1; // bit 8
468 u16 media_1000BT_FD:1; // bit 9
469 u16 port_type:1; // bit 10
470 u16 cfg_value:1; // bit 11
471 u16 cfg_enable:1; // bit 12
472 u16 test_mode:3; // bit 15:13
473 } bits;
474} MSCR_t, *PMSCR_t;
475
476enum _mii_mscr { 376enum _mii_mscr {
477 MII_MSCR_TEST_MODE = 0xe000, 377 MII_MSCR_TEST_MODE = 0xe000,
478 MII_MSCR_CFG_ENABLE = 0x1000, 378 MII_MSCR_CFG_ENABLE = 0x1000,
@@ -483,20 +383,6 @@ enum _mii_mscr {
483}; 383};
484 384
485/* MASTER-SLAVE Status Register */ 385/* MASTER-SLAVE Status Register */
486typedef union t_MII_MSSR {
487 u16 image;
488 struct {
489 u16 idle_err_count:8; // bit 7:0
490 u16 _bit_9_8:2; // bit 9:8
491 u16 lp_1000BT_HD:1; // bit 10
492 u16 lp_1000BT_FD:1; // bit 11
493 u16 remote_rcv_status:1; // bit 12
494 u16 local_rcv_status:1; // bit 13
495 u16 cfg_resolution:1; // bit 14
496 u16 cfg_fault:1; // bit 15
497 } bits;
498} MSSR_t, *PMSSR_t;
499
500enum _mii_mssr { 386enum _mii_mssr {
501 MII_MSSR_CFG_FAULT = 0x8000, 387 MII_MSSR_CFG_FAULT = 0x8000,
502 MII_MSSR_CFG_RES = 0x4000, 388 MII_MSSR_CFG_RES = 0x4000,
@@ -508,17 +394,6 @@ enum _mii_mssr {
508}; 394};
509 395
510/* IEEE Extened Status Register */ 396/* IEEE Extened Status Register */
511typedef union t_MII_ESR {
512 u16 image;
513 struct {
514 u16 _bit_11_0:12; // bit 11:0
515 u16 media_1000BT_HD:2; // bit 12
516 u16 media_1000BT_FD:1; // bit 13
517 u16 media_1000BX_HD:1; // bit 14
518 u16 media_1000BX_FD:1; // bit 15
519 } bits;
520} ESR_t, *PESR_t;
521
522enum _mii_esr { 397enum _mii_esr {
523 MII_ESR_1000BX_FD = 0x8000, 398 MII_ESR_1000BX_FD = 0x8000,
524 MII_ESR_1000BX_HD = 0x4000, 399 MII_ESR_1000BX_HD = 0x4000,
@@ -526,6 +401,7 @@ enum _mii_esr {
526 MII_ESR_1000BT_HD = 0x1000, 401 MII_ESR_1000BT_HD = 0x1000,
527}; 402};
528/* PHY Specific Control Register */ 403/* PHY Specific Control Register */
404#if 0
529typedef union t_MII_PHY_SCR { 405typedef union t_MII_PHY_SCR {
530 u16 image; 406 u16 image;
531 struct { 407 struct {
@@ -543,6 +419,7 @@ typedef union t_MII_PHY_SCR {
543 u16 xmit_fifo_depth:2; // bit 15:14 419 u16 xmit_fifo_depth:2; // bit 15:14
544 } bits; 420 } bits;
545} PHY_SCR_t, *PPHY_SCR_t; 421} PHY_SCR_t, *PPHY_SCR_t;
422#endif
546 423
547typedef enum t_MII_ADMIN_STATUS { 424typedef enum t_MII_ADMIN_STATUS {
548 adm_reset, 425 adm_reset,
@@ -556,21 +433,6 @@ typedef enum t_MII_ADMIN_STATUS {
556/* PCS control and status registers bitmap as the same as MII */ 433/* PCS control and status registers bitmap as the same as MII */
557/* PCS Extended Status register bitmap as the same as MII */ 434/* PCS Extended Status register bitmap as the same as MII */
558/* PCS ANAR */ 435/* PCS ANAR */
559typedef union t_PCS_ANAR {
560 u16 image;
561 struct {
562 u16 _bit_4_0:5; // bit 4:0
563 u16 full_duplex:1; // bit 5
564 u16 half_duplex:1; // bit 6
565 u16 asymmetric:1; // bit 7
566 u16 pause:1; // bit 8
567 u16 _bit_11_9:3; // bit 11:9
568 u16 remote_fault:2; // bit 13:12
569 u16 _bit_14:1; // bit 14
570 u16 next_page:1; // bit 15
571 } bits;
572} ANAR_PCS_t, *PANAR_PCS_t;
573
574enum _pcs_anar { 436enum _pcs_anar {
575 PCS_ANAR_NEXT_PAGE = 0x8000, 437 PCS_ANAR_NEXT_PAGE = 0x8000,
576 PCS_ANAR_REMOTE_FAULT = 0x3000, 438 PCS_ANAR_REMOTE_FAULT = 0x3000,
@@ -580,21 +442,6 @@ enum _pcs_anar {
580 PCS_ANAR_FULL_DUPLEX = 0x0020, 442 PCS_ANAR_FULL_DUPLEX = 0x0020,
581}; 443};
582/* PCS ANLPAR */ 444/* PCS ANLPAR */
583typedef union t_PCS_ANLPAR {
584 u16 image;
585 struct {
586 u16 _bit_4_0:5; // bit 4:0
587 u16 full_duplex:1; // bit 5
588 u16 half_duplex:1; // bit 6
589 u16 asymmetric:1; // bit 7
590 u16 pause:1; // bit 8
591 u16 _bit_11_9:3; // bit 11:9
592 u16 remote_fault:2; // bit 13:12
593 u16 _bit_14:1; // bit 14
594 u16 next_page:1; // bit 15
595 } bits;
596} ANLPAR_PCS_t, *PANLPAR_PCS_t;
597
598enum _pcs_anlpar { 445enum _pcs_anlpar {
599 PCS_ANLPAR_NEXT_PAGE = PCS_ANAR_NEXT_PAGE, 446 PCS_ANLPAR_NEXT_PAGE = PCS_ANAR_NEXT_PAGE,
600 PCS_ANLPAR_REMOTE_FAULT = PCS_ANAR_REMOTE_FAULT, 447 PCS_ANLPAR_REMOTE_FAULT = PCS_ANAR_REMOTE_FAULT,
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index dbd23bb65d1e..50f0c17451b1 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -857,21 +857,14 @@ static void init_tfdlist(struct net_device *dev)
857static void ipg_nic_txfree(struct net_device *dev) 857static void ipg_nic_txfree(struct net_device *dev)
858{ 858{
859 struct ipg_nic_private *sp = netdev_priv(dev); 859 struct ipg_nic_private *sp = netdev_priv(dev);
860 void __iomem *ioaddr = sp->ioaddr; 860 unsigned int released, pending, dirty;
861 unsigned int curr;
862 u64 txd_map;
863 unsigned int released, pending;
864
865 txd_map = (u64)sp->txd_map;
866 curr = ipg_r32(TFD_LIST_PTR_0) -
867 do_div(txd_map, sizeof(struct ipg_tx)) - 1;
868 861
869 IPG_DEBUG_MSG("_nic_txfree\n"); 862 IPG_DEBUG_MSG("_nic_txfree\n");
870 863
871 pending = sp->tx_current - sp->tx_dirty; 864 pending = sp->tx_current - sp->tx_dirty;
865 dirty = sp->tx_dirty % IPG_TFDLIST_LENGTH;
872 866
873 for (released = 0; released < pending; released++) { 867 for (released = 0; released < pending; released++) {
874 unsigned int dirty = sp->tx_dirty % IPG_TFDLIST_LENGTH;
875 struct sk_buff *skb = sp->TxBuff[dirty]; 868 struct sk_buff *skb = sp->TxBuff[dirty];
876 struct ipg_tx *txfd = sp->txd + dirty; 869 struct ipg_tx *txfd = sp->txd + dirty;
877 870
@@ -882,11 +875,8 @@ static void ipg_nic_txfree(struct net_device *dev)
882 * If the TFDDone bit is set, free the associated 875 * If the TFDDone bit is set, free the associated
883 * buffer. 876 * buffer.
884 */ 877 */
885 if (dirty == curr) 878 if (!(txfd->tfc & cpu_to_le64(IPG_TFC_TFDDONE)))
886 break; 879 break;
887
888 /* Setup TFDDONE for compatible issue. */
889 txfd->tfc |= cpu_to_le64(IPG_TFC_TFDDONE);
890 880
891 /* Free the transmit buffer. */ 881 /* Free the transmit buffer. */
892 if (skb) { 882 if (skb) {
@@ -898,6 +888,7 @@ static void ipg_nic_txfree(struct net_device *dev)
898 888
899 sp->TxBuff[dirty] = NULL; 889 sp->TxBuff[dirty] = NULL;
900 } 890 }
891 dirty = (dirty + 1) % IPG_TFDLIST_LENGTH;
901 } 892 }
902 893
903 sp->tx_dirty += released; 894 sp->tx_dirty += released;
@@ -1630,6 +1621,8 @@ static irqreturn_t ipg_interrupt_handler(int irq, void *dev_inst)
1630#ifdef JUMBO_FRAME 1621#ifdef JUMBO_FRAME
1631 ipg_nic_rxrestore(dev); 1622 ipg_nic_rxrestore(dev);
1632#endif 1623#endif
1624 spin_lock(&sp->lock);
1625
1633 /* Get interrupt source information, and acknowledge 1626 /* Get interrupt source information, and acknowledge
1634 * some (i.e. TxDMAComplete, RxDMAComplete, RxEarly, 1627 * some (i.e. TxDMAComplete, RxDMAComplete, RxEarly,
1635 * IntRequested, MacControlFrame, LinkEvent) interrupts 1628 * IntRequested, MacControlFrame, LinkEvent) interrupts
@@ -1647,9 +1640,7 @@ static irqreturn_t ipg_interrupt_handler(int irq, void *dev_inst)
1647 handled = 1; 1640 handled = 1;
1648 1641
1649 if (unlikely(!netif_running(dev))) 1642 if (unlikely(!netif_running(dev)))
1650 goto out; 1643 goto out_unlock;
1651
1652 spin_lock(&sp->lock);
1653 1644
1654 /* If RFDListEnd interrupt, restore all used RFDs. */ 1645 /* If RFDListEnd interrupt, restore all used RFDs. */
1655 if (status & IPG_IS_RFD_LIST_END) { 1646 if (status & IPG_IS_RFD_LIST_END) {
@@ -1733,9 +1724,9 @@ out_enable:
1733 ipg_w16(IPG_IE_TX_DMA_COMPLETE | IPG_IE_RX_DMA_COMPLETE | 1724 ipg_w16(IPG_IE_TX_DMA_COMPLETE | IPG_IE_RX_DMA_COMPLETE |
1734 IPG_IE_HOST_ERROR | IPG_IE_INT_REQUESTED | IPG_IE_TX_COMPLETE | 1725 IPG_IE_HOST_ERROR | IPG_IE_INT_REQUESTED | IPG_IE_TX_COMPLETE |
1735 IPG_IE_LINK_EVENT | IPG_IE_UPDATE_STATS, INT_ENABLE); 1726 IPG_IE_LINK_EVENT | IPG_IE_UPDATE_STATS, INT_ENABLE);
1736 1727out_unlock:
1737 spin_unlock(&sp->lock); 1728 spin_unlock(&sp->lock);
1738out: 1729
1739 return IRQ_RETVAL(handled); 1730 return IRQ_RETVAL(handled);
1740} 1731}
1741 1732
@@ -1943,10 +1934,7 @@ static int ipg_nic_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1943 */ 1934 */
1944 if (sp->tenmbpsmode) 1935 if (sp->tenmbpsmode)
1945 txfd->tfc |= cpu_to_le64(IPG_TFC_TXINDICATE); 1936 txfd->tfc |= cpu_to_le64(IPG_TFC_TXINDICATE);
1946 else if (!((sp->tx_current - sp->tx_dirty + 1) > 1937 txfd->tfc |= cpu_to_le64(IPG_TFC_TXDMAINDICATE);
1947 IPG_FRAMESBETWEENTXDMACOMPLETES)) {
1948 txfd->tfc |= cpu_to_le64(IPG_TFC_TXDMAINDICATE);
1949 }
1950 /* Based on compilation option, determine if FCS is to be 1938 /* Based on compilation option, determine if FCS is to be
1951 * appended to transmit frame by IPG. 1939 * appended to transmit frame by IPG.
1952 */ 1940 */
@@ -2003,7 +1991,7 @@ static int ipg_nic_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
2003 ipg_w32(IPG_DC_TX_DMA_POLL_NOW, DMA_CTRL); 1991 ipg_w32(IPG_DC_TX_DMA_POLL_NOW, DMA_CTRL);
2004 1992
2005 if (sp->tx_current == (sp->tx_dirty + IPG_TFDLIST_LENGTH)) 1993 if (sp->tx_current == (sp->tx_dirty + IPG_TFDLIST_LENGTH))
2006 netif_wake_queue(dev); 1994 netif_stop_queue(dev);
2007 1995
2008 spin_unlock_irqrestore(&sp->lock, flags); 1996 spin_unlock_irqrestore(&sp->lock, flags);
2009 1997
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 288177716a49..36a7ba3134ce 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -187,14 +187,16 @@ enum Window1 {
187enum Window3 { /* Window 3: MAC/config bits. */ 187enum Window3 { /* Window 3: MAC/config bits. */
188 Wn3_Config=0, Wn3_MAC_Ctrl=6, Wn3_Options=8, 188 Wn3_Config=0, Wn3_MAC_Ctrl=6, Wn3_Options=8,
189}; 189};
190union wn3_config { 190enum wn3_config {
191 int i; 191 Ram_size = 7,
192 struct w3_config_fields { 192 Ram_width = 8,
193 unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2; 193 Ram_speed = 0x30,
194 int pad8:8; 194 Rom_size = 0xc0,
195 unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1; 195 Ram_split_shift = 16,
196 int pad24:7; 196 Ram_split = 3 << Ram_split_shift,
197 } u; 197 Xcvr_shift = 20,
198 Xcvr = 7 << Xcvr_shift,
199 Autoselect = 0x1000000,
198}; 200};
199 201
200enum Window4 { /* Window 4: Xcvr/media bits. */ 202enum Window4 { /* Window 4: Xcvr/media bits. */
@@ -342,7 +344,7 @@ static int tc574_config(struct pcmcia_device *link)
342 kio_addr_t ioaddr; 344 kio_addr_t ioaddr;
343 __be16 *phys_addr; 345 __be16 *phys_addr;
344 char *cardname; 346 char *cardname;
345 union wn3_config config; 347 __u32 config;
346 DECLARE_MAC_BUF(mac); 348 DECLARE_MAC_BUF(mac);
347 349
348 phys_addr = (__be16 *)dev->dev_addr; 350 phys_addr = (__be16 *)dev->dev_addr;
@@ -401,9 +403,9 @@ static int tc574_config(struct pcmcia_device *link)
401 outw(0<<11, ioaddr + RunnerRdCtrl); 403 outw(0<<11, ioaddr + RunnerRdCtrl);
402 printk(KERN_INFO " ASIC rev %d,", mcr>>3); 404 printk(KERN_INFO " ASIC rev %d,", mcr>>3);
403 EL3WINDOW(3); 405 EL3WINDOW(3);
404 config.i = inl(ioaddr + Wn3_Config); 406 config = inl(ioaddr + Wn3_Config);
405 lp->default_media = config.u.xcvr; 407 lp->default_media = (config & Xcvr) >> Xcvr_shift;
406 lp->autoselect = config.u.autoselect; 408 lp->autoselect = config & Autoselect ? 1 : 0;
407 } 409 }
408 410
409 init_timer(&lp->media); 411 init_timer(&lp->media);
@@ -464,8 +466,9 @@ static int tc574_config(struct pcmcia_device *link)
464 dev->name, cardname, dev->base_addr, dev->irq, 466 dev->name, cardname, dev->base_addr, dev->irq,
465 print_mac(mac, dev->dev_addr)); 467 print_mac(mac, dev->dev_addr));
466 printk(" %dK FIFO split %s Rx:Tx, %sMII interface.\n", 468 printk(" %dK FIFO split %s Rx:Tx, %sMII interface.\n",
467 8 << config.u.ram_size, ram_split[config.u.ram_split], 469 8 << config & Ram_size,
468 config.u.autoselect ? "autoselect " : ""); 470 ram_split[(config & Ram_split) >> Ram_split_shift],
471 config & Autoselect ? "autoselect " : "");
469 472
470 return 0; 473 return 0;
471 474
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index fa57c49c0c51..f2ba944e035e 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -84,7 +84,7 @@
84#include "s2io.h" 84#include "s2io.h"
85#include "s2io-regs.h" 85#include "s2io-regs.h"
86 86
87#define DRV_VERSION "2.0.26.10" 87#define DRV_VERSION "2.0.26.17"
88 88
89/* S2io Driver name & version. */ 89/* S2io Driver name & version. */
90static char s2io_driver_name[] = "Neterion"; 90static char s2io_driver_name[] = "Neterion";
@@ -3848,8 +3848,6 @@ static int s2io_open(struct net_device *dev)
3848 netif_carrier_off(dev); 3848 netif_carrier_off(dev);
3849 sp->last_link_state = 0; 3849 sp->last_link_state = 0;
3850 3850
3851 napi_enable(&sp->napi);
3852
3853 if (sp->config.intr_type == MSI_X) { 3851 if (sp->config.intr_type == MSI_X) {
3854 int ret = s2io_enable_msi_x(sp); 3852 int ret = s2io_enable_msi_x(sp);
3855 3853
@@ -3892,7 +3890,6 @@ static int s2io_open(struct net_device *dev)
3892 return 0; 3890 return 0;
3893 3891
3894hw_init_failed: 3892hw_init_failed:
3895 napi_disable(&sp->napi);
3896 if (sp->config.intr_type == MSI_X) { 3893 if (sp->config.intr_type == MSI_X) {
3897 if (sp->entries) { 3894 if (sp->entries) {
3898 kfree(sp->entries); 3895 kfree(sp->entries);
@@ -3932,7 +3929,6 @@ static int s2io_close(struct net_device *dev)
3932 return 0; 3929 return 0;
3933 3930
3934 netif_stop_queue(dev); 3931 netif_stop_queue(dev);
3935 napi_disable(&sp->napi);
3936 /* Reset card, kill tasklet and free Tx and Rx buffers. */ 3932 /* Reset card, kill tasklet and free Tx and Rx buffers. */
3937 s2io_card_down(sp); 3933 s2io_card_down(sp);
3938 3934
@@ -6796,6 +6792,8 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
6796 struct XENA_dev_config __iomem *bar0 = sp->bar0; 6792 struct XENA_dev_config __iomem *bar0 = sp->bar0;
6797 unsigned long flags; 6793 unsigned long flags;
6798 register u64 val64 = 0; 6794 register u64 val64 = 0;
6795 struct config_param *config;
6796 config = &sp->config;
6799 6797
6800 if (!is_s2io_card_up(sp)) 6798 if (!is_s2io_card_up(sp))
6801 return; 6799 return;
@@ -6807,6 +6805,10 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
6807 } 6805 }
6808 clear_bit(__S2IO_STATE_CARD_UP, &sp->state); 6806 clear_bit(__S2IO_STATE_CARD_UP, &sp->state);
6809 6807
6808 /* Disable napi */
6809 if (config->napi)
6810 napi_disable(&sp->napi);
6811
6810 /* disable Tx and Rx traffic on the NIC */ 6812 /* disable Tx and Rx traffic on the NIC */
6811 if (do_io) 6813 if (do_io)
6812 stop_nic(sp); 6814 stop_nic(sp);
@@ -6900,6 +6902,11 @@ static int s2io_card_up(struct s2io_nic * sp)
6900 DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i, 6902 DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i,
6901 atomic_read(&sp->rx_bufs_left[i])); 6903 atomic_read(&sp->rx_bufs_left[i]));
6902 } 6904 }
6905
6906 /* Initialise napi */
6907 if (config->napi)
6908 napi_enable(&sp->napi);
6909
6903 /* Maintain the state prior to the open */ 6910 /* Maintain the state prior to the open */
6904 if (sp->promisc_flg) 6911 if (sp->promisc_flg)
6905 sp->promisc_flg = 0; 6912 sp->promisc_flg = 0;
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 7023bbe545ee..bc15940ce1bc 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -3949,7 +3949,7 @@ static __exit void sky2_debug_cleanup(void)
3949/* Initialize network device */ 3949/* Initialize network device */
3950static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, 3950static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3951 unsigned port, 3951 unsigned port,
3952 int highmem) 3952 int highmem, int wol)
3953{ 3953{
3954 struct sky2_port *sky2; 3954 struct sky2_port *sky2;
3955 struct net_device *dev = alloc_etherdev(sizeof(*sky2)); 3955 struct net_device *dev = alloc_etherdev(sizeof(*sky2));
@@ -3989,7 +3989,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3989 sky2->speed = -1; 3989 sky2->speed = -1;
3990 sky2->advertising = sky2_supported_modes(hw); 3990 sky2->advertising = sky2_supported_modes(hw);
3991 sky2->rx_csum = (hw->chip_id != CHIP_ID_YUKON_XL); 3991 sky2->rx_csum = (hw->chip_id != CHIP_ID_YUKON_XL);
3992 sky2->wol = sky2_wol_supported(hw) & WAKE_MAGIC; 3992 sky2->wol = wol;
3993 3993
3994 spin_lock_init(&sky2->phy_lock); 3994 spin_lock_init(&sky2->phy_lock);
3995 sky2->tx_pending = TX_DEF_PENDING; 3995 sky2->tx_pending = TX_DEF_PENDING;
@@ -4086,12 +4086,24 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
4086 return err; 4086 return err;
4087} 4087}
4088 4088
4089static int __devinit pci_wake_enabled(struct pci_dev *dev)
4090{
4091 int pm = pci_find_capability(dev, PCI_CAP_ID_PM);
4092 u16 value;
4093
4094 if (!pm)
4095 return 0;
4096 if (pci_read_config_word(dev, pm + PCI_PM_CTRL, &value))
4097 return 0;
4098 return value & PCI_PM_CTRL_PME_ENABLE;
4099}
4100
4089static int __devinit sky2_probe(struct pci_dev *pdev, 4101static int __devinit sky2_probe(struct pci_dev *pdev,
4090 const struct pci_device_id *ent) 4102 const struct pci_device_id *ent)
4091{ 4103{
4092 struct net_device *dev; 4104 struct net_device *dev;
4093 struct sky2_hw *hw; 4105 struct sky2_hw *hw;
4094 int err, using_dac = 0; 4106 int err, using_dac = 0, wol_default;
4095 4107
4096 err = pci_enable_device(pdev); 4108 err = pci_enable_device(pdev);
4097 if (err) { 4109 if (err) {
@@ -4124,6 +4136,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
4124 } 4136 }
4125 } 4137 }
4126 4138
4139 wol_default = pci_wake_enabled(pdev) ? WAKE_MAGIC : 0;
4140
4127 err = -ENOMEM; 4141 err = -ENOMEM;
4128 hw = kzalloc(sizeof(*hw), GFP_KERNEL); 4142 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
4129 if (!hw) { 4143 if (!hw) {
@@ -4167,7 +4181,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
4167 4181
4168 sky2_reset(hw); 4182 sky2_reset(hw);
4169 4183
4170 dev = sky2_init_netdev(hw, 0, using_dac); 4184 dev = sky2_init_netdev(hw, 0, using_dac, wol_default);
4171 if (!dev) { 4185 if (!dev) {
4172 err = -ENOMEM; 4186 err = -ENOMEM;
4173 goto err_out_free_pci; 4187 goto err_out_free_pci;
@@ -4204,7 +4218,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
4204 if (hw->ports > 1) { 4218 if (hw->ports > 1) {
4205 struct net_device *dev1; 4219 struct net_device *dev1;
4206 4220
4207 dev1 = sky2_init_netdev(hw, 1, using_dac); 4221 dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default);
4208 if (!dev1) 4222 if (!dev1)
4209 dev_warn(&pdev->dev, "allocation for second device failed\n"); 4223 dev_warn(&pdev->dev, "allocation for second device failed\n");
4210 else if ((err = register_netdev(dev1))) { 4224 else if ((err = register_netdev(dev1))) {
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 33dc713b5301..c6f26e28e376 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -139,19 +139,21 @@ struct thingie {
139}; 139};
140 140
141struct TxFD { 141struct TxFD {
142 u32 state; 142 __le32 state;
143 u32 next; 143 __le32 next;
144 u32 data; 144 __le32 data;
145 u32 complete; 145 __le32 complete;
146 u32 jiffies; /* Allows sizeof(TxFD) == sizeof(RxFD) + extra hack */ 146 u32 jiffies; /* Allows sizeof(TxFD) == sizeof(RxFD) + extra hack */
147 /* FWIW, datasheet calls that "dummy" and says that card
148 * never looks at it; neither does the driver */
147}; 149};
148 150
149struct RxFD { 151struct RxFD {
150 u32 state1; 152 __le32 state1;
151 u32 next; 153 __le32 next;
152 u32 data; 154 __le32 data;
153 u32 state2; 155 __le32 state2;
154 u32 end; 156 __le32 end;
155}; 157};
156 158
157#define DUMMY_SKB_SIZE 64 159#define DUMMY_SKB_SIZE 64
@@ -181,7 +183,7 @@ struct RxFD {
181#define SCC_REG_START(dpriv) (SCC_START+(dpriv->dev_id)*SCC_OFFSET) 183#define SCC_REG_START(dpriv) (SCC_START+(dpriv->dev_id)*SCC_OFFSET)
182 184
183struct dscc4_pci_priv { 185struct dscc4_pci_priv {
184 u32 *iqcfg; 186 __le32 *iqcfg;
185 int cfg_cur; 187 int cfg_cur;
186 spinlock_t lock; 188 spinlock_t lock;
187 struct pci_dev *pdev; 189 struct pci_dev *pdev;
@@ -197,8 +199,8 @@ struct dscc4_dev_priv {
197 199
198 struct RxFD *rx_fd; 200 struct RxFD *rx_fd;
199 struct TxFD *tx_fd; 201 struct TxFD *tx_fd;
200 u32 *iqrx; 202 __le32 *iqrx;
201 u32 *iqtx; 203 __le32 *iqtx;
202 204
203 /* FIXME: check all the volatile are required */ 205 /* FIXME: check all the volatile are required */
204 volatile u32 tx_current; 206 volatile u32 tx_current;
@@ -298,7 +300,7 @@ struct dscc4_dev_priv {
298#define BrrExpMask 0x00000f00 300#define BrrExpMask 0x00000f00
299#define BrrMultMask 0x0000003f 301#define BrrMultMask 0x0000003f
300#define EncodingMask 0x00700000 302#define EncodingMask 0x00700000
301#define Hold 0x40000000 303#define Hold cpu_to_le32(0x40000000)
302#define SccBusy 0x10000000 304#define SccBusy 0x10000000
303#define PowerUp 0x80000000 305#define PowerUp 0x80000000
304#define Vis 0x00001000 306#define Vis 0x00001000
@@ -307,14 +309,14 @@ struct dscc4_dev_priv {
307#define FrameRdo 0x40 309#define FrameRdo 0x40
308#define FrameCrc 0x20 310#define FrameCrc 0x20
309#define FrameRab 0x10 311#define FrameRab 0x10
310#define FrameAborted 0x00000200 312#define FrameAborted cpu_to_le32(0x00000200)
311#define FrameEnd 0x80000000 313#define FrameEnd cpu_to_le32(0x80000000)
312#define DataComplete 0x40000000 314#define DataComplete cpu_to_le32(0x40000000)
313#define LengthCheck 0x00008000 315#define LengthCheck 0x00008000
314#define SccEvt 0x02000000 316#define SccEvt 0x02000000
315#define NoAck 0x00000200 317#define NoAck 0x00000200
316#define Action 0x00000001 318#define Action 0x00000001
317#define HiDesc 0x20000000 319#define HiDesc cpu_to_le32(0x20000000)
318 320
319/* SCC events */ 321/* SCC events */
320#define RxEvt 0xf0000000 322#define RxEvt 0xf0000000
@@ -489,8 +491,8 @@ static void dscc4_release_ring(struct dscc4_dev_priv *dpriv)
489 skbuff = dpriv->tx_skbuff; 491 skbuff = dpriv->tx_skbuff;
490 for (i = 0; i < TX_RING_SIZE; i++) { 492 for (i = 0; i < TX_RING_SIZE; i++) {
491 if (*skbuff) { 493 if (*skbuff) {
492 pci_unmap_single(pdev, tx_fd->data, (*skbuff)->len, 494 pci_unmap_single(pdev, le32_to_cpu(tx_fd->data),
493 PCI_DMA_TODEVICE); 495 (*skbuff)->len, PCI_DMA_TODEVICE);
494 dev_kfree_skb(*skbuff); 496 dev_kfree_skb(*skbuff);
495 } 497 }
496 skbuff++; 498 skbuff++;
@@ -500,7 +502,7 @@ static void dscc4_release_ring(struct dscc4_dev_priv *dpriv)
500 skbuff = dpriv->rx_skbuff; 502 skbuff = dpriv->rx_skbuff;
501 for (i = 0; i < RX_RING_SIZE; i++) { 503 for (i = 0; i < RX_RING_SIZE; i++) {
502 if (*skbuff) { 504 if (*skbuff) {
503 pci_unmap_single(pdev, rx_fd->data, 505 pci_unmap_single(pdev, le32_to_cpu(rx_fd->data),
504 RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE); 506 RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE);
505 dev_kfree_skb(*skbuff); 507 dev_kfree_skb(*skbuff);
506 } 508 }
@@ -522,10 +524,10 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv *dpriv,
522 dpriv->rx_skbuff[dirty] = skb; 524 dpriv->rx_skbuff[dirty] = skb;
523 if (skb) { 525 if (skb) {
524 skb->protocol = hdlc_type_trans(skb, dev); 526 skb->protocol = hdlc_type_trans(skb, dev);
525 rx_fd->data = pci_map_single(dpriv->pci_priv->pdev, skb->data, 527 rx_fd->data = cpu_to_le32(pci_map_single(dpriv->pci_priv->pdev,
526 len, PCI_DMA_FROMDEVICE); 528 skb->data, len, PCI_DMA_FROMDEVICE));
527 } else { 529 } else {
528 rx_fd->data = (u32) NULL; 530 rx_fd->data = 0;
529 ret = -1; 531 ret = -1;
530 } 532 }
531 return ret; 533 return ret;
@@ -587,7 +589,7 @@ static inline int dscc4_xpr_ack(struct dscc4_dev_priv *dpriv)
587 589
588 do { 590 do {
589 if (!(dpriv->flags & (NeedIDR | NeedIDT)) || 591 if (!(dpriv->flags & (NeedIDR | NeedIDT)) ||
590 (dpriv->iqtx[cur] & Xpr)) 592 (dpriv->iqtx[cur] & cpu_to_le32(Xpr)))
591 break; 593 break;
592 smp_rmb(); 594 smp_rmb();
593 schedule_timeout_uninterruptible(10); 595 schedule_timeout_uninterruptible(10);
@@ -650,8 +652,9 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
650 printk(KERN_DEBUG "%s: skb=0 (%s)\n", dev->name, __FUNCTION__); 652 printk(KERN_DEBUG "%s: skb=0 (%s)\n", dev->name, __FUNCTION__);
651 goto refill; 653 goto refill;
652 } 654 }
653 pkt_len = TO_SIZE(rx_fd->state2); 655 pkt_len = TO_SIZE(le32_to_cpu(rx_fd->state2));
654 pci_unmap_single(pdev, rx_fd->data, RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE); 656 pci_unmap_single(pdev, le32_to_cpu(rx_fd->data),
657 RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE);
655 if ((skb->data[--pkt_len] & FrameOk) == FrameOk) { 658 if ((skb->data[--pkt_len] & FrameOk) == FrameOk) {
656 stats->rx_packets++; 659 stats->rx_packets++;
657 stats->rx_bytes += pkt_len; 660 stats->rx_bytes += pkt_len;
@@ -679,7 +682,7 @@ refill:
679 } 682 }
680 dscc4_rx_update(dpriv, dev); 683 dscc4_rx_update(dpriv, dev);
681 rx_fd->state2 = 0x00000000; 684 rx_fd->state2 = 0x00000000;
682 rx_fd->end = 0xbabeface; 685 rx_fd->end = cpu_to_le32(0xbabeface);
683} 686}
684 687
685static void dscc4_free1(struct pci_dev *pdev) 688static void dscc4_free1(struct pci_dev *pdev)
@@ -772,8 +775,8 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
772 } 775 }
773 /* Global interrupt queue */ 776 /* Global interrupt queue */
774 writel((u32)(((IRQ_RING_SIZE >> 5) - 1) << 20), ioaddr + IQLENR1); 777 writel((u32)(((IRQ_RING_SIZE >> 5) - 1) << 20), ioaddr + IQLENR1);
775 priv->iqcfg = (u32 *) pci_alloc_consistent(pdev, 778 priv->iqcfg = (__le32 *) pci_alloc_consistent(pdev,
776 IRQ_RING_SIZE*sizeof(u32), &priv->iqcfg_dma); 779 IRQ_RING_SIZE*sizeof(__le32), &priv->iqcfg_dma);
777 if (!priv->iqcfg) 780 if (!priv->iqcfg)
778 goto err_free_irq_5; 781 goto err_free_irq_5;
779 writel(priv->iqcfg_dma, ioaddr + IQCFG); 782 writel(priv->iqcfg_dma, ioaddr + IQCFG);
@@ -786,7 +789,7 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
786 */ 789 */
787 for (i = 0; i < dev_per_card; i++) { 790 for (i = 0; i < dev_per_card; i++) {
788 dpriv = priv->root + i; 791 dpriv = priv->root + i;
789 dpriv->iqtx = (u32 *) pci_alloc_consistent(pdev, 792 dpriv->iqtx = (__le32 *) pci_alloc_consistent(pdev,
790 IRQ_RING_SIZE*sizeof(u32), &dpriv->iqtx_dma); 793 IRQ_RING_SIZE*sizeof(u32), &dpriv->iqtx_dma);
791 if (!dpriv->iqtx) 794 if (!dpriv->iqtx)
792 goto err_free_iqtx_6; 795 goto err_free_iqtx_6;
@@ -794,7 +797,7 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
794 } 797 }
795 for (i = 0; i < dev_per_card; i++) { 798 for (i = 0; i < dev_per_card; i++) {
796 dpriv = priv->root + i; 799 dpriv = priv->root + i;
797 dpriv->iqrx = (u32 *) pci_alloc_consistent(pdev, 800 dpriv->iqrx = (__le32 *) pci_alloc_consistent(pdev,
798 IRQ_RING_SIZE*sizeof(u32), &dpriv->iqrx_dma); 801 IRQ_RING_SIZE*sizeof(u32), &dpriv->iqrx_dma);
799 if (!dpriv->iqrx) 802 if (!dpriv->iqrx)
800 goto err_free_iqrx_7; 803 goto err_free_iqrx_7;
@@ -1156,8 +1159,8 @@ static int dscc4_start_xmit(struct sk_buff *skb, struct net_device *dev)
1156 dpriv->tx_skbuff[next] = skb; 1159 dpriv->tx_skbuff[next] = skb;
1157 tx_fd = dpriv->tx_fd + next; 1160 tx_fd = dpriv->tx_fd + next;
1158 tx_fd->state = FrameEnd | TO_STATE_TX(skb->len); 1161 tx_fd->state = FrameEnd | TO_STATE_TX(skb->len);
1159 tx_fd->data = pci_map_single(ppriv->pdev, skb->data, skb->len, 1162 tx_fd->data = cpu_to_le32(pci_map_single(ppriv->pdev, skb->data, skb->len,
1160 PCI_DMA_TODEVICE); 1163 PCI_DMA_TODEVICE));
1161 tx_fd->complete = 0x00000000; 1164 tx_fd->complete = 0x00000000;
1162 tx_fd->jiffies = jiffies; 1165 tx_fd->jiffies = jiffies;
1163 mb(); 1166 mb();
@@ -1508,7 +1511,7 @@ static irqreturn_t dscc4_irq(int irq, void *token)
1508 if (state & Cfg) { 1511 if (state & Cfg) {
1509 if (debug > 0) 1512 if (debug > 0)
1510 printk(KERN_DEBUG "%s: CfgIV\n", DRV_NAME); 1513 printk(KERN_DEBUG "%s: CfgIV\n", DRV_NAME);
1511 if (priv->iqcfg[priv->cfg_cur++%IRQ_RING_SIZE] & Arf) 1514 if (priv->iqcfg[priv->cfg_cur++%IRQ_RING_SIZE] & cpu_to_le32(Arf))
1512 printk(KERN_ERR "%s: %s failed\n", dev->name, "CFG"); 1515 printk(KERN_ERR "%s: %s failed\n", dev->name, "CFG");
1513 if (!(state &= ~Cfg)) 1516 if (!(state &= ~Cfg))
1514 goto out; 1517 goto out;
@@ -1541,7 +1544,7 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv,
1541 1544
1542try: 1545try:
1543 cur = dpriv->iqtx_current%IRQ_RING_SIZE; 1546 cur = dpriv->iqtx_current%IRQ_RING_SIZE;
1544 state = dpriv->iqtx[cur]; 1547 state = le32_to_cpu(dpriv->iqtx[cur]);
1545 if (!state) { 1548 if (!state) {
1546 if (debug > 4) 1549 if (debug > 4)
1547 printk(KERN_DEBUG "%s: Tx ISR = 0x%08x\n", dev->name, 1550 printk(KERN_DEBUG "%s: Tx ISR = 0x%08x\n", dev->name,
@@ -1580,7 +1583,7 @@ try:
1580 tx_fd = dpriv->tx_fd + cur; 1583 tx_fd = dpriv->tx_fd + cur;
1581 skb = dpriv->tx_skbuff[cur]; 1584 skb = dpriv->tx_skbuff[cur];
1582 if (skb) { 1585 if (skb) {
1583 pci_unmap_single(ppriv->pdev, tx_fd->data, 1586 pci_unmap_single(ppriv->pdev, le32_to_cpu(tx_fd->data),
1584 skb->len, PCI_DMA_TODEVICE); 1587 skb->len, PCI_DMA_TODEVICE);
1585 if (tx_fd->state & FrameEnd) { 1588 if (tx_fd->state & FrameEnd) {
1586 stats->tx_packets++; 1589 stats->tx_packets++;
@@ -1711,7 +1714,7 @@ static void dscc4_rx_irq(struct dscc4_pci_priv *priv,
1711 1714
1712try: 1715try:
1713 cur = dpriv->iqrx_current%IRQ_RING_SIZE; 1716 cur = dpriv->iqrx_current%IRQ_RING_SIZE;
1714 state = dpriv->iqrx[cur]; 1717 state = le32_to_cpu(dpriv->iqrx[cur]);
1715 if (!state) 1718 if (!state)
1716 return; 1719 return;
1717 dpriv->iqrx[cur] = 0; 1720 dpriv->iqrx[cur] = 0;
@@ -1755,7 +1758,7 @@ try:
1755 goto try; 1758 goto try;
1756 rx_fd->state1 &= ~Hold; 1759 rx_fd->state1 &= ~Hold;
1757 rx_fd->state2 = 0x00000000; 1760 rx_fd->state2 = 0x00000000;
1758 rx_fd->end = 0xbabeface; 1761 rx_fd->end = cpu_to_le32(0xbabeface);
1759 //} 1762 //}
1760 goto try; 1763 goto try;
1761 } 1764 }
@@ -1834,7 +1837,7 @@ try:
1834 hdlc_stats(dev)->rx_over_errors++; 1837 hdlc_stats(dev)->rx_over_errors++;
1835 rx_fd->state1 |= Hold; 1838 rx_fd->state1 |= Hold;
1836 rx_fd->state2 = 0x00000000; 1839 rx_fd->state2 = 0x00000000;
1837 rx_fd->end = 0xbabeface; 1840 rx_fd->end = cpu_to_le32(0xbabeface);
1838 } else 1841 } else
1839 dscc4_rx_skb(dpriv, dev); 1842 dscc4_rx_skb(dpriv, dev);
1840 } while (1); 1843 } while (1);
@@ -1904,8 +1907,9 @@ static struct sk_buff *dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv)
1904 skb_copy_to_linear_data(skb, version, 1907 skb_copy_to_linear_data(skb, version,
1905 strlen(version) % DUMMY_SKB_SIZE); 1908 strlen(version) % DUMMY_SKB_SIZE);
1906 tx_fd->state = FrameEnd | TO_STATE_TX(DUMMY_SKB_SIZE); 1909 tx_fd->state = FrameEnd | TO_STATE_TX(DUMMY_SKB_SIZE);
1907 tx_fd->data = pci_map_single(dpriv->pci_priv->pdev, skb->data, 1910 tx_fd->data = cpu_to_le32(pci_map_single(dpriv->pci_priv->pdev,
1908 DUMMY_SKB_SIZE, PCI_DMA_TODEVICE); 1911 skb->data, DUMMY_SKB_SIZE,
1912 PCI_DMA_TODEVICE));
1909 dpriv->tx_skbuff[last] = skb; 1913 dpriv->tx_skbuff[last] = skb;
1910 } 1914 }
1911 return skb; 1915 return skb;
@@ -1937,8 +1941,8 @@ static int dscc4_init_ring(struct net_device *dev)
1937 tx_fd->state = FrameEnd | TO_STATE_TX(2*DUMMY_SKB_SIZE); 1941 tx_fd->state = FrameEnd | TO_STATE_TX(2*DUMMY_SKB_SIZE);
1938 tx_fd->complete = 0x00000000; 1942 tx_fd->complete = 0x00000000;
1939 /* FIXME: NULL should be ok - to be tried */ 1943 /* FIXME: NULL should be ok - to be tried */
1940 tx_fd->data = dpriv->tx_fd_dma; 1944 tx_fd->data = cpu_to_le32(dpriv->tx_fd_dma);
1941 (tx_fd++)->next = (u32)(dpriv->tx_fd_dma + 1945 (tx_fd++)->next = cpu_to_le32(dpriv->tx_fd_dma +
1942 (++i%TX_RING_SIZE)*sizeof(*tx_fd)); 1946 (++i%TX_RING_SIZE)*sizeof(*tx_fd));
1943 } while (i < TX_RING_SIZE); 1947 } while (i < TX_RING_SIZE);
1944 1948
@@ -1951,12 +1955,12 @@ static int dscc4_init_ring(struct net_device *dev)
1951 /* size set by the host. Multiple of 4 bytes please */ 1955 /* size set by the host. Multiple of 4 bytes please */
1952 rx_fd->state1 = HiDesc; 1956 rx_fd->state1 = HiDesc;
1953 rx_fd->state2 = 0x00000000; 1957 rx_fd->state2 = 0x00000000;
1954 rx_fd->end = 0xbabeface; 1958 rx_fd->end = cpu_to_le32(0xbabeface);
1955 rx_fd->state1 |= TO_STATE_RX(HDLC_MAX_MRU); 1959 rx_fd->state1 |= TO_STATE_RX(HDLC_MAX_MRU);
1956 // FIXME: return value verifiee mais traitement suspect 1960 // FIXME: return value verifiee mais traitement suspect
1957 if (try_get_rx_skb(dpriv, dev) >= 0) 1961 if (try_get_rx_skb(dpriv, dev) >= 0)
1958 dpriv->rx_dirty++; 1962 dpriv->rx_dirty++;
1959 (rx_fd++)->next = (u32)(dpriv->rx_fd_dma + 1963 (rx_fd++)->next = cpu_to_le32(dpriv->rx_fd_dma +
1960 (++i%RX_RING_SIZE)*sizeof(*rx_fd)); 1964 (++i%RX_RING_SIZE)*sizeof(*rx_fd));
1961 } while (i < RX_RING_SIZE); 1965 } while (i < RX_RING_SIZE);
1962 1966
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index 574737b55f39..c9c878cd5c72 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -890,16 +890,8 @@ write_av9110 (lmc_softc_t * sc, u_int32_t n, u_int32_t m, u_int32_t v,
890static void 890static void
891lmc_ssi_watchdog (lmc_softc_t * const sc) 891lmc_ssi_watchdog (lmc_softc_t * const sc)
892{ 892{
893 u_int16_t mii17; 893 u_int16_t mii17 = lmc_mii_readreg (sc, 0, 17);
894 struct ssicsr2 894 if (((mii17 >> 3) & 7) == 7)
895 {
896 unsigned short dtr:1, dsr:1, rts:1, cable:3, crc:1, led0:1, led1:1,
897 led2:1, led3:1, fifo:1, ll:1, rl:1, tm:1, loop:1;
898 };
899 struct ssicsr2 *ssicsr;
900 mii17 = lmc_mii_readreg (sc, 0, 17);
901 ssicsr = (struct ssicsr2 *) &mii17;
902 if (ssicsr->cable == 7)
903 { 895 {
904 lmc_led_off (sc, LMC_MII16_LED2); 896 lmc_led_off (sc, LMC_MII16_LED2);
905 } 897 }
diff --git a/drivers/net/wan/sbni.h b/drivers/net/wan/sbni.h
index 27715e70f28b..84264510a8ed 100644
--- a/drivers/net/wan/sbni.h
+++ b/drivers/net/wan/sbni.h
@@ -44,9 +44,15 @@ enum {
44#define PR_RES 0x80 44#define PR_RES 0x80
45 45
46struct sbni_csr1 { 46struct sbni_csr1 {
47 unsigned rxl : 5; 47#ifdef __LITTLE_ENDIAN_BITFIELD
48 unsigned rate : 2; 48 u8 rxl : 5;
49 unsigned : 1; 49 u8 rate : 2;
50 u8 : 1;
51#else
52 u8 : 1;
53 u8 rate : 2;
54 u8 rxl : 5;
55#endif
50}; 56};
51 57
52/* fields in frame header */ 58/* fields in frame header */
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c
index 98cf70c5fd47..11f53cb1139e 100644
--- a/drivers/net/wireless/b43/rfkill.c
+++ b/drivers/net/wireless/b43/rfkill.c
@@ -138,8 +138,11 @@ void b43_rfkill_init(struct b43_wldev *dev)
138 rfk->rfkill->user_claim_unsupported = 1; 138 rfk->rfkill->user_claim_unsupported = 1;
139 139
140 rfk->poll_dev = input_allocate_polled_device(); 140 rfk->poll_dev = input_allocate_polled_device();
141 if (!rfk->poll_dev) 141 if (!rfk->poll_dev) {
142 goto err_free_rfk; 142 rfkill_free(rfk->rfkill);
143 goto err_freed_rfk;
144 }
145
143 rfk->poll_dev->private = dev; 146 rfk->poll_dev->private = dev;
144 rfk->poll_dev->poll = b43_rfkill_poll; 147 rfk->poll_dev->poll = b43_rfkill_poll;
145 rfk->poll_dev->poll_interval = 1000; /* msecs */ 148 rfk->poll_dev->poll_interval = 1000; /* msecs */
@@ -175,8 +178,7 @@ err_unreg_rfk:
175err_free_polldev: 178err_free_polldev:
176 input_free_polled_device(rfk->poll_dev); 179 input_free_polled_device(rfk->poll_dev);
177 rfk->poll_dev = NULL; 180 rfk->poll_dev = NULL;
178err_free_rfk: 181err_freed_rfk:
179 rfkill_free(rfk->rfkill);
180 rfk->rfkill = NULL; 182 rfk->rfkill = NULL;
181out_error: 183out_error:
182 rfk->registered = 0; 184 rfk->registered = 0;
@@ -195,6 +197,5 @@ void b43_rfkill_exit(struct b43_wldev *dev)
195 rfkill_unregister(rfk->rfkill); 197 rfkill_unregister(rfk->rfkill);
196 input_free_polled_device(rfk->poll_dev); 198 input_free_polled_device(rfk->poll_dev);
197 rfk->poll_dev = NULL; 199 rfk->poll_dev = NULL;
198 rfkill_free(rfk->rfkill);
199 rfk->rfkill = NULL; 200 rfk->rfkill = NULL;
200} 201}
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 040dc3e36410..cbf15d703201 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -608,7 +608,7 @@ static void prism2_plx_remove(struct pci_dev *pdev)
608 608
609MODULE_DEVICE_TABLE(pci, prism2_plx_id_table); 609MODULE_DEVICE_TABLE(pci, prism2_plx_id_table);
610 610
611static struct pci_driver prism2_plx_drv_id = { 611static struct pci_driver prism2_plx_driver = {
612 .name = "hostap_plx", 612 .name = "hostap_plx",
613 .id_table = prism2_plx_id_table, 613 .id_table = prism2_plx_id_table,
614 .probe = prism2_plx_probe, 614 .probe = prism2_plx_probe,
@@ -618,13 +618,13 @@ static struct pci_driver prism2_plx_drv_id = {
618 618
619static int __init init_prism2_plx(void) 619static int __init init_prism2_plx(void)
620{ 620{
621 return pci_register_driver(&prism2_plx_drv_id); 621 return pci_register_driver(&prism2_plx_driver);
622} 622}
623 623
624 624
625static void __exit exit_prism2_plx(void) 625static void __exit exit_prism2_plx(void)
626{ 626{
627 pci_unregister_driver(&prism2_plx_drv_id); 627 pci_unregister_driver(&prism2_plx_driver);
628} 628}
629 629
630 630
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 88062c1318a8..003f73f89efa 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4935,7 +4935,7 @@ static int ipw_queue_reset(struct ipw_priv *priv)
4935/** 4935/**
4936 * Reclaim Tx queue entries no more used by NIC. 4936 * Reclaim Tx queue entries no more used by NIC.
4937 * 4937 *
4938 * When FW adwances 'R' index, all entries between old and 4938 * When FW advances 'R' index, all entries between old and
4939 * new 'R' index need to be reclaimed. As result, some free space 4939 * new 'R' index need to be reclaimed. As result, some free space
4940 * forms. If there is enough free space (> low mark), wake Tx queue. 4940 * forms. If there is enough free space (> low mark), wake Tx queue.
4941 * 4941 *
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index b24425f74883..4f1efb108c28 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -871,6 +871,10 @@ static int if_sdio_probe(struct sdio_func *func,
871 if (sscanf(func->card->info[i], 871 if (sscanf(func->card->info[i],
872 "ID: %x", &model) == 1) 872 "ID: %x", &model) == 1)
873 break; 873 break;
874 if (!strcmp(func->card->info[i], "IBIS Wireless SDIO Card")) {
875 model = 4;
876 break;
877 }
874 } 878 }
875 879
876 if (i == func->card->num_info) { 880 if (i == func->card->num_info) {
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 6d5d9aba0b73..04663eb31950 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -149,7 +149,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev)
149 * The data behind the ieee80211 header must be 149 * The data behind the ieee80211 header must be
150 * aligned on a 4 byte boundary. 150 * aligned on a 4 byte boundary.
151 */ 151 */
152 align = NET_IP_ALIGN + (2 * (header_size % 4 == 0)); 152 align = header_size % 4;
153 153
154 /* 154 /*
155 * Allocate the sk_buffer, initialize it and copy 155 * Allocate the sk_buffer, initialize it and copy
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index ab4797ed94c9..568d73847dca 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -245,13 +245,20 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
245 * Allocate a new sk buffer to replace the current one. 245 * Allocate a new sk buffer to replace the current one.
246 * If allocation fails, we should drop the current frame 246 * If allocation fails, we should drop the current frame
247 * so we can recycle the existing sk buffer for the new frame. 247 * so we can recycle the existing sk buffer for the new frame.
248 * As alignment we use 2 and not NET_IP_ALIGN because we need
249 * to be sure we have 2 bytes room in the head. (NET_IP_ALIGN
250 * can be 0 on some hardware). We use these 2 bytes for frame
251 * alignment later, we assume that the chance that
252 * header_size % 4 == 2 is bigger then header_size % 2 == 0
253 * and thus optimize alignment by reserving the 2 bytes in
254 * advance.
248 */ 255 */
249 frame_size = entry->ring->data_size + entry->ring->desc_size; 256 frame_size = entry->ring->data_size + entry->ring->desc_size;
250 skb = dev_alloc_skb(frame_size + NET_IP_ALIGN); 257 skb = dev_alloc_skb(frame_size + 2);
251 if (!skb) 258 if (!skb)
252 goto skip_entry; 259 goto skip_entry;
253 260
254 skb_reserve(skb, NET_IP_ALIGN); 261 skb_reserve(skb, 2);
255 skb_put(skb, frame_size); 262 skb_put(skb, frame_size);
256 263
257 /* 264 /*