aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/connector/connector.c40
-rw-r--r--drivers/net/3c59x.c5
-rw-r--r--drivers/net/8139cp.c1
-rw-r--r--drivers/net/8139too.c13
-rw-r--r--drivers/net/Kconfig31
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c21
-rw-r--r--drivers/net/cxgb3/t3cdev.h3
-rw-r--r--drivers/net/dl2k.c2
-rw-r--r--drivers/net/dm9000.c1159
-rw-r--r--drivers/net/dm9000.h11
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/e1000/e1000_ethtool.c2
-rw-r--r--drivers/net/e1000/e1000_main.c34
-rw-r--r--drivers/net/e1000e/e1000.h4
-rw-r--r--drivers/net/e1000e/netdev.c51
-rw-r--r--drivers/net/fealnx.c43
-rw-r--r--drivers/net/forcedeth.c5
-rw-r--r--drivers/net/hamradio/dmascc.c2
-rw-r--r--drivers/net/igb/igb.h4
-rw-r--r--drivers/net/igb/igb_main.c50
-rw-r--r--drivers/net/ipg.c16
-rw-r--r--drivers/net/ixgbe/ixgbe.h9
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c11
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c114
-rw-r--r--drivers/net/netxen/netxen_nic_main.c18
-rw-r--r--drivers/net/pci-skeleton.c1
-rw-r--r--drivers/net/pcmcia/axnet_cs.c2
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c3
-rw-r--r--drivers/net/pppoe.c2
-rw-r--r--drivers/net/qla3xxx.c2
-rw-r--r--drivers/net/r6040.c2
-rw-r--r--drivers/net/s2io.c35
-rw-r--r--drivers/net/s2io.h4
-rw-r--r--drivers/net/sh_eth.c4
-rw-r--r--drivers/net/sh_eth.h4
-rw-r--r--drivers/net/tc35815.c4
-rw-r--r--drivers/net/tsi108_eth.c1
-rw-r--r--drivers/net/tulip/21142.c6
-rw-r--r--drivers/net/tulip/de2104x.c10
-rw-r--r--drivers/net/tulip/eeprom.c6
-rw-r--r--drivers/net/tulip/interrupt.c5
-rw-r--r--drivers/net/tulip/media.c5
-rw-r--r--drivers/net/tulip/pnic.c5
-rw-r--r--drivers/net/tulip/pnic2.c5
-rw-r--r--drivers/net/tulip/timer.c6
-rw-r--r--drivers/net/tulip/tulip.h4
-rw-r--r--drivers/net/tulip/tulip_core.c8
-rw-r--r--drivers/net/typhoon.c3
-rw-r--r--drivers/net/usb/rndis_host.c14
-rw-r--r--drivers/net/wan/x25_asy.c3
-rw-r--r--drivers/net/wireless/b43/leds.c3
-rw-r--r--drivers/net/wireless/b43/main.c12
-rw-r--r--drivers/net/wireless/b43legacy/dma.c2
-rw-r--r--drivers/net/wireless/b43legacy/main.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c33
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c33
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c2
-rw-r--r--drivers/net/wireless/rndis_wlan.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c36
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c38
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c36
-rw-r--r--drivers/pci/pci-acpi.c20
64 files changed, 1155 insertions, 870 deletions
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 85e2ba7fcfba..bf4830082a13 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -27,6 +27,8 @@
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/connector.h> 28#include <linux/connector.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/proc_fs.h>
31#include <linux/spinlock.h>
30 32
31#include <net/sock.h> 33#include <net/sock.h>
32 34
@@ -403,6 +405,40 @@ static void cn_callback(void *data)
403 mutex_unlock(&notify_lock); 405 mutex_unlock(&notify_lock);
404} 406}
405 407
408static int cn_proc_show(struct seq_file *m, void *v)
409{
410 struct cn_queue_dev *dev = cdev.cbdev;
411 struct cn_callback_entry *cbq;
412
413 seq_printf(m, "Name ID\n");
414
415 spin_lock_bh(&dev->queue_lock);
416
417 list_for_each_entry(cbq, &dev->queue_list, callback_entry) {
418 seq_printf(m, "%-15s %u:%u\n",
419 cbq->id.name,
420 cbq->id.id.idx,
421 cbq->id.id.val);
422 }
423
424 spin_unlock_bh(&dev->queue_lock);
425
426 return 0;
427}
428
429static int cn_proc_open(struct inode *inode, struct file *file)
430{
431 return single_open(file, cn_proc_show, NULL);
432}
433
434static const struct file_operations cn_file_ops = {
435 .owner = THIS_MODULE,
436 .open = cn_proc_open,
437 .read = seq_read,
438 .llseek = seq_lseek,
439 .release = single_release
440};
441
406static int __devinit cn_init(void) 442static int __devinit cn_init(void)
407{ 443{
408 struct cn_dev *dev = &cdev; 444 struct cn_dev *dev = &cdev;
@@ -434,6 +470,8 @@ static int __devinit cn_init(void)
434 return -EINVAL; 470 return -EINVAL;
435 } 471 }
436 472
473 proc_net_fops_create(&init_net, "connector", S_IRUGO, &cn_file_ops);
474
437 return 0; 475 return 0;
438} 476}
439 477
@@ -443,6 +481,8 @@ static void __devexit cn_fini(void)
443 481
444 cn_already_initialized = 0; 482 cn_already_initialized = 0;
445 483
484 proc_net_remove(&init_net, "connector");
485
446 cn_del_callback(&dev->id); 486 cn_del_callback(&dev->id);
447 cn_queue_free_dev(dev->cbdev); 487 cn_queue_free_dev(dev->cbdev);
448 netlink_kernel_release(dev->nls); 488 netlink_kernel_release(dev->nls);
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 2edda8cc7f99..aabad8ce7458 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1768,9 +1768,10 @@ vortex_timer(unsigned long data)
1768 case XCVR_MII: case XCVR_NWAY: 1768 case XCVR_MII: case XCVR_NWAY:
1769 { 1769 {
1770 ok = 1; 1770 ok = 1;
1771 spin_lock_bh(&vp->lock); 1771 /* Interrupts are already disabled */
1772 spin_lock(&vp->lock);
1772 vortex_check_media(dev, 0); 1773 vortex_check_media(dev, 0);
1773 spin_unlock_bh(&vp->lock); 1774 spin_unlock(&vp->lock);
1774 } 1775 }
1775 break; 1776 break;
1776 default: /* Other media types handled by Tx timeouts. */ 1777 default: /* Other media types handled by Tx timeouts. */
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 934db350e339..6011d6fabef0 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1213,7 +1213,6 @@ static int cp_close (struct net_device *dev)
1213 1213
1214 spin_unlock_irqrestore(&cp->lock, flags); 1214 spin_unlock_irqrestore(&cp->lock, flags);
1215 1215
1216 synchronize_irq(dev->irq);
1217 free_irq(dev->irq, dev); 1216 free_irq(dev->irq, dev);
1218 1217
1219 cp_free_rings(cp); 1218 cp_free_rings(cp);
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index b23a00c5b84f..75317a14ad1c 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -107,8 +107,8 @@
107#include <linux/mii.h> 107#include <linux/mii.h>
108#include <linux/completion.h> 108#include <linux/completion.h>
109#include <linux/crc32.h> 109#include <linux/crc32.h>
110#include <asm/io.h> 110#include <linux/io.h>
111#include <asm/uaccess.h> 111#include <linux/uaccess.h>
112#include <asm/irq.h> 112#include <asm/irq.h>
113 113
114#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION 114#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION
@@ -134,7 +134,7 @@
134 134
135#if RTL8139_DEBUG 135#if RTL8139_DEBUG
136/* note: prints function name for you */ 136/* note: prints function name for you */
137# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) 137# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
138#else 138#else
139# define DPRINTK(fmt, args...) 139# define DPRINTK(fmt, args...)
140#endif 140#endif
@@ -145,7 +145,7 @@
145# define assert(expr) \ 145# define assert(expr) \
146 if(unlikely(!(expr))) { \ 146 if(unlikely(!(expr))) { \
147 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ 147 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
148 #expr,__FILE__,__FUNCTION__,__LINE__); \ 148 #expr, __FILE__, __func__, __LINE__); \
149 } 149 }
150#endif 150#endif
151 151
@@ -219,7 +219,7 @@ enum {
219#define RTL8139B_IO_SIZE 256 219#define RTL8139B_IO_SIZE 256
220 220
221#define RTL8129_CAPS HAS_MII_XCVR 221#define RTL8129_CAPS HAS_MII_XCVR
222#define RTL8139_CAPS HAS_CHIP_XCVR|HAS_LNK_CHNG 222#define RTL8139_CAPS (HAS_CHIP_XCVR|HAS_LNK_CHNG)
223 223
224typedef enum { 224typedef enum {
225 RTL8139 = 0, 225 RTL8139 = 0,
@@ -1889,7 +1889,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1889} 1889}
1890 1890
1891#if RX_BUF_IDX == 3 1891#if RX_BUF_IDX == 3
1892static __inline__ void wrap_copy(struct sk_buff *skb, const unsigned char *ring, 1892static inline void wrap_copy(struct sk_buff *skb, const unsigned char *ring,
1893 u32 offset, unsigned int size) 1893 u32 offset, unsigned int size)
1894{ 1894{
1895 u32 left = RX_BUF_LEN - offset; 1895 u32 left = RX_BUF_LEN - offset;
@@ -2231,7 +2231,6 @@ static int rtl8139_close (struct net_device *dev)
2231 2231
2232 spin_unlock_irqrestore (&tp->lock, flags); 2232 spin_unlock_irqrestore (&tp->lock, flags);
2233 2233
2234 synchronize_irq (dev->irq); /* racy, but that's ok here */
2235 free_irq (dev->irq, dev); 2234 free_irq (dev->irq, dev);
2236 2235
2237 rtl8139_tx_clear (tp); 2236 rtl8139_tx_clear (tp);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 287d0873c60d..d85b9d067597 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -938,6 +938,23 @@ config DM9000
938 To compile this driver as a module, choose M here. The module 938 To compile this driver as a module, choose M here. The module
939 will be called dm9000. 939 will be called dm9000.
940 940
941config DM9000_DEBUGLEVEL
942 int "DM9000 maximum debug level"
943 depends on DM9000
944 default 4
945 help
946 The maximum level of debugging code compiled into the DM9000
947 driver.
948
949config DM9000_FORCE_SIMPLE_PHY_POLL
950 bool "Force simple NSR based PHY polling"
951 depends on DM9000
952 ---help---
953 This configuration forces the DM9000 to use the NSR's LinkStatus
954 bit to determine if the link is up or down instead of the more
955 costly MII PHY reads. Note, this will not work if the chip is
956 operating with an external PHY.
957
941config ENC28J60 958config ENC28J60
942 tristate "ENC28J60 support" 959 tristate "ENC28J60 support"
943 depends on EXPERIMENTAL && SPI && NET_ETHERNET 960 depends on EXPERIMENTAL && SPI && NET_ETHERNET
@@ -955,14 +972,6 @@ config ENC28J60_WRITEVERIFY
955 Enable the verify after the buffer write useful for debugging purpose. 972 Enable the verify after the buffer write useful for debugging purpose.
956 If unsure, say N. 973 If unsure, say N.
957 974
958config DM9000_DEBUGLEVEL
959 int "DM9000 maximum debug level"
960 depends on DM9000
961 default 4
962 help
963 The maximum level of debugging code compiled into the DM9000
964 driver.
965
966config SMC911X 975config SMC911X
967 tristate "SMSC LAN911[5678] support" 976 tristate "SMSC LAN911[5678] support"
968 select CRC32 977 select CRC32
@@ -2025,9 +2034,6 @@ config E1000E
2025 To compile this driver as a module, choose M here. The module 2034 To compile this driver as a module, choose M here. The module
2026 will be called e1000e. 2035 will be called e1000e.
2027 2036
2028config E1000E_ENABLED
2029 def_bool E1000E != n
2030
2031config IP1000 2037config IP1000
2032 tristate "IP1000 Gigabit Ethernet support" 2038 tristate "IP1000 Gigabit Ethernet support"
2033 depends on PCI && EXPERIMENTAL 2039 depends on PCI && EXPERIMENTAL
@@ -2462,7 +2468,8 @@ config EHEA
2462 2468
2463config IXGBE 2469config IXGBE
2464 tristate "Intel(R) 10GbE PCI Express adapters support" 2470 tristate "Intel(R) 10GbE PCI Express adapters support"
2465 depends on PCI 2471 depends on PCI && INET
2472 select INET_LRO
2466 ---help--- 2473 ---help---
2467 This driver supports Intel(R) 10GbE PCI Express family of 2474 This driver supports Intel(R) 10GbE PCI Express family of
2468 adapters. For more information on how to identify your adapter, go 2475 adapters. For more information on how to identify your adapter, go
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index ff9c013ce535..ae6ff5df779c 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -1248,6 +1248,25 @@ static inline void unregister_tdev(struct t3cdev *tdev)
1248 mutex_unlock(&cxgb3_db_lock); 1248 mutex_unlock(&cxgb3_db_lock);
1249} 1249}
1250 1250
1251static inline int adap2type(struct adapter *adapter)
1252{
1253 int type = 0;
1254
1255 switch (adapter->params.rev) {
1256 case T3_REV_A:
1257 type = T3A;
1258 break;
1259 case T3_REV_B:
1260 case T3_REV_B2:
1261 type = T3B;
1262 break;
1263 case T3_REV_C:
1264 type = T3C;
1265 break;
1266 }
1267 return type;
1268}
1269
1251void __devinit cxgb3_adapter_ofld(struct adapter *adapter) 1270void __devinit cxgb3_adapter_ofld(struct adapter *adapter)
1252{ 1271{
1253 struct t3cdev *tdev = &adapter->tdev; 1272 struct t3cdev *tdev = &adapter->tdev;
@@ -1257,7 +1276,7 @@ void __devinit cxgb3_adapter_ofld(struct adapter *adapter)
1257 cxgb3_set_dummy_ops(tdev); 1276 cxgb3_set_dummy_ops(tdev);
1258 tdev->send = t3_offload_tx; 1277 tdev->send = t3_offload_tx;
1259 tdev->ctl = cxgb_offload_ctl; 1278 tdev->ctl = cxgb_offload_ctl;
1260 tdev->type = adapter->params.rev == 0 ? T3A : T3B; 1279 tdev->type = adap2type(adapter);
1261 1280
1262 register_tdev(tdev); 1281 register_tdev(tdev);
1263} 1282}
diff --git a/drivers/net/cxgb3/t3cdev.h b/drivers/net/cxgb3/t3cdev.h
index a18c8a140424..8556628fd5af 100644
--- a/drivers/net/cxgb3/t3cdev.h
+++ b/drivers/net/cxgb3/t3cdev.h
@@ -45,7 +45,8 @@ struct cxgb3_client;
45 45
46enum t3ctype { 46enum t3ctype {
47 T3A = 0, 47 T3A = 0,
48 T3B 48 T3B,
49 T3C,
49}; 50};
50 51
51struct t3cdev { 52struct t3cdev {
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index 8277e89e552d..f8037110a522 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -1753,7 +1753,7 @@ rio_close (struct net_device *dev)
1753 1753
1754 /* Stop Tx and Rx logics */ 1754 /* Stop Tx and Rx logics */
1755 writel (TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl); 1755 writel (TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl);
1756 synchronize_irq (dev->irq); 1756
1757 free_irq (dev->irq, dev); 1757 free_irq (dev->irq, dev);
1758 del_timer_sync (&np->timer); 1758 del_timer_sync (&np->timer);
1759 1759
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 08a7365a7d10..952e10d686ec 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -44,9 +44,8 @@
44 44
45#define DM9000_PHY 0x40 /* PHY address 0x01 */ 45#define DM9000_PHY 0x40 /* PHY address 0x01 */
46 46
47#define CARDNAME "dm9000" 47#define CARDNAME "dm9000"
48#define PFX CARDNAME ": " 48#define DRV_VERSION "1.31"
49#define DRV_VERSION "1.30"
50 49
51#ifdef CONFIG_BLACKFIN 50#ifdef CONFIG_BLACKFIN
52#define readsb insb 51#define readsb insb
@@ -55,9 +54,6 @@
55#define writesb outsb 54#define writesb outsb
56#define writesw outsw 55#define writesw outsw
57#define writesl outsl 56#define writesl outsl
58#define DEFAULT_TRIGGER IRQF_TRIGGER_HIGH
59#else
60#define DEFAULT_TRIGGER (0)
61#endif 57#endif
62 58
63/* 59/*
@@ -85,23 +81,36 @@ MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
85 * these two devices. 81 * these two devices.
86 */ 82 */
87 83
84/* The driver supports the original DM9000E, and now the two newer
85 * devices, DM9000A and DM9000B.
86 */
87
88enum dm9000_type {
89 TYPE_DM9000E, /* original DM9000 */
90 TYPE_DM9000A,
91 TYPE_DM9000B
92};
93
88/* Structure/enum declaration ------------------------------- */ 94/* Structure/enum declaration ------------------------------- */
89typedef struct board_info { 95typedef struct board_info {
90 96
91 void __iomem *io_addr; /* Register I/O base address */ 97 void __iomem *io_addr; /* Register I/O base address */
92 void __iomem *io_data; /* Data I/O address */ 98 void __iomem *io_data; /* Data I/O address */
93 u16 irq; /* IRQ */ 99 u16 irq; /* IRQ */
94 100
95 u16 tx_pkt_cnt; 101 u16 tx_pkt_cnt;
96 u16 queue_pkt_len; 102 u16 queue_pkt_len;
97 u16 queue_start_addr; 103 u16 queue_start_addr;
98 u16 dbug_cnt; 104 u16 dbug_cnt;
99 u8 io_mode; /* 0:word, 2:byte */ 105 u8 io_mode; /* 0:word, 2:byte */
100 u8 phy_addr; 106 u8 phy_addr;
101 unsigned int flags; 107 u8 imr_all;
102 unsigned int in_suspend :1;
103 108
104 int debug_level; 109 unsigned int flags;
110 unsigned int in_suspend :1;
111 int debug_level;
112
113 enum dm9000_type type;
105 114
106 void (*inblk)(void __iomem *port, void *data, int length); 115 void (*inblk)(void __iomem *port, void *data, int length);
107 void (*outblk)(void __iomem *port, void *data, int length); 116 void (*outblk)(void __iomem *port, void *data, int length);
@@ -120,10 +129,10 @@ typedef struct board_info {
120 struct delayed_work phy_poll; 129 struct delayed_work phy_poll;
121 struct net_device *ndev; 130 struct net_device *ndev;
122 131
123 spinlock_t lock; 132 spinlock_t lock;
124 133
125 struct mii_if_info mii; 134 struct mii_if_info mii;
126 u32 msg_enable; 135 u32 msg_enable;
127} board_info_t; 136} board_info_t;
128 137
129/* debug code */ 138/* debug code */
@@ -140,26 +149,6 @@ static inline board_info_t *to_dm9000_board(struct net_device *dev)
140 return dev->priv; 149 return dev->priv;
141} 150}
142 151
143/* function declaration ------------------------------------- */
144static int dm9000_probe(struct platform_device *);
145static int dm9000_open(struct net_device *);
146static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
147static int dm9000_stop(struct net_device *);
148static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
149
150static void dm9000_init_dm9000(struct net_device *);
151
152static irqreturn_t dm9000_interrupt(int, void *);
153
154static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int reg);
155static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg,
156 int value);
157
158static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
159static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
160static void dm9000_rx(struct net_device *);
161static void dm9000_hash_table(struct net_device *);
162
163/* DM9000 network board routine ---------------------------- */ 152/* DM9000 network board routine ---------------------------- */
164 153
165static void 154static void
@@ -302,52 +291,135 @@ static void dm9000_set_io(struct board_info *db, int byte_width)
302 291
303static void dm9000_schedule_poll(board_info_t *db) 292static void dm9000_schedule_poll(board_info_t *db)
304{ 293{
305 schedule_delayed_work(&db->phy_poll, HZ * 2); 294 if (db->type == TYPE_DM9000E)
295 schedule_delayed_work(&db->phy_poll, HZ * 2);
306} 296}
307 297
308/* Our watchdog timed out. Called by the networking layer */ 298static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
309static void dm9000_timeout(struct net_device *dev) 299{
300 board_info_t *dm = to_dm9000_board(dev);
301
302 if (!netif_running(dev))
303 return -EINVAL;
304
305 return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL);
306}
307
308static unsigned int
309dm9000_read_locked(board_info_t *db, int reg)
310{ 310{
311 board_info_t *db = (board_info_t *) dev->priv;
312 u8 reg_save;
313 unsigned long flags; 311 unsigned long flags;
312 unsigned int ret;
314 313
315 /* Save previous register address */ 314 spin_lock_irqsave(&db->lock, flags);
316 reg_save = readb(db->io_addr); 315 ret = ior(db, reg);
317 spin_lock_irqsave(&db->lock,flags); 316 spin_unlock_irqrestore(&db->lock, flags);
318 317
319 netif_stop_queue(dev); 318 return ret;
320 dm9000_reset(db); 319}
321 dm9000_init_dm9000(dev);
322 /* We can accept TX packets again */
323 dev->trans_start = jiffies;
324 netif_wake_queue(dev);
325 320
326 /* Restore previous register address */ 321static int dm9000_wait_eeprom(board_info_t *db)
327 writeb(reg_save, db->io_addr); 322{
328 spin_unlock_irqrestore(&db->lock,flags); 323 unsigned int status;
324 int timeout = 8; /* wait max 8msec */
325
326 /* The DM9000 data sheets say we should be able to
327 * poll the ERRE bit in EPCR to wait for the EEPROM
328 * operation. From testing several chips, this bit
329 * does not seem to work.
330 *
331 * We attempt to use the bit, but fall back to the
332 * timeout (which is why we do not return an error
333 * on expiry) to say that the EEPROM operation has
334 * completed.
335 */
336
337 while (1) {
338 status = dm9000_read_locked(db, DM9000_EPCR);
339
340 if ((status & EPCR_ERRE) == 0)
341 break;
342
343 msleep(1);
344
345 if (timeout-- < 0) {
346 dev_dbg(db->dev, "timeout waiting EEPROM\n");
347 break;
348 }
349 }
350
351 return 0;
329} 352}
330 353
331#ifdef CONFIG_NET_POLL_CONTROLLER
332/* 354/*
333 *Used by netconsole 355 * Read a word data from EEPROM
334 */ 356 */
335static void dm9000_poll_controller(struct net_device *dev) 357static void
358dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
336{ 359{
337 disable_irq(dev->irq); 360 unsigned long flags;
338 dm9000_interrupt(dev->irq,dev); 361
339 enable_irq(dev->irq); 362 if (db->flags & DM9000_PLATF_NO_EEPROM) {
363 to[0] = 0xff;
364 to[1] = 0xff;
365 return;
366 }
367
368 mutex_lock(&db->addr_lock);
369
370 spin_lock_irqsave(&db->lock, flags);
371
372 iow(db, DM9000_EPAR, offset);
373 iow(db, DM9000_EPCR, EPCR_ERPRR);
374
375 spin_unlock_irqrestore(&db->lock, flags);
376
377 dm9000_wait_eeprom(db);
378
379 /* delay for at-least 150uS */
380 msleep(1);
381
382 spin_lock_irqsave(&db->lock, flags);
383
384 iow(db, DM9000_EPCR, 0x0);
385
386 to[0] = ior(db, DM9000_EPDRL);
387 to[1] = ior(db, DM9000_EPDRH);
388
389 spin_unlock_irqrestore(&db->lock, flags);
390
391 mutex_unlock(&db->addr_lock);
340} 392}
341#endif
342 393
343static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 394/*
395 * Write a word data to SROM
396 */
397static void
398dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
344{ 399{
345 board_info_t *dm = to_dm9000_board(dev); 400 unsigned long flags;
346 401
347 if (!netif_running(dev)) 402 if (db->flags & DM9000_PLATF_NO_EEPROM)
348 return -EINVAL; 403 return;
349 404
350 return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL); 405 mutex_lock(&db->addr_lock);
406
407 spin_lock_irqsave(&db->lock, flags);
408 iow(db, DM9000_EPAR, offset);
409 iow(db, DM9000_EPDRH, data[1]);
410 iow(db, DM9000_EPDRL, data[0]);
411 iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
412 spin_unlock_irqrestore(&db->lock, flags);
413
414 dm9000_wait_eeprom(db);
415
416 mdelay(1); /* wait at least 150uS to clear */
417
418 spin_lock_irqsave(&db->lock, flags);
419 iow(db, DM9000_EPCR, 0);
420 spin_unlock_irqrestore(&db->lock, flags);
421
422 mutex_unlock(&db->addr_lock);
351} 423}
352 424
353/* ethtool ops */ 425/* ethtool ops */
@@ -400,7 +472,14 @@ static int dm9000_nway_reset(struct net_device *dev)
400static u32 dm9000_get_link(struct net_device *dev) 472static u32 dm9000_get_link(struct net_device *dev)
401{ 473{
402 board_info_t *dm = to_dm9000_board(dev); 474 board_info_t *dm = to_dm9000_board(dev);
403 return mii_link_ok(&dm->mii); 475 u32 ret;
476
477 if (dm->flags & DM9000_PLATF_EXT_PHY)
478 ret = mii_link_ok(&dm->mii);
479 else
480 ret = dm9000_read_locked(dm, DM9000_NSR) & NSR_LINKST ? 1 : 0;
481
482 return ret;
404} 483}
405 484
406#define DM_EEPROM_MAGIC (0x444D394B) 485#define DM_EEPROM_MAGIC (0x444D394B)
@@ -472,15 +551,48 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
472 .set_eeprom = dm9000_set_eeprom, 551 .set_eeprom = dm9000_set_eeprom,
473}; 552};
474 553
554static void dm9000_show_carrier(board_info_t *db,
555 unsigned carrier, unsigned nsr)
556{
557 struct net_device *ndev = db->ndev;
558 unsigned ncr = dm9000_read_locked(db, DM9000_NCR);
559
560 if (carrier)
561 dev_info(db->dev, "%s: link up, %dMbps, %s-duplex, no LPA\n",
562 ndev->name, (nsr & NSR_SPEED) ? 10 : 100,
563 (ncr & NCR_FDX) ? "full" : "half");
564 else
565 dev_info(db->dev, "%s: link down\n", ndev->name);
566}
567
475static void 568static void
476dm9000_poll_work(struct work_struct *w) 569dm9000_poll_work(struct work_struct *w)
477{ 570{
478 struct delayed_work *dw = container_of(w, struct delayed_work, work); 571 struct delayed_work *dw = container_of(w, struct delayed_work, work);
479 board_info_t *db = container_of(dw, board_info_t, phy_poll); 572 board_info_t *db = container_of(dw, board_info_t, phy_poll);
573 struct net_device *ndev = db->ndev;
574
575 if (db->flags & DM9000_PLATF_SIMPLE_PHY &&
576 !(db->flags & DM9000_PLATF_EXT_PHY)) {
577 unsigned nsr = dm9000_read_locked(db, DM9000_NSR);
578 unsigned old_carrier = netif_carrier_ok(ndev) ? 1 : 0;
579 unsigned new_carrier;
480 580
481 mii_check_media(&db->mii, netif_msg_link(db), 0); 581 new_carrier = (nsr & NSR_LINKST) ? 1 : 0;
582
583 if (old_carrier != new_carrier) {
584 if (netif_msg_link(db))
585 dm9000_show_carrier(db, new_carrier, nsr);
586
587 if (!new_carrier)
588 netif_carrier_off(ndev);
589 else
590 netif_carrier_on(ndev);
591 }
592 } else
593 mii_check_media(&db->mii, netif_msg_link(db), 0);
482 594
483 if (netif_running(db->ndev)) 595 if (netif_running(ndev))
484 dm9000_schedule_poll(db); 596 dm9000_schedule_poll(db);
485} 597}
486 598
@@ -492,12 +604,6 @@ dm9000_poll_work(struct work_struct *w)
492static void 604static void
493dm9000_release_board(struct platform_device *pdev, struct board_info *db) 605dm9000_release_board(struct platform_device *pdev, struct board_info *db)
494{ 606{
495 if (db->data_res == NULL) {
496 if (db->addr_res != NULL)
497 release_mem_region((unsigned long)db->io_addr, 4);
498 return;
499 }
500
501 /* unmap our resources */ 607 /* unmap our resources */
502 608
503 iounmap(db->io_addr); 609 iounmap(db->io_addr);
@@ -505,288 +611,73 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db)
505 611
506 /* release the resources */ 612 /* release the resources */
507 613
508 if (db->data_req != NULL) { 614 release_resource(db->data_req);
509 release_resource(db->data_req); 615 kfree(db->data_req);
510 kfree(db->data_req);
511 }
512 616
513 if (db->addr_req != NULL) { 617 release_resource(db->addr_req);
514 release_resource(db->addr_req); 618 kfree(db->addr_req);
515 kfree(db->addr_req);
516 }
517} 619}
518 620
519#define res_size(_r) (((_r)->end - (_r)->start) + 1) 621static unsigned char dm9000_type_to_char(enum dm9000_type type)
520
521/*
522 * Search DM9000 board, allocate space and register it
523 */
524static int __devinit
525dm9000_probe(struct platform_device *pdev)
526{ 622{
527 struct dm9000_plat_data *pdata = pdev->dev.platform_data; 623 switch (type) {
528 struct board_info *db; /* Point a board information structure */ 624 case TYPE_DM9000E: return 'e';
529 struct net_device *ndev; 625 case TYPE_DM9000A: return 'a';
530 const unsigned char *mac_src; 626 case TYPE_DM9000B: return 'b';
531 unsigned long base;
532 int ret = 0;
533 int iosize;
534 int i;
535 u32 id_val;
536
537 /* Init network device */
538 ndev = alloc_etherdev(sizeof (struct board_info));
539 if (!ndev) {
540 dev_err(&pdev->dev, "could not allocate device.\n");
541 return -ENOMEM;
542 }
543
544 SET_NETDEV_DEV(ndev, &pdev->dev);
545
546 dev_dbg(&pdev->dev, "dm9000_probe()\n");
547
548 /* setup board info structure */
549 db = (struct board_info *) ndev->priv;
550 memset(db, 0, sizeof (*db));
551
552 db->dev = &pdev->dev;
553 db->ndev = ndev;
554
555 spin_lock_init(&db->lock);
556 mutex_init(&db->addr_lock);
557
558 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
559
560
561 if (pdev->num_resources < 2) {
562 ret = -ENODEV;
563 goto out;
564 } else if (pdev->num_resources == 2) {
565 base = pdev->resource[0].start;
566
567 if (!request_mem_region(base, 4, ndev->name)) {
568 ret = -EBUSY;
569 goto out;
570 }
571
572 ndev->base_addr = base;
573 ndev->irq = pdev->resource[1].start;
574 db->io_addr = (void __iomem *)base;
575 db->io_data = (void __iomem *)(base + 4);
576
577 /* ensure at least we have a default set of IO routines */
578 dm9000_set_io(db, 2);
579
580 } else {
581 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
582 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
583 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
584
585 if (db->addr_res == NULL || db->data_res == NULL ||
586 db->irq_res == NULL) {
587 dev_err(db->dev, "insufficient resources\n");
588 ret = -ENOENT;
589 goto out;
590 }
591
592 i = res_size(db->addr_res);
593 db->addr_req = request_mem_region(db->addr_res->start, i,
594 pdev->name);
595
596 if (db->addr_req == NULL) {
597 dev_err(db->dev, "cannot claim address reg area\n");
598 ret = -EIO;
599 goto out;
600 }
601
602 db->io_addr = ioremap(db->addr_res->start, i);
603
604 if (db->io_addr == NULL) {
605 dev_err(db->dev, "failed to ioremap address reg\n");
606 ret = -EINVAL;
607 goto out;
608 }
609
610 iosize = res_size(db->data_res);
611 db->data_req = request_mem_region(db->data_res->start, iosize,
612 pdev->name);
613
614 if (db->data_req == NULL) {
615 dev_err(db->dev, "cannot claim data reg area\n");
616 ret = -EIO;
617 goto out;
618 }
619
620 db->io_data = ioremap(db->data_res->start, iosize);
621
622 if (db->io_data == NULL) {
623 dev_err(db->dev,"failed to ioremap data reg\n");
624 ret = -EINVAL;
625 goto out;
626 }
627
628 /* fill in parameters for net-dev structure */
629
630 ndev->base_addr = (unsigned long)db->io_addr;
631 ndev->irq = db->irq_res->start;
632
633 /* ensure at least we have a default set of IO routines */
634 dm9000_set_io(db, iosize);
635 } 627 }
636 628
637 /* check to see if anything is being over-ridden */ 629 return '?';
638 if (pdata != NULL) {
639 /* check to see if the driver wants to over-ride the
640 * default IO width */
641
642 if (pdata->flags & DM9000_PLATF_8BITONLY)
643 dm9000_set_io(db, 1);
644
645 if (pdata->flags & DM9000_PLATF_16BITONLY)
646 dm9000_set_io(db, 2);
647
648 if (pdata->flags & DM9000_PLATF_32BITONLY)
649 dm9000_set_io(db, 4);
650
651 /* check to see if there are any IO routine
652 * over-rides */
653
654 if (pdata->inblk != NULL)
655 db->inblk = pdata->inblk;
656
657 if (pdata->outblk != NULL)
658 db->outblk = pdata->outblk;
659
660 if (pdata->dumpblk != NULL)
661 db->dumpblk = pdata->dumpblk;
662
663 db->flags = pdata->flags;
664 }
665
666 dm9000_reset(db);
667
668 /* try two times, DM9000 sometimes gets the first read wrong */
669 for (i = 0; i < 8; i++) {
670 id_val = ior(db, DM9000_VIDL);
671 id_val |= (u32)ior(db, DM9000_VIDH) << 8;
672 id_val |= (u32)ior(db, DM9000_PIDL) << 16;
673 id_val |= (u32)ior(db, DM9000_PIDH) << 24;
674
675 if (id_val == DM9000_ID)
676 break;
677 dev_err(db->dev, "read wrong id 0x%08x\n", id_val);
678 }
679
680 if (id_val != DM9000_ID) {
681 dev_err(db->dev, "wrong id: 0x%08x\n", id_val);
682 ret = -ENODEV;
683 goto out;
684 }
685
686 /* from this point we assume that we have found a DM9000 */
687
688 /* driver system function */
689 ether_setup(ndev);
690
691 ndev->open = &dm9000_open;
692 ndev->hard_start_xmit = &dm9000_start_xmit;
693 ndev->tx_timeout = &dm9000_timeout;
694 ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
695 ndev->stop = &dm9000_stop;
696 ndev->set_multicast_list = &dm9000_hash_table;
697 ndev->ethtool_ops = &dm9000_ethtool_ops;
698 ndev->do_ioctl = &dm9000_ioctl;
699
700#ifdef CONFIG_NET_POLL_CONTROLLER
701 ndev->poll_controller = &dm9000_poll_controller;
702#endif
703
704 db->msg_enable = NETIF_MSG_LINK;
705 db->mii.phy_id_mask = 0x1f;
706 db->mii.reg_num_mask = 0x1f;
707 db->mii.force_media = 0;
708 db->mii.full_duplex = 0;
709 db->mii.dev = ndev;
710 db->mii.mdio_read = dm9000_phy_read;
711 db->mii.mdio_write = dm9000_phy_write;
712
713 mac_src = "eeprom";
714
715 /* try reading the node address from the attached EEPROM */
716 for (i = 0; i < 6; i += 2)
717 dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
718
719 if (!is_valid_ether_addr(ndev->dev_addr)) {
720 /* try reading from mac */
721
722 mac_src = "chip";
723 for (i = 0; i < 6; i++)
724 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
725 }
726
727 if (!is_valid_ether_addr(ndev->dev_addr))
728 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
729 "set using ifconfig\n", ndev->name);
730
731 platform_set_drvdata(pdev, ndev);
732 ret = register_netdev(ndev);
733
734 if (ret == 0) {
735 DECLARE_MAC_BUF(mac);
736 printk("%s: dm9000 at %p,%p IRQ %d MAC: %s (%s)\n",
737 ndev->name, db->io_addr, db->io_data, ndev->irq,
738 print_mac(mac, ndev->dev_addr), mac_src);
739 }
740 return 0;
741
742out:
743 dev_err(db->dev, "not found (%d).\n", ret);
744
745 dm9000_release_board(pdev, db);
746 free_netdev(ndev);
747
748 return ret;
749} 630}
750 631
751/* 632/*
752 * Open the interface. 633 * Set DM9000 multicast address
753 * The interface is opened whenever "ifconfig" actives it.
754 */ 634 */
755static int 635static void
756dm9000_open(struct net_device *dev) 636dm9000_hash_table(struct net_device *dev)
757{ 637{
758 board_info_t *db = (board_info_t *) dev->priv; 638 board_info_t *db = (board_info_t *) dev->priv;
759 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK; 639 struct dev_mc_list *mcptr = dev->mc_list;
640 int mc_cnt = dev->mc_count;
641 int i, oft;
642 u32 hash_val;
643 u16 hash_table[4];
644 u8 rcr = RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN;
645 unsigned long flags;
760 646
761 if (netif_msg_ifup(db)) 647 dm9000_dbg(db, 1, "entering %s\n", __func__);
762 dev_dbg(db->dev, "enabling %s\n", dev->name);
763 648
764 /* If there is no IRQ type specified, default to something that 649 spin_lock_irqsave(&db->lock, flags);
765 * may work, and tell the user that this is a problem */
766 650
767 if (irqflags == IRQF_TRIGGER_NONE) { 651 for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
768 dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n"); 652 iow(db, oft, dev->dev_addr[i]);
769 irqflags = DEFAULT_TRIGGER;
770 }
771 653
772 irqflags |= IRQF_SHARED; 654 /* Clear Hash Table */
655 for (i = 0; i < 4; i++)
656 hash_table[i] = 0x0;
773 657
774 if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev)) 658 /* broadcast address */
775 return -EAGAIN; 659 hash_table[3] = 0x8000;
776 660
777 /* Initialize DM9000 board */ 661 if (dev->flags & IFF_PROMISC)
778 dm9000_reset(db); 662 rcr |= RCR_PRMSC;
779 dm9000_init_dm9000(dev);
780 663
781 /* Init driver variable */ 664 if (dev->flags & IFF_ALLMULTI)
782 db->dbug_cnt = 0; 665 rcr |= RCR_ALL;
783 666
784 mii_check_media(&db->mii, netif_msg_link(db), 1); 667 /* the multicast address in Hash Table : 64 bits */
785 netif_start_queue(dev); 668 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
786 669 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
787 dm9000_schedule_poll(db); 670 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
671 }
788 672
789 return 0; 673 /* Write the hash table to MAC MD table */
674 for (i = 0, oft = DM9000_MAR; i < 4; i++) {
675 iow(db, oft++, hash_table[i]);
676 iow(db, oft++, hash_table[i] >> 8);
677 }
678
679 iow(db, DM9000_RCR, rcr);
680 spin_unlock_irqrestore(&db->lock, flags);
790} 681}
791 682
792/* 683/*
@@ -795,7 +686,8 @@ dm9000_open(struct net_device *dev)
795static void 686static void
796dm9000_init_dm9000(struct net_device *dev) 687dm9000_init_dm9000(struct net_device *dev)
797{ 688{
798 board_info_t *db = (board_info_t *) dev->priv; 689 board_info_t *db = dev->priv;
690 unsigned int imr;
799 691
800 dm9000_dbg(db, 1, "entering %s\n", __func__); 692 dm9000_dbg(db, 1, "entering %s\n", __func__);
801 693
@@ -822,8 +714,14 @@ dm9000_init_dm9000(struct net_device *dev)
822 /* Set address filter table */ 714 /* Set address filter table */
823 dm9000_hash_table(dev); 715 dm9000_hash_table(dev);
824 716
717 imr = IMR_PAR | IMR_PTM | IMR_PRM;
718 if (db->type != TYPE_DM9000E)
719 imr |= IMR_LNKCHNG;
720
721 db->imr_all = imr;
722
825 /* Enable TX/RX interrupt mask */ 723 /* Enable TX/RX interrupt mask */
826 iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM); 724 iow(db, DM9000_IMR, imr);
827 725
828 /* Init Driver variable */ 726 /* Init Driver variable */
829 db->tx_pkt_cnt = 0; 727 db->tx_pkt_cnt = 0;
@@ -831,6 +729,29 @@ dm9000_init_dm9000(struct net_device *dev)
831 dev->trans_start = 0; 729 dev->trans_start = 0;
832} 730}
833 731
732/* Our watchdog timed out. Called by the networking layer */
733static void dm9000_timeout(struct net_device *dev)
734{
735 board_info_t *db = (board_info_t *) dev->priv;
736 u8 reg_save;
737 unsigned long flags;
738
739 /* Save previous register address */
740 reg_save = readb(db->io_addr);
741 spin_lock_irqsave(&db->lock, flags);
742
743 netif_stop_queue(dev);
744 dm9000_reset(db);
745 dm9000_init_dm9000(dev);
746 /* We can accept TX packets again */
747 dev->trans_start = jiffies;
748 netif_wake_queue(dev);
749
750 /* Restore previous register address */
751 writeb(reg_save, db->io_addr);
752 spin_unlock_irqrestore(&db->lock, flags);
753}
754
834/* 755/*
835 * Hardware start transmission. 756 * Hardware start transmission.
836 * Send a packet to media from the upper layer. 757 * Send a packet to media from the upper layer.
@@ -839,7 +760,7 @@ static int
839dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) 760dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
840{ 761{
841 unsigned long flags; 762 unsigned long flags;
842 board_info_t *db = (board_info_t *) dev->priv; 763 board_info_t *db = dev->priv;
843 764
844 dm9000_dbg(db, 3, "%s:\n", __func__); 765 dm9000_dbg(db, 3, "%s:\n", __func__);
845 766
@@ -879,50 +800,12 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
879 return 0; 800 return 0;
880} 801}
881 802
882static void
883dm9000_shutdown(struct net_device *dev)
884{
885 board_info_t *db = (board_info_t *) dev->priv;
886
887 /* RESET device */
888 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
889 iow(db, DM9000_GPR, 0x01); /* Power-Down PHY */
890 iow(db, DM9000_IMR, IMR_PAR); /* Disable all interrupt */
891 iow(db, DM9000_RCR, 0x00); /* Disable RX */
892}
893
894/*
895 * Stop the interface.
896 * The interface is stopped when it is brought.
897 */
898static int
899dm9000_stop(struct net_device *ndev)
900{
901 board_info_t *db = (board_info_t *) ndev->priv;
902
903 if (netif_msg_ifdown(db))
904 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
905
906 cancel_delayed_work_sync(&db->phy_poll);
907
908 netif_stop_queue(ndev);
909 netif_carrier_off(ndev);
910
911 /* free interrupt */
912 free_irq(ndev->irq, ndev);
913
914 dm9000_shutdown(ndev);
915
916 return 0;
917}
918
919/* 803/*
920 * DM9000 interrupt handler 804 * DM9000 interrupt handler
921 * receive the packet to upper layer, free the transmitted packet 805 * receive the packet to upper layer, free the transmitted packet
922 */ 806 */
923 807
924static void 808static void dm9000_tx_done(struct net_device *dev, board_info_t *db)
925dm9000_tx_done(struct net_device *dev, board_info_t * db)
926{ 809{
927 int tx_status = ior(db, DM9000_NSR); /* Got TX status */ 810 int tx_status = ior(db, DM9000_NSR); /* Got TX status */
928 811
@@ -945,52 +828,6 @@ dm9000_tx_done(struct net_device *dev, board_info_t * db)
945 } 828 }
946} 829}
947 830
948static irqreturn_t
949dm9000_interrupt(int irq, void *dev_id)
950{
951 struct net_device *dev = dev_id;
952 board_info_t *db = (board_info_t *) dev->priv;
953 int int_status;
954 u8 reg_save;
955
956 dm9000_dbg(db, 3, "entering %s\n", __func__);
957
958 /* A real interrupt coming */
959
960 spin_lock(&db->lock);
961
962 /* Save previous register address */
963 reg_save = readb(db->io_addr);
964
965 /* Disable all interrupts */
966 iow(db, DM9000_IMR, IMR_PAR);
967
968 /* Got DM9000 interrupt status */
969 int_status = ior(db, DM9000_ISR); /* Got ISR */
970 iow(db, DM9000_ISR, int_status); /* Clear ISR status */
971
972 if (netif_msg_intr(db))
973 dev_dbg(db->dev, "interrupt status %02x\n", int_status);
974
975 /* Received the coming packet */
976 if (int_status & ISR_PRS)
977 dm9000_rx(dev);
978
979 /* Trnasmit Interrupt check */
980 if (int_status & ISR_PTS)
981 dm9000_tx_done(dev, db);
982
983 /* Re-enable interrupt mask */
984 iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
985
986 /* Restore previous register address */
987 writeb(reg_save, db->io_addr);
988
989 spin_unlock(&db->lock);
990
991 return IRQ_HANDLED;
992}
993
994struct dm9000_rxhdr { 831struct dm9000_rxhdr {
995 u8 RxPktReady; 832 u8 RxPktReady;
996 u8 RxStatus; 833 u8 RxStatus;
@@ -1094,173 +931,109 @@ dm9000_rx(struct net_device *dev)
1094 } while (rxbyte == DM9000_PKT_RDY); 931 } while (rxbyte == DM9000_PKT_RDY);
1095} 932}
1096 933
1097static unsigned int 934static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
1098dm9000_read_locked(board_info_t *db, int reg)
1099{ 935{
1100 unsigned long flags; 936 struct net_device *dev = dev_id;
1101 unsigned int ret; 937 board_info_t *db = dev->priv;
938 int int_status;
939 u8 reg_save;
1102 940
1103 spin_lock_irqsave(&db->lock, flags); 941 dm9000_dbg(db, 3, "entering %s\n", __func__);
1104 ret = ior(db, reg);
1105 spin_unlock_irqrestore(&db->lock, flags);
1106 942
1107 return ret; 943 /* A real interrupt coming */
1108}
1109 944
1110static int dm9000_wait_eeprom(board_info_t *db) 945 spin_lock(&db->lock);
1111{
1112 unsigned int status;
1113 int timeout = 8; /* wait max 8msec */
1114 946
1115 /* The DM9000 data sheets say we should be able to 947 /* Save previous register address */
1116 * poll the ERRE bit in EPCR to wait for the EEPROM 948 reg_save = readb(db->io_addr);
1117 * operation. From testing several chips, this bit
1118 * does not seem to work.
1119 *
1120 * We attempt to use the bit, but fall back to the
1121 * timeout (which is why we do not return an error
1122 * on expiry) to say that the EEPROM operation has
1123 * completed.
1124 */
1125 949
1126 while (1) { 950 /* Disable all interrupts */
1127 status = dm9000_read_locked(db, DM9000_EPCR); 951 iow(db, DM9000_IMR, IMR_PAR);
1128 952
1129 if ((status & EPCR_ERRE) == 0) 953 /* Got DM9000 interrupt status */
1130 break; 954 int_status = ior(db, DM9000_ISR); /* Got ISR */
955 iow(db, DM9000_ISR, int_status); /* Clear ISR status */
1131 956
1132 if (timeout-- < 0) { 957 if (netif_msg_intr(db))
1133 dev_dbg(db->dev, "timeout waiting EEPROM\n"); 958 dev_dbg(db->dev, "interrupt status %02x\n", int_status);
1134 break;
1135 }
1136 }
1137 959
1138 return 0; 960 /* Received the coming packet */
1139} 961 if (int_status & ISR_PRS)
962 dm9000_rx(dev);
1140 963
1141/* 964 /* Trnasmit Interrupt check */
1142 * Read a word data from EEPROM 965 if (int_status & ISR_PTS)
1143 */ 966 dm9000_tx_done(dev, db);
1144static void
1145dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
1146{
1147 unsigned long flags;
1148 967
1149 if (db->flags & DM9000_PLATF_NO_EEPROM) { 968 if (db->type != TYPE_DM9000E) {
1150 to[0] = 0xff; 969 if (int_status & ISR_LNKCHNG) {
1151 to[1] = 0xff; 970 /* fire a link-change request */
1152 return; 971 schedule_delayed_work(&db->phy_poll, 1);
972 }
1153 } 973 }
1154 974
1155 mutex_lock(&db->addr_lock); 975 /* Re-enable interrupt mask */
1156 976 iow(db, DM9000_IMR, db->imr_all);
1157 spin_lock_irqsave(&db->lock, flags);
1158
1159 iow(db, DM9000_EPAR, offset);
1160 iow(db, DM9000_EPCR, EPCR_ERPRR);
1161
1162 spin_unlock_irqrestore(&db->lock, flags);
1163
1164 dm9000_wait_eeprom(db);
1165
1166 /* delay for at-least 150uS */
1167 msleep(1);
1168
1169 spin_lock_irqsave(&db->lock, flags);
1170
1171 iow(db, DM9000_EPCR, 0x0);
1172 977
1173 to[0] = ior(db, DM9000_EPDRL); 978 /* Restore previous register address */
1174 to[1] = ior(db, DM9000_EPDRH); 979 writeb(reg_save, db->io_addr);
1175 980
1176 spin_unlock_irqrestore(&db->lock, flags); 981 spin_unlock(&db->lock);
1177 982
1178 mutex_unlock(&db->addr_lock); 983 return IRQ_HANDLED;
1179} 984}
1180 985
986#ifdef CONFIG_NET_POLL_CONTROLLER
1181/* 987/*
1182 * Write a word data to SROM 988 *Used by netconsole
1183 */ 989 */
1184static void 990static void dm9000_poll_controller(struct net_device *dev)
1185dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
1186{ 991{
1187 unsigned long flags; 992 disable_irq(dev->irq);
1188 993 dm9000_interrupt(dev->irq, dev);
1189 if (db->flags & DM9000_PLATF_NO_EEPROM) 994 enable_irq(dev->irq);
1190 return;
1191
1192 mutex_lock(&db->addr_lock);
1193
1194 spin_lock_irqsave(&db->lock, flags);
1195 iow(db, DM9000_EPAR, offset);
1196 iow(db, DM9000_EPDRH, data[1]);
1197 iow(db, DM9000_EPDRL, data[0]);
1198 iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
1199 spin_unlock_irqrestore(&db->lock, flags);
1200
1201 dm9000_wait_eeprom(db);
1202
1203 mdelay(1); /* wait at least 150uS to clear */
1204
1205 spin_lock_irqsave(&db->lock, flags);
1206 iow(db, DM9000_EPCR, 0);
1207 spin_unlock_irqrestore(&db->lock, flags);
1208
1209 mutex_unlock(&db->addr_lock);
1210} 995}
996#endif
1211 997
1212/* 998/*
1213 * Set DM9000 multicast address 999 * Open the interface.
1000 * The interface is opened whenever "ifconfig" actives it.
1214 */ 1001 */
1215static void 1002static int
1216dm9000_hash_table(struct net_device *dev) 1003dm9000_open(struct net_device *dev)
1217{ 1004{
1218 board_info_t *db = (board_info_t *) dev->priv; 1005 board_info_t *db = dev->priv;
1219 struct dev_mc_list *mcptr = dev->mc_list; 1006 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
1220 int mc_cnt = dev->mc_count;
1221 int i, oft;
1222 u32 hash_val;
1223 u16 hash_table[4];
1224 u8 rcr = RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN;
1225 unsigned long flags;
1226
1227 dm9000_dbg(db, 1, "entering %s\n", __func__);
1228 1007
1229 spin_lock_irqsave(&db->lock, flags); 1008 if (netif_msg_ifup(db))
1009 dev_dbg(db->dev, "enabling %s\n", dev->name);
1230 1010
1231 for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++) 1011 /* If there is no IRQ type specified, default to something that
1232 iow(db, oft, dev->dev_addr[i]); 1012 * may work, and tell the user that this is a problem */
1233 1013
1234 /* Clear Hash Table */ 1014 if (irqflags == IRQF_TRIGGER_NONE)
1235 for (i = 0; i < 4; i++) 1015 dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
1236 hash_table[i] = 0x0;
1237 1016
1238 /* broadcast address */ 1017 irqflags |= IRQF_SHARED;
1239 hash_table[3] = 0x8000;
1240 1018
1241 if (dev->flags & IFF_PROMISC) 1019 if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
1242 rcr |= RCR_PRMSC; 1020 return -EAGAIN;
1243 1021
1244 if (dev->flags & IFF_ALLMULTI) 1022 /* Initialize DM9000 board */
1245 rcr |= RCR_ALL; 1023 dm9000_reset(db);
1024 dm9000_init_dm9000(dev);
1246 1025
1247 /* the multicast address in Hash Table : 64 bits */ 1026 /* Init driver variable */
1248 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1027 db->dbug_cnt = 0;
1249 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
1250 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
1251 }
1252 1028
1253 /* Write the hash table to MAC MD table */ 1029 mii_check_media(&db->mii, netif_msg_link(db), 1);
1254 for (i = 0, oft = DM9000_MAR; i < 4; i++) { 1030 netif_start_queue(dev);
1255 iow(db, oft++, hash_table[i]); 1031
1256 iow(db, oft++, hash_table[i] >> 8); 1032 dm9000_schedule_poll(db);
1257 }
1258 1033
1259 iow(db, DM9000_RCR, rcr); 1034 return 0;
1260 spin_unlock_irqrestore(&db->lock, flags);
1261} 1035}
1262 1036
1263
1264/* 1037/*
1265 * Sleep, either by using msleep() or if we are suspending, then 1038 * Sleep, either by using msleep() or if we are suspending, then
1266 * use mdelay() to sleep. 1039 * use mdelay() to sleep.
@@ -1323,7 +1096,8 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1323 * Write a word to phyxcer 1096 * Write a word to phyxcer
1324 */ 1097 */
1325static void 1098static void
1326dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) 1099dm9000_phy_write(struct net_device *dev,
1100 int phyaddr_unused, int reg, int value)
1327{ 1101{
1328 board_info_t *db = (board_info_t *) dev->priv; 1102 board_info_t *db = (board_info_t *) dev->priv;
1329 unsigned long flags; 1103 unsigned long flags;
@@ -1363,6 +1137,273 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1363 mutex_unlock(&db->addr_lock); 1137 mutex_unlock(&db->addr_lock);
1364} 1138}
1365 1139
1140static void
1141dm9000_shutdown(struct net_device *dev)
1142{
1143 board_info_t *db = dev->priv;
1144
1145 /* RESET device */
1146 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
1147 iow(db, DM9000_GPR, 0x01); /* Power-Down PHY */
1148 iow(db, DM9000_IMR, IMR_PAR); /* Disable all interrupt */
1149 iow(db, DM9000_RCR, 0x00); /* Disable RX */
1150}
1151
1152/*
1153 * Stop the interface.
1154 * The interface is stopped when it is brought.
1155 */
1156static int
1157dm9000_stop(struct net_device *ndev)
1158{
1159 board_info_t *db = ndev->priv;
1160
1161 if (netif_msg_ifdown(db))
1162 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
1163
1164 cancel_delayed_work_sync(&db->phy_poll);
1165
1166 netif_stop_queue(ndev);
1167 netif_carrier_off(ndev);
1168
1169 /* free interrupt */
1170 free_irq(ndev->irq, ndev);
1171
1172 dm9000_shutdown(ndev);
1173
1174 return 0;
1175}
1176
1177#define res_size(_r) (((_r)->end - (_r)->start) + 1)
1178
1179/*
1180 * Search DM9000 board, allocate space and register it
1181 */
1182static int __devinit
1183dm9000_probe(struct platform_device *pdev)
1184{
1185 struct dm9000_plat_data *pdata = pdev->dev.platform_data;
1186 struct board_info *db; /* Point a board information structure */
1187 struct net_device *ndev;
1188 const unsigned char *mac_src;
1189 int ret = 0;
1190 int iosize;
1191 int i;
1192 u32 id_val;
1193
1194 /* Init network device */
1195 ndev = alloc_etherdev(sizeof(struct board_info));
1196 if (!ndev) {
1197 dev_err(&pdev->dev, "could not allocate device.\n");
1198 return -ENOMEM;
1199 }
1200
1201 SET_NETDEV_DEV(ndev, &pdev->dev);
1202
1203 dev_dbg(&pdev->dev, "dm9000_probe()\n");
1204
1205 /* setup board info structure */
1206 db = ndev->priv;
1207 memset(db, 0, sizeof(*db));
1208
1209 db->dev = &pdev->dev;
1210 db->ndev = ndev;
1211
1212 spin_lock_init(&db->lock);
1213 mutex_init(&db->addr_lock);
1214
1215 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
1216
1217 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1218 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1219 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1220
1221 if (db->addr_res == NULL || db->data_res == NULL ||
1222 db->irq_res == NULL) {
1223 dev_err(db->dev, "insufficient resources\n");
1224 ret = -ENOENT;
1225 goto out;
1226 }
1227
1228 iosize = res_size(db->addr_res);
1229 db->addr_req = request_mem_region(db->addr_res->start, iosize,
1230 pdev->name);
1231
1232 if (db->addr_req == NULL) {
1233 dev_err(db->dev, "cannot claim address reg area\n");
1234 ret = -EIO;
1235 goto out;
1236 }
1237
1238 db->io_addr = ioremap(db->addr_res->start, iosize);
1239
1240 if (db->io_addr == NULL) {
1241 dev_err(db->dev, "failed to ioremap address reg\n");
1242 ret = -EINVAL;
1243 goto out;
1244 }
1245
1246 iosize = res_size(db->data_res);
1247 db->data_req = request_mem_region(db->data_res->start, iosize,
1248 pdev->name);
1249
1250 if (db->data_req == NULL) {
1251 dev_err(db->dev, "cannot claim data reg area\n");
1252 ret = -EIO;
1253 goto out;
1254 }
1255
1256 db->io_data = ioremap(db->data_res->start, iosize);
1257
1258 if (db->io_data == NULL) {
1259 dev_err(db->dev, "failed to ioremap data reg\n");
1260 ret = -EINVAL;
1261 goto out;
1262 }
1263
1264 /* fill in parameters for net-dev structure */
1265 ndev->base_addr = (unsigned long)db->io_addr;
1266 ndev->irq = db->irq_res->start;
1267
1268 /* ensure at least we have a default set of IO routines */
1269 dm9000_set_io(db, iosize);
1270
1271 /* check to see if anything is being over-ridden */
1272 if (pdata != NULL) {
1273 /* check to see if the driver wants to over-ride the
1274 * default IO width */
1275
1276 if (pdata->flags & DM9000_PLATF_8BITONLY)
1277 dm9000_set_io(db, 1);
1278
1279 if (pdata->flags & DM9000_PLATF_16BITONLY)
1280 dm9000_set_io(db, 2);
1281
1282 if (pdata->flags & DM9000_PLATF_32BITONLY)
1283 dm9000_set_io(db, 4);
1284
1285 /* check to see if there are any IO routine
1286 * over-rides */
1287
1288 if (pdata->inblk != NULL)
1289 db->inblk = pdata->inblk;
1290
1291 if (pdata->outblk != NULL)
1292 db->outblk = pdata->outblk;
1293
1294 if (pdata->dumpblk != NULL)
1295 db->dumpblk = pdata->dumpblk;
1296
1297 db->flags = pdata->flags;
1298 }
1299
1300#ifdef CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL
1301 db->flags |= DM9000_PLATF_SIMPLE_PHY;
1302#endif
1303
1304 dm9000_reset(db);
1305
1306 /* try multiple times, DM9000 sometimes gets the read wrong */
1307 for (i = 0; i < 8; i++) {
1308 id_val = ior(db, DM9000_VIDL);
1309 id_val |= (u32)ior(db, DM9000_VIDH) << 8;
1310 id_val |= (u32)ior(db, DM9000_PIDL) << 16;
1311 id_val |= (u32)ior(db, DM9000_PIDH) << 24;
1312
1313 if (id_val == DM9000_ID)
1314 break;
1315 dev_err(db->dev, "read wrong id 0x%08x\n", id_val);
1316 }
1317
1318 if (id_val != DM9000_ID) {
1319 dev_err(db->dev, "wrong id: 0x%08x\n", id_val);
1320 ret = -ENODEV;
1321 goto out;
1322 }
1323
1324 /* Identify what type of DM9000 we are working on */
1325
1326 id_val = ior(db, DM9000_CHIPR);
1327 dev_dbg(db->dev, "dm9000 revision 0x%02x\n", id_val);
1328
1329 switch (id_val) {
1330 case CHIPR_DM9000A:
1331 db->type = TYPE_DM9000A;
1332 break;
1333 case CHIPR_DM9000B:
1334 db->type = TYPE_DM9000B;
1335 break;
1336 default:
1337 dev_dbg(db->dev, "ID %02x => defaulting to DM9000E\n", id_val);
1338 db->type = TYPE_DM9000E;
1339 }
1340
1341 /* from this point we assume that we have found a DM9000 */
1342
1343 /* driver system function */
1344 ether_setup(ndev);
1345
1346 ndev->open = &dm9000_open;
1347 ndev->hard_start_xmit = &dm9000_start_xmit;
1348 ndev->tx_timeout = &dm9000_timeout;
1349 ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
1350 ndev->stop = &dm9000_stop;
1351 ndev->set_multicast_list = &dm9000_hash_table;
1352 ndev->ethtool_ops = &dm9000_ethtool_ops;
1353 ndev->do_ioctl = &dm9000_ioctl;
1354
1355#ifdef CONFIG_NET_POLL_CONTROLLER
1356 ndev->poll_controller = &dm9000_poll_controller;
1357#endif
1358
1359 db->msg_enable = NETIF_MSG_LINK;
1360 db->mii.phy_id_mask = 0x1f;
1361 db->mii.reg_num_mask = 0x1f;
1362 db->mii.force_media = 0;
1363 db->mii.full_duplex = 0;
1364 db->mii.dev = ndev;
1365 db->mii.mdio_read = dm9000_phy_read;
1366 db->mii.mdio_write = dm9000_phy_write;
1367
1368 mac_src = "eeprom";
1369
1370 /* try reading the node address from the attached EEPROM */
1371 for (i = 0; i < 6; i += 2)
1372 dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
1373
1374 if (!is_valid_ether_addr(ndev->dev_addr)) {
1375 /* try reading from mac */
1376
1377 mac_src = "chip";
1378 for (i = 0; i < 6; i++)
1379 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
1380 }
1381
1382 if (!is_valid_ether_addr(ndev->dev_addr))
1383 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
1384 "set using ifconfig\n", ndev->name);
1385
1386 platform_set_drvdata(pdev, ndev);
1387 ret = register_netdev(ndev);
1388
1389 if (ret == 0) {
1390 DECLARE_MAC_BUF(mac);
1391 printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %s (%s)\n",
1392 ndev->name, dm9000_type_to_char(db->type),
1393 db->io_addr, db->io_data, ndev->irq,
1394 print_mac(mac, ndev->dev_addr), mac_src);
1395 }
1396 return 0;
1397
1398out:
1399 dev_err(db->dev, "not found (%d).\n", ret);
1400
1401 dm9000_release_board(pdev, db);
1402 free_netdev(ndev);
1403
1404 return ret;
1405}
1406
1366static int 1407static int
1367dm9000_drv_suspend(struct platform_device *dev, pm_message_t state) 1408dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
1368{ 1409{
@@ -1432,7 +1473,7 @@ dm9000_init(void)
1432{ 1473{
1433 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION); 1474 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
1434 1475
1435 return platform_driver_register(&dm9000_driver); /* search board and register */ 1476 return platform_driver_register(&dm9000_driver);
1436} 1477}
1437 1478
1438static void __exit 1479static void __exit
diff --git a/drivers/net/dm9000.h b/drivers/net/dm9000.h
index 82cad360bafc..ba25cf541420 100644
--- a/drivers/net/dm9000.h
+++ b/drivers/net/dm9000.h
@@ -45,6 +45,9 @@
45#define DM9000_CHIPR 0x2C 45#define DM9000_CHIPR 0x2C
46#define DM9000_SMCR 0x2F 46#define DM9000_SMCR 0x2F
47 47
48#define CHIPR_DM9000A 0x19
49#define CHIPR_DM9000B 0x1B
50
48#define DM9000_MRCMDX 0xF0 51#define DM9000_MRCMDX 0xF0
49#define DM9000_MRCMD 0xF2 52#define DM9000_MRCMD 0xF2
50#define DM9000_MRRL 0xF4 53#define DM9000_MRRL 0xF4
@@ -131,5 +134,13 @@
131#define DM9000_PKT_RDY 0x01 /* Packet ready to receive */ 134#define DM9000_PKT_RDY 0x01 /* Packet ready to receive */
132#define DM9000_PKT_MAX 1536 /* Received packet max size */ 135#define DM9000_PKT_MAX 1536 /* Received packet max size */
133 136
137/* DM9000A / DM9000B definitions */
138
139#define IMR_LNKCHNG (1<<5)
140#define IMR_UNDERRUN (1<<4)
141
142#define ISR_LNKCHNG (1<<5)
143#define ISR_UNDERRUN (1<<4)
144
134#endif /* _DM9000X_H_ */ 145#endif /* _DM9000X_H_ */
135 146
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index f3cba5e24ec5..1037b1332312 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1803,6 +1803,8 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1803 if (rx->prev->skb) { 1803 if (rx->prev->skb) {
1804 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; 1804 struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data;
1805 put_unaligned_le32(rx->dma_addr, &prev_rfd->link); 1805 put_unaligned_le32(rx->dma_addr, &prev_rfd->link);
1806 pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr,
1807 sizeof(struct rfd), PCI_DMA_TODEVICE);
1806 } 1808 }
1807 1809
1808 return 0; 1810 return 0;
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 701531e72e7b..a3f6a9c72ec8 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -347,7 +347,7 @@ e1000_set_tso(struct net_device *netdev, u32 data)
347 else 347 else
348 netdev->features &= ~NETIF_F_TSO; 348 netdev->features &= ~NETIF_F_TSO;
349 349
350 if (data) 350 if (data && (adapter->hw.mac_type > e1000_82547_rev_2))
351 netdev->features |= NETIF_F_TSO6; 351 netdev->features |= NETIF_F_TSO6;
352 else 352 else
353 netdev->features &= ~NETIF_F_TSO6; 353 netdev->features &= ~NETIF_F_TSO6;
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 59579b1d8843..311ca266bd77 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -47,12 +47,6 @@ static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation
47 * Macro expands to... 47 * Macro expands to...
48 * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} 48 * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
49 */ 49 */
50#ifdef CONFIG_E1000E_ENABLED
51 #define PCIE(x)
52#else
53 #define PCIE(x) x,
54#endif
55
56static struct pci_device_id e1000_pci_tbl[] = { 50static struct pci_device_id e1000_pci_tbl[] = {
57 INTEL_E1000_ETHERNET_DEVICE(0x1000), 51 INTEL_E1000_ETHERNET_DEVICE(0x1000),
58 INTEL_E1000_ETHERNET_DEVICE(0x1001), 52 INTEL_E1000_ETHERNET_DEVICE(0x1001),
@@ -79,14 +73,6 @@ static struct pci_device_id e1000_pci_tbl[] = {
79 INTEL_E1000_ETHERNET_DEVICE(0x1026), 73 INTEL_E1000_ETHERNET_DEVICE(0x1026),
80 INTEL_E1000_ETHERNET_DEVICE(0x1027), 74 INTEL_E1000_ETHERNET_DEVICE(0x1027),
81 INTEL_E1000_ETHERNET_DEVICE(0x1028), 75 INTEL_E1000_ETHERNET_DEVICE(0x1028),
82PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1049))
83PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104A))
84PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104B))
85PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104C))
86PCIE( INTEL_E1000_ETHERNET_DEVICE(0x104D))
87PCIE( INTEL_E1000_ETHERNET_DEVICE(0x105E))
88PCIE( INTEL_E1000_ETHERNET_DEVICE(0x105F))
89PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1060))
90 INTEL_E1000_ETHERNET_DEVICE(0x1075), 76 INTEL_E1000_ETHERNET_DEVICE(0x1075),
91 INTEL_E1000_ETHERNET_DEVICE(0x1076), 77 INTEL_E1000_ETHERNET_DEVICE(0x1076),
92 INTEL_E1000_ETHERNET_DEVICE(0x1077), 78 INTEL_E1000_ETHERNET_DEVICE(0x1077),
@@ -95,28 +81,9 @@ PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1060))
95 INTEL_E1000_ETHERNET_DEVICE(0x107A), 81 INTEL_E1000_ETHERNET_DEVICE(0x107A),
96 INTEL_E1000_ETHERNET_DEVICE(0x107B), 82 INTEL_E1000_ETHERNET_DEVICE(0x107B),
97 INTEL_E1000_ETHERNET_DEVICE(0x107C), 83 INTEL_E1000_ETHERNET_DEVICE(0x107C),
98PCIE( INTEL_E1000_ETHERNET_DEVICE(0x107D))
99PCIE( INTEL_E1000_ETHERNET_DEVICE(0x107E))
100PCIE( INTEL_E1000_ETHERNET_DEVICE(0x107F))
101 INTEL_E1000_ETHERNET_DEVICE(0x108A), 84 INTEL_E1000_ETHERNET_DEVICE(0x108A),
102PCIE( INTEL_E1000_ETHERNET_DEVICE(0x108B))
103PCIE( INTEL_E1000_ETHERNET_DEVICE(0x108C))
104PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1096))
105PCIE( INTEL_E1000_ETHERNET_DEVICE(0x1098))
106 INTEL_E1000_ETHERNET_DEVICE(0x1099), 85 INTEL_E1000_ETHERNET_DEVICE(0x1099),
107PCIE( INTEL_E1000_ETHERNET_DEVICE(0x109A))
108PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10A4))
109PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10A5))
110 INTEL_E1000_ETHERNET_DEVICE(0x10B5), 86 INTEL_E1000_ETHERNET_DEVICE(0x10B5),
111PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10B9))
112PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10BA))
113PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10BB))
114PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10BC))
115PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10C4))
116PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10C5))
117PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10D5))
118PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10D9))
119PCIE( INTEL_E1000_ETHERNET_DEVICE(0x10DA))
120 /* required last entry */ 87 /* required last entry */
121 {0,} 88 {0,}
122}; 89};
@@ -5284,7 +5251,6 @@ e1000_netpoll(struct net_device *netdev)
5284 5251
5285 disable_irq(adapter->pdev->irq); 5252 disable_irq(adapter->pdev->irq);
5286 e1000_intr(adapter->pdev->irq, netdev); 5253 e1000_intr(adapter->pdev->irq, netdev);
5287 e1000_clean_tx_irq(adapter, adapter->tx_ring);
5288#ifndef CONFIG_E1000_NAPI 5254#ifndef CONFIG_E1000_NAPI
5289 adapter->clean_rx(adapter, adapter->rx_ring); 5255 adapter->clean_rx(adapter, adapter->rx_ring);
5290#endif 5256#endif
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index d3bc6f8101fa..4a4f62e002b2 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -283,6 +283,10 @@ struct e1000_adapter {
283 unsigned long led_status; 283 unsigned long led_status;
284 284
285 unsigned int flags; 285 unsigned int flags;
286
287 /* for ioport free */
288 int bars;
289 int need_ioport;
286}; 290};
287 291
288struct e1000_info { 292struct e1000_info {
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index ccb8ca2cbb2b..acdd616c96f6 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2535,7 +2535,8 @@ void e1000e_down(struct e1000_adapter *adapter)
2535 adapter->link_speed = 0; 2535 adapter->link_speed = 0;
2536 adapter->link_duplex = 0; 2536 adapter->link_duplex = 0;
2537 2537
2538 e1000e_reset(adapter); 2538 if (!pci_channel_offline(adapter->pdev))
2539 e1000e_reset(adapter);
2539 e1000_clean_tx_ring(adapter); 2540 e1000_clean_tx_ring(adapter);
2540 e1000_clean_rx_ring(adapter); 2541 e1000_clean_rx_ring(adapter);
2541 2542
@@ -4002,7 +4003,11 @@ static int e1000_resume(struct pci_dev *pdev)
4002 pci_set_power_state(pdev, PCI_D0); 4003 pci_set_power_state(pdev, PCI_D0);
4003 pci_restore_state(pdev); 4004 pci_restore_state(pdev);
4004 e1000e_disable_l1aspm(pdev); 4005 e1000e_disable_l1aspm(pdev);
4005 err = pci_enable_device(pdev); 4006
4007 if (adapter->need_ioport)
4008 err = pci_enable_device(pdev);
4009 else
4010 err = pci_enable_device_mem(pdev);
4006 if (err) { 4011 if (err) {
4007 dev_err(&pdev->dev, 4012 dev_err(&pdev->dev,
4008 "Cannot enable PCI device from suspend\n"); 4013 "Cannot enable PCI device from suspend\n");
@@ -4103,9 +4108,14 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4103 struct net_device *netdev = pci_get_drvdata(pdev); 4108 struct net_device *netdev = pci_get_drvdata(pdev);
4104 struct e1000_adapter *adapter = netdev_priv(netdev); 4109 struct e1000_adapter *adapter = netdev_priv(netdev);
4105 struct e1000_hw *hw = &adapter->hw; 4110 struct e1000_hw *hw = &adapter->hw;
4111 int err;
4106 4112
4107 e1000e_disable_l1aspm(pdev); 4113 e1000e_disable_l1aspm(pdev);
4108 if (pci_enable_device(pdev)) { 4114 if (adapter->need_ioport)
4115 err = pci_enable_device(pdev);
4116 else
4117 err = pci_enable_device_mem(pdev);
4118 if (err) {
4109 dev_err(&pdev->dev, 4119 dev_err(&pdev->dev,
4110 "Cannot re-enable PCI device after reset.\n"); 4120 "Cannot re-enable PCI device after reset.\n");
4111 return PCI_ERS_RESULT_DISCONNECT; 4121 return PCI_ERS_RESULT_DISCONNECT;
@@ -4184,6 +4194,21 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
4184} 4194}
4185 4195
4186/** 4196/**
4197 * e1000e_is_need_ioport - determine if an adapter needs ioport resources or not
4198 * @pdev: PCI device information struct
4199 *
4200 * Returns true if an adapters needs ioport resources
4201 **/
4202static int e1000e_is_need_ioport(struct pci_dev *pdev)
4203{
4204 switch (pdev->device) {
4205 /* Currently there are no adapters that need ioport resources */
4206 default:
4207 return false;
4208 }
4209}
4210
4211/**
4187 * e1000_probe - Device Initialization Routine 4212 * e1000_probe - Device Initialization Routine
4188 * @pdev: PCI device information struct 4213 * @pdev: PCI device information struct
4189 * @ent: entry in e1000_pci_tbl 4214 * @ent: entry in e1000_pci_tbl
@@ -4208,9 +4233,19 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4208 int i, err, pci_using_dac; 4233 int i, err, pci_using_dac;
4209 u16 eeprom_data = 0; 4234 u16 eeprom_data = 0;
4210 u16 eeprom_apme_mask = E1000_EEPROM_APME; 4235 u16 eeprom_apme_mask = E1000_EEPROM_APME;
4236 int bars, need_ioport;
4211 4237
4212 e1000e_disable_l1aspm(pdev); 4238 e1000e_disable_l1aspm(pdev);
4213 err = pci_enable_device(pdev); 4239
4240 /* do not allocate ioport bars when not needed */
4241 need_ioport = e1000e_is_need_ioport(pdev);
4242 if (need_ioport) {
4243 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
4244 err = pci_enable_device(pdev);
4245 } else {
4246 bars = pci_select_bars(pdev, IORESOURCE_MEM);
4247 err = pci_enable_device_mem(pdev);
4248 }
4214 if (err) 4249 if (err)
4215 return err; 4250 return err;
4216 4251
@@ -4233,7 +4268,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4233 } 4268 }
4234 } 4269 }
4235 4270
4236 err = pci_request_regions(pdev, e1000e_driver_name); 4271 err = pci_request_selected_regions(pdev, bars, e1000e_driver_name);
4237 if (err) 4272 if (err)
4238 goto err_pci_reg; 4273 goto err_pci_reg;
4239 4274
@@ -4258,6 +4293,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4258 adapter->hw.adapter = adapter; 4293 adapter->hw.adapter = adapter;
4259 adapter->hw.mac.type = ei->mac; 4294 adapter->hw.mac.type = ei->mac;
4260 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; 4295 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
4296 adapter->bars = bars;
4297 adapter->need_ioport = need_ioport;
4261 4298
4262 mmio_start = pci_resource_start(pdev, 0); 4299 mmio_start = pci_resource_start(pdev, 0);
4263 mmio_len = pci_resource_len(pdev, 0); 4300 mmio_len = pci_resource_len(pdev, 0);
@@ -4497,7 +4534,7 @@ err_sw_init:
4497err_ioremap: 4534err_ioremap:
4498 free_netdev(netdev); 4535 free_netdev(netdev);
4499err_alloc_etherdev: 4536err_alloc_etherdev:
4500 pci_release_regions(pdev); 4537 pci_release_selected_regions(pdev, bars);
4501err_pci_reg: 4538err_pci_reg:
4502err_dma: 4539err_dma:
4503 pci_disable_device(pdev); 4540 pci_disable_device(pdev);
@@ -4545,7 +4582,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
4545 iounmap(adapter->hw.hw_addr); 4582 iounmap(adapter->hw.hw_addr);
4546 if (adapter->hw.flash_address) 4583 if (adapter->hw.flash_address)
4547 iounmap(adapter->hw.flash_address); 4584 iounmap(adapter->hw.flash_address);
4548 pci_release_regions(pdev); 4585 pci_release_selected_regions(pdev, adapter->bars);
4549 4586
4550 free_netdev(netdev); 4587 free_netdev(netdev);
4551 4588
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 7bb9c728a1d3..3c1364de2b66 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -90,6 +90,7 @@ static int full_duplex[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
90#include <asm/processor.h> /* Processor type for cache alignment. */ 90#include <asm/processor.h> /* Processor type for cache alignment. */
91#include <asm/io.h> 91#include <asm/io.h>
92#include <asm/uaccess.h> 92#include <asm/uaccess.h>
93#include <asm/byteorder.h>
93 94
94/* These identify the driver base version and may not be removed. */ 95/* These identify the driver base version and may not be removed. */
95static char version[] = 96static char version[] =
@@ -861,40 +862,20 @@ static int netdev_open(struct net_device *dev)
861 Wait the specified 50 PCI cycles after a reset by initializing 862 Wait the specified 50 PCI cycles after a reset by initializing
862 Tx and Rx queues and the address filter list. 863 Tx and Rx queues and the address filter list.
863 FIXME (Ueimor): optimistic for alpha + posted writes ? */ 864 FIXME (Ueimor): optimistic for alpha + posted writes ? */
864#if defined(__powerpc__) || defined(__sparc__) 865
865// 89/9/1 modify,
866// np->bcrvalue=0x04 | 0x0x38; /* big-endian, 256 burst length */
867 np->bcrvalue = 0x04 | 0x10; /* big-endian, tx 8 burst length */
868 np->crvalue = 0xe00; /* rx 128 burst length */
869#elif defined(__alpha__) || defined(__x86_64__)
870// 89/9/1 modify,
871// np->bcrvalue=0x38; /* little-endian, 256 burst length */
872 np->bcrvalue = 0x10; /* little-endian, 8 burst length */
873 np->crvalue = 0xe00; /* rx 128 burst length */
874#elif defined(__i386__)
875#if defined(MODULE)
876// 89/9/1 modify,
877// np->bcrvalue=0x38; /* little-endian, 256 burst length */
878 np->bcrvalue = 0x10; /* little-endian, 8 burst length */ 866 np->bcrvalue = 0x10; /* little-endian, 8 burst length */
879 np->crvalue = 0xe00; /* rx 128 burst length */ 867#ifdef __BIG_ENDIAN
880#else 868 np->bcrvalue |= 0x04; /* big-endian */
881 /* When not a module we can work around broken '486 PCI boards. */
882#define x86 boot_cpu_data.x86
883// 89/9/1 modify,
884// np->bcrvalue=(x86 <= 4 ? 0x10 : 0x38);
885 np->bcrvalue = 0x10;
886 np->crvalue = (x86 <= 4 ? 0xa00 : 0xe00);
887 if (x86 <= 4)
888 printk(KERN_INFO "%s: This is a 386/486 PCI system, setting burst "
889 "length to %x.\n", dev->name, (x86 <= 4 ? 0x10 : 0x38));
890#endif 869#endif
891#else 870
892// 89/9/1 modify, 871#if defined(__i386__) && !defined(MODULE)
893// np->bcrvalue=0x38; 872 if (boot_cpu_data.x86 <= 4)
894 np->bcrvalue = 0x10; 873 np->crvalue = 0xa00;
895 np->crvalue = 0xe00; /* rx 128 burst length */ 874 else
896#warning Processor architecture undefined!
897#endif 875#endif
876 np->crvalue = 0xe00; /* rx 128 burst length */
877
878
898// 89/12/29 add, 879// 89/12/29 add,
899// 90/1/16 modify, 880// 90/1/16 modify,
900// np->imrvalue=FBE|TUNF|CNTOVF|RBU|TI|RI; 881// np->imrvalue=FBE|TUNF|CNTOVF|RBU|TI|RI;
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index c980ce9719af..afd063fe11af 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -5559,6 +5559,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5559 /* set mac address */ 5559 /* set mac address */
5560 nv_copy_mac_to_hw(dev); 5560 nv_copy_mac_to_hw(dev);
5561 5561
5562 /* Workaround current PCI init glitch: wakeup bits aren't
5563 * being set from PCI PM capability.
5564 */
5565 device_init_wakeup(&pci_dev->dev, 1);
5566
5562 /* disable WOL */ 5567 /* disable WOL */
5563 writel(0, base + NvRegWakeUpFlags); 5568 writel(0, base + NvRegWakeUpFlags);
5564 np->wolenabled = 0; 5569 np->wolenabled = 0;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 0b94833e23f7..e8cfadefa4b6 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -1077,8 +1077,6 @@ static inline void rx_off(struct scc_priv *priv)
1077 1077
1078static void start_timer(struct scc_priv *priv, int t, int r15) 1078static void start_timer(struct scc_priv *priv, int t, int r15)
1079{ 1079{
1080 unsigned long flags;
1081
1082 outb(priv->tmr_mode, priv->tmr_ctrl); 1080 outb(priv->tmr_mode, priv->tmr_ctrl);
1083 if (t == 0) { 1081 if (t == 0) {
1084 tm_isr(priv); 1082 tm_isr(priv);
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 6b2e7d351d65..0eecb8b2abd2 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -271,6 +271,10 @@ struct igb_adapter {
271 unsigned int msi_enabled; 271 unsigned int msi_enabled;
272 272
273 u32 eeprom_wol; 273 u32 eeprom_wol;
274
275 /* for ioport free */
276 int bars;
277 int need_ioport;
274}; 278};
275 279
276enum e1000_state_t { 280enum e1000_state_t {
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 7b6b780dc8a6..171d1fc1fbf8 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -718,7 +718,8 @@ void igb_down(struct igb_adapter *adapter)
718 adapter->link_speed = 0; 718 adapter->link_speed = 0;
719 adapter->link_duplex = 0; 719 adapter->link_duplex = 0;
720 720
721 igb_reset(adapter); 721 if (!pci_channel_offline(adapter->pdev))
722 igb_reset(adapter);
722 igb_clean_all_tx_rings(adapter); 723 igb_clean_all_tx_rings(adapter);
723 igb_clean_all_rx_rings(adapter); 724 igb_clean_all_rx_rings(adapter);
724} 725}
@@ -820,6 +821,21 @@ void igb_reset(struct igb_adapter *adapter)
820} 821}
821 822
822/** 823/**
824 * igb_is_need_ioport - determine if an adapter needs ioport resources or not
825 * @pdev: PCI device information struct
826 *
827 * Returns true if an adapter needs ioport resources
828 **/
829static int igb_is_need_ioport(struct pci_dev *pdev)
830{
831 switch (pdev->device) {
832 /* Currently there are no adapters that need ioport resources */
833 default:
834 return false;
835 }
836}
837
838/**
823 * igb_probe - Device Initialization Routine 839 * igb_probe - Device Initialization Routine
824 * @pdev: PCI device information struct 840 * @pdev: PCI device information struct
825 * @ent: entry in igb_pci_tbl 841 * @ent: entry in igb_pci_tbl
@@ -843,8 +859,17 @@ static int __devinit igb_probe(struct pci_dev *pdev,
843 u16 eeprom_data = 0; 859 u16 eeprom_data = 0;
844 u16 eeprom_apme_mask = IGB_EEPROM_APME; 860 u16 eeprom_apme_mask = IGB_EEPROM_APME;
845 u32 part_num; 861 u32 part_num;
862 int bars, need_ioport;
846 863
847 err = pci_enable_device(pdev); 864 /* do not allocate ioport bars when not needed */
865 need_ioport = igb_is_need_ioport(pdev);
866 if (need_ioport) {
867 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
868 err = pci_enable_device(pdev);
869 } else {
870 bars = pci_select_bars(pdev, IORESOURCE_MEM);
871 err = pci_enable_device_mem(pdev);
872 }
848 if (err) 873 if (err)
849 return err; 874 return err;
850 875
@@ -866,7 +891,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
866 } 891 }
867 } 892 }
868 893
869 err = pci_request_regions(pdev, igb_driver_name); 894 err = pci_request_selected_regions(pdev, bars, igb_driver_name);
870 if (err) 895 if (err)
871 goto err_pci_reg; 896 goto err_pci_reg;
872 897
@@ -887,6 +912,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,
887 hw = &adapter->hw; 912 hw = &adapter->hw;
888 hw->back = adapter; 913 hw->back = adapter;
889 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE; 914 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE;
915 adapter->bars = bars;
916 adapter->need_ioport = need_ioport;
890 917
891 mmio_start = pci_resource_start(pdev, 0); 918 mmio_start = pci_resource_start(pdev, 0);
892 mmio_len = pci_resource_len(pdev, 0); 919 mmio_len = pci_resource_len(pdev, 0);
@@ -1127,7 +1154,7 @@ err_hw_init:
1127err_ioremap: 1154err_ioremap:
1128 free_netdev(netdev); 1155 free_netdev(netdev);
1129err_alloc_etherdev: 1156err_alloc_etherdev:
1130 pci_release_regions(pdev); 1157 pci_release_selected_regions(pdev, bars);
1131err_pci_reg: 1158err_pci_reg:
1132err_dma: 1159err_dma:
1133 pci_disable_device(pdev); 1160 pci_disable_device(pdev);
@@ -1174,7 +1201,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
1174 iounmap(adapter->hw.hw_addr); 1201 iounmap(adapter->hw.hw_addr);
1175 if (adapter->hw.flash_address) 1202 if (adapter->hw.flash_address)
1176 iounmap(adapter->hw.flash_address); 1203 iounmap(adapter->hw.flash_address);
1177 pci_release_regions(pdev); 1204 pci_release_selected_regions(pdev, adapter->bars);
1178 1205
1179 free_netdev(netdev); 1206 free_netdev(netdev);
1180 1207
@@ -3975,7 +4002,11 @@ static int igb_resume(struct pci_dev *pdev)
3975 4002
3976 pci_set_power_state(pdev, PCI_D0); 4003 pci_set_power_state(pdev, PCI_D0);
3977 pci_restore_state(pdev); 4004 pci_restore_state(pdev);
3978 err = pci_enable_device(pdev); 4005
4006 if (adapter->need_ioport)
4007 err = pci_enable_device(pdev);
4008 else
4009 err = pci_enable_device_mem(pdev);
3979 if (err) { 4010 if (err) {
3980 dev_err(&pdev->dev, 4011 dev_err(&pdev->dev,
3981 "igb: Cannot enable PCI device from suspend\n"); 4012 "igb: Cannot enable PCI device from suspend\n");
@@ -4078,8 +4109,13 @@ static pci_ers_result_t igb_io_slot_reset(struct pci_dev *pdev)
4078 struct net_device *netdev = pci_get_drvdata(pdev); 4109 struct net_device *netdev = pci_get_drvdata(pdev);
4079 struct igb_adapter *adapter = netdev_priv(netdev); 4110 struct igb_adapter *adapter = netdev_priv(netdev);
4080 struct e1000_hw *hw = &adapter->hw; 4111 struct e1000_hw *hw = &adapter->hw;
4112 int err;
4081 4113
4082 if (pci_enable_device(pdev)) { 4114 if (adapter->need_ioport)
4115 err = pci_enable_device(pdev);
4116 else
4117 err = pci_enable_device_mem(pdev);
4118 if (err) {
4083 dev_err(&pdev->dev, 4119 dev_err(&pdev->dev,
4084 "Cannot re-enable PCI device after reset.\n"); 4120 "Cannot re-enable PCI device after reset.\n");
4085 return PCI_ERS_RESULT_DISCONNECT; 4121 return PCI_ERS_RESULT_DISCONNECT;
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 679a0826780e..2c03f4e2ccc4 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -1271,7 +1271,7 @@ static void ipg_nic_rx_with_end(struct net_device *dev,
1271 1271
1272 framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN; 1272 framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN;
1273 1273
1274 endframeLen = framelen - jumbo->current_size; 1274 endframelen = framelen - jumbo->current_size;
1275 /* 1275 /*
1276 if (framelen > IPG_RXFRAG_SIZE) 1276 if (framelen > IPG_RXFRAG_SIZE)
1277 framelen=IPG_RXFRAG_SIZE; 1277 framelen=IPG_RXFRAG_SIZE;
@@ -1279,8 +1279,8 @@ static void ipg_nic_rx_with_end(struct net_device *dev,
1279 if (framelen > IPG_RXSUPPORT_SIZE) 1279 if (framelen > IPG_RXSUPPORT_SIZE)
1280 dev_kfree_skb_irq(jumbo->skb); 1280 dev_kfree_skb_irq(jumbo->skb);
1281 else { 1281 else {
1282 memcpy(skb_put(jumbo->skb, endframeLen), 1282 memcpy(skb_put(jumbo->skb, endframelen),
1283 skb->data, endframeLen); 1283 skb->data, endframelen);
1284 1284
1285 jumbo->skb->protocol = 1285 jumbo->skb->protocol =
1286 eth_type_trans(jumbo->skb, dev); 1286 eth_type_trans(jumbo->skb, dev);
@@ -1352,16 +1352,16 @@ static int ipg_nic_rx(struct net_device *dev)
1352 1352
1353 switch (ipg_nic_rx_check_frame_type(dev)) { 1353 switch (ipg_nic_rx_check_frame_type(dev)) {
1354 case FRAME_WITH_START_WITH_END: 1354 case FRAME_WITH_START_WITH_END:
1355 ipg_nic_rx_with_start_and_end(dev, tp, rxfd, entry); 1355 ipg_nic_rx_with_start_and_end(dev, sp, rxfd, entry);
1356 break; 1356 break;
1357 case FRAME_WITH_START: 1357 case FRAME_WITH_START:
1358 ipg_nic_rx_with_start(dev, tp, rxfd, entry); 1358 ipg_nic_rx_with_start(dev, sp, rxfd, entry);
1359 break; 1359 break;
1360 case FRAME_WITH_END: 1360 case FRAME_WITH_END:
1361 ipg_nic_rx_with_end(dev, tp, rxfd, entry); 1361 ipg_nic_rx_with_end(dev, sp, rxfd, entry);
1362 break; 1362 break;
1363 case FRAME_NO_START_NO_END: 1363 case FRAME_NO_START_NO_END:
1364 ipg_nic_rx_no_start_no_end(dev, tp, rxfd, entry); 1364 ipg_nic_rx_no_start_no_end(dev, sp, rxfd, entry);
1365 break; 1365 break;
1366 } 1366 }
1367 } 1367 }
@@ -1808,7 +1808,7 @@ static int ipg_nic_open(struct net_device *dev)
1808 /* initialize JUMBO Frame control variable */ 1808 /* initialize JUMBO Frame control variable */
1809 sp->jumbo.found_start = 0; 1809 sp->jumbo.found_start = 0;
1810 sp->jumbo.current_size = 0; 1810 sp->jumbo.current_size = 0;
1811 sp->jumbo.skb = 0; 1811 sp->jumbo.skb = NULL;
1812 dev->mtu = IPG_TXFRAG_SIZE; 1812 dev->mtu = IPG_TXFRAG_SIZE;
1813#endif 1813#endif
1814 1814
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index d98113472a89..956914a5028d 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -32,6 +32,7 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/netdevice.h> 34#include <linux/netdevice.h>
35#include <linux/inet_lro.h>
35 36
36#include "ixgbe_type.h" 37#include "ixgbe_type.h"
37#include "ixgbe_common.h" 38#include "ixgbe_common.h"
@@ -100,6 +101,9 @@
100#define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000 101#define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000
101#define IXGBE_TX_FLAGS_VLAN_SHIFT 16 102#define IXGBE_TX_FLAGS_VLAN_SHIFT 16
102 103
104#define IXGBE_MAX_LRO_DESCRIPTORS 8
105#define IXGBE_MAX_LRO_AGGREGATE 32
106
103/* wrapper around a pointer to a socket buffer, 107/* wrapper around a pointer to a socket buffer,
104 * so a DMA handle can be stored along with the buffer */ 108 * so a DMA handle can be stored along with the buffer */
105struct ixgbe_tx_buffer { 109struct ixgbe_tx_buffer {
@@ -150,6 +154,8 @@ struct ixgbe_ring {
150 /* cpu for tx queue */ 154 /* cpu for tx queue */
151 int cpu; 155 int cpu;
152#endif 156#endif
157 struct net_lro_mgr lro_mgr;
158 bool lro_used;
153 struct ixgbe_queue_stats stats; 159 struct ixgbe_queue_stats stats;
154 u8 v_idx; /* maps directly to the index for this ring in the hardware 160 u8 v_idx; /* maps directly to the index for this ring in the hardware
155 * vector array, can also be used for finding the bit in EICR 161 * vector array, can also be used for finding the bit in EICR
@@ -287,6 +293,9 @@ struct ixgbe_adapter {
287 293
288 unsigned long state; 294 unsigned long state;
289 u64 tx_busy; 295 u64 tx_busy;
296 u64 lro_aggregated;
297 u64 lro_flushed;
298 u64 lro_no_desc;
290}; 299};
291 300
292enum ixbge_state_t { 301enum ixbge_state_t {
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 4e463778bcfd..12990b1fe7e4 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -90,6 +90,8 @@ static struct ixgbe_stats ixgbe_gstrings_stats[] = {
90 {"rx_header_split", IXGBE_STAT(rx_hdr_split)}, 90 {"rx_header_split", IXGBE_STAT(rx_hdr_split)},
91 {"alloc_rx_page_failed", IXGBE_STAT(alloc_rx_page_failed)}, 91 {"alloc_rx_page_failed", IXGBE_STAT(alloc_rx_page_failed)},
92 {"alloc_rx_buff_failed", IXGBE_STAT(alloc_rx_buff_failed)}, 92 {"alloc_rx_buff_failed", IXGBE_STAT(alloc_rx_buff_failed)},
93 {"lro_aggregated", IXGBE_STAT(lro_aggregated)},
94 {"lro_flushed", IXGBE_STAT(lro_flushed)},
93}; 95};
94 96
95#define IXGBE_QUEUE_STATS_LEN \ 97#define IXGBE_QUEUE_STATS_LEN \
@@ -787,6 +789,7 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
787 int stat_count = sizeof(struct ixgbe_queue_stats) / sizeof(u64); 789 int stat_count = sizeof(struct ixgbe_queue_stats) / sizeof(u64);
788 int j, k; 790 int j, k;
789 int i; 791 int i;
792 u64 aggregated = 0, flushed = 0, no_desc = 0;
790 793
791 ixgbe_update_stats(adapter); 794 ixgbe_update_stats(adapter);
792 for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) { 795 for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) {
@@ -801,11 +804,17 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
801 i += k; 804 i += k;
802 } 805 }
803 for (j = 0; j < adapter->num_rx_queues; j++) { 806 for (j = 0; j < adapter->num_rx_queues; j++) {
807 aggregated += adapter->rx_ring[j].lro_mgr.stats.aggregated;
808 flushed += adapter->rx_ring[j].lro_mgr.stats.flushed;
809 no_desc += adapter->rx_ring[j].lro_mgr.stats.no_desc;
804 queue_stat = (u64 *)&adapter->rx_ring[j].stats; 810 queue_stat = (u64 *)&adapter->rx_ring[j].stats;
805 for (k = 0; k < stat_count; k++) 811 for (k = 0; k < stat_count; k++)
806 data[i + k] = queue_stat[k]; 812 data[i + k] = queue_stat[k];
807 i += k; 813 i += k;
808 } 814 }
815 adapter->lro_aggregated = aggregated;
816 adapter->lro_flushed = flushed;
817 adapter->lro_no_desc = no_desc;
809} 818}
810 819
811static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, 820static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
@@ -973,6 +982,8 @@ static struct ethtool_ops ixgbe_ethtool_ops = {
973 .get_ethtool_stats = ixgbe_get_ethtool_stats, 982 .get_ethtool_stats = ixgbe_get_ethtool_stats,
974 .get_coalesce = ixgbe_get_coalesce, 983 .get_coalesce = ixgbe_get_coalesce,
975 .set_coalesce = ixgbe_set_coalesce, 984 .set_coalesce = ixgbe_set_coalesce,
985 .get_flags = ethtool_op_get_flags,
986 .set_flags = ethtool_op_set_flags,
976}; 987};
977 988
978void ixgbe_set_ethtool_ops(struct net_device *netdev) 989void ixgbe_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 0d37c9025be4..b37d618d8e2a 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -389,24 +389,39 @@ static int __ixgbe_notify_dca(struct device *dev, void *data)
389 * ixgbe_receive_skb - Send a completed packet up the stack 389 * ixgbe_receive_skb - Send a completed packet up the stack
390 * @adapter: board private structure 390 * @adapter: board private structure
391 * @skb: packet to send up 391 * @skb: packet to send up
392 * @is_vlan: packet has a VLAN tag 392 * @status: hardware indication of status of receive
393 * @tag: VLAN tag from descriptor 393 * @rx_ring: rx descriptor ring (for a specific queue) to setup
394 * @rx_desc: rx descriptor
394 **/ 395 **/
395static void ixgbe_receive_skb(struct ixgbe_adapter *adapter, 396static void ixgbe_receive_skb(struct ixgbe_adapter *adapter,
396 struct sk_buff *skb, bool is_vlan, 397 struct sk_buff *skb, u8 status,
397 u16 tag) 398 struct ixgbe_ring *ring,
399 union ixgbe_adv_rx_desc *rx_desc)
398{ 400{
399 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) { 401 bool is_vlan = (status & IXGBE_RXD_STAT_VP);
400 if (adapter->vlgrp && is_vlan) 402 u16 tag = le16_to_cpu(rx_desc->wb.upper.vlan);
401 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, tag);
402 else
403 netif_receive_skb(skb);
404 } else {
405 403
404 if (adapter->netdev->features & NETIF_F_LRO &&
405 skb->ip_summed == CHECKSUM_UNNECESSARY) {
406 if (adapter->vlgrp && is_vlan) 406 if (adapter->vlgrp && is_vlan)
407 vlan_hwaccel_rx(skb, adapter->vlgrp, tag); 407 lro_vlan_hwaccel_receive_skb(&ring->lro_mgr, skb,
408 adapter->vlgrp, tag,
409 rx_desc);
408 else 410 else
409 netif_rx(skb); 411 lro_receive_skb(&ring->lro_mgr, skb, rx_desc);
412 ring->lro_used = true;
413 } else {
414 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) {
415 if (adapter->vlgrp && is_vlan)
416 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, tag);
417 else
418 netif_receive_skb(skb);
419 } else {
420 if (adapter->vlgrp && is_vlan)
421 vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
422 else
423 netif_rx(skb);
424 }
410 } 425 }
411} 426}
412 427
@@ -546,8 +561,8 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter *adapter,
546 struct sk_buff *skb; 561 struct sk_buff *skb;
547 unsigned int i; 562 unsigned int i;
548 u32 upper_len, len, staterr; 563 u32 upper_len, len, staterr;
549 u16 hdr_info, vlan_tag; 564 u16 hdr_info;
550 bool is_vlan, cleaned = false; 565 bool cleaned = false;
551 int cleaned_count = 0; 566 int cleaned_count = 0;
552 unsigned int total_rx_bytes = 0, total_rx_packets = 0; 567 unsigned int total_rx_bytes = 0, total_rx_packets = 0;
553 568
@@ -556,8 +571,6 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter *adapter,
556 rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i); 571 rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i);
557 staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 572 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
558 rx_buffer_info = &rx_ring->rx_buffer_info[i]; 573 rx_buffer_info = &rx_ring->rx_buffer_info[i];
559 is_vlan = (staterr & IXGBE_RXD_STAT_VP);
560 vlan_tag = le16_to_cpu(rx_desc->wb.upper.vlan);
561 574
562 while (staterr & IXGBE_RXD_STAT_DD) { 575 while (staterr & IXGBE_RXD_STAT_DD) {
563 if (*work_done >= work_to_do) 576 if (*work_done >= work_to_do)
@@ -635,7 +648,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_adapter *adapter,
635 total_rx_packets++; 648 total_rx_packets++;
636 649
637 skb->protocol = eth_type_trans(skb, netdev); 650 skb->protocol = eth_type_trans(skb, netdev);
638 ixgbe_receive_skb(adapter, skb, is_vlan, vlan_tag); 651 ixgbe_receive_skb(adapter, skb, staterr, rx_ring, rx_desc);
639 netdev->last_rx = jiffies; 652 netdev->last_rx = jiffies;
640 653
641next_desc: 654next_desc:
@@ -652,8 +665,11 @@ next_desc:
652 rx_buffer_info = next_buffer; 665 rx_buffer_info = next_buffer;
653 666
654 staterr = le32_to_cpu(rx_desc->wb.upper.status_error); 667 staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
655 is_vlan = (staterr & IXGBE_RXD_STAT_VP); 668 }
656 vlan_tag = le16_to_cpu(rx_desc->wb.upper.vlan); 669
670 if (rx_ring->lro_used) {
671 lro_flush_all(&rx_ring->lro_mgr);
672 rx_ring->lro_used = false;
657 } 673 }
658 674
659 rx_ring->next_to_clean = i; 675 rx_ring->next_to_clean = i;
@@ -1382,6 +1398,33 @@ static void ixgbe_configure_tx(struct ixgbe_adapter *adapter)
1382 1398
1383#define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2 1399#define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2
1384/** 1400/**
1401 * ixgbe_get_skb_hdr - helper function for LRO header processing
1402 * @skb: pointer to sk_buff to be added to LRO packet
1403 * @iphdr: pointer to tcp header structure
1404 * @tcph: pointer to tcp header structure
1405 * @hdr_flags: pointer to header flags
1406 * @priv: private data
1407 **/
1408static int ixgbe_get_skb_hdr(struct sk_buff *skb, void **iphdr, void **tcph,
1409 u64 *hdr_flags, void *priv)
1410{
1411 union ixgbe_adv_rx_desc *rx_desc = priv;
1412
1413 /* Verify that this is a valid IPv4 TCP packet */
1414 if (!(rx_desc->wb.lower.lo_dword.pkt_info &
1415 (IXGBE_RXDADV_PKTTYPE_IPV4 | IXGBE_RXDADV_PKTTYPE_TCP)))
1416 return -1;
1417
1418 /* Set network headers */
1419 skb_reset_network_header(skb);
1420 skb_set_transport_header(skb, ip_hdrlen(skb));
1421 *iphdr = ip_hdr(skb);
1422 *tcph = tcp_hdr(skb);
1423 *hdr_flags = LRO_IPV4 | LRO_TCP;
1424 return 0;
1425}
1426
1427/**
1385 * ixgbe_configure_rx - Configure 8254x Receive Unit after Reset 1428 * ixgbe_configure_rx - Configure 8254x Receive Unit after Reset
1386 * @adapter: board private structure 1429 * @adapter: board private structure
1387 * 1430 *
@@ -1470,6 +1513,17 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
1470 adapter->rx_ring[i].tail = IXGBE_RDT(i); 1513 adapter->rx_ring[i].tail = IXGBE_RDT(i);
1471 } 1514 }
1472 1515
1516 /* Intitial LRO Settings */
1517 adapter->rx_ring[i].lro_mgr.max_aggr = IXGBE_MAX_LRO_AGGREGATE;
1518 adapter->rx_ring[i].lro_mgr.max_desc = IXGBE_MAX_LRO_DESCRIPTORS;
1519 adapter->rx_ring[i].lro_mgr.get_skb_header = ixgbe_get_skb_hdr;
1520 adapter->rx_ring[i].lro_mgr.features = LRO_F_EXTRACT_VLAN_ID;
1521 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL))
1522 adapter->rx_ring[i].lro_mgr.features |= LRO_F_NAPI;
1523 adapter->rx_ring[i].lro_mgr.dev = adapter->netdev;
1524 adapter->rx_ring[i].lro_mgr.ip_summed = CHECKSUM_UNNECESSARY;
1525 adapter->rx_ring[i].lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY;
1526
1473 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { 1527 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
1474 /* Fill out redirection table */ 1528 /* Fill out redirection table */
1475 for (i = 0, j = 0; i < 128; i++, j++) { 1529 for (i = 0, j = 0; i < 128; i++, j++) {
@@ -1969,7 +2023,8 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
1969 netif_carrier_off(netdev); 2023 netif_carrier_off(netdev);
1970 netif_stop_queue(netdev); 2024 netif_stop_queue(netdev);
1971 2025
1972 ixgbe_reset(adapter); 2026 if (!pci_channel_offline(adapter->pdev))
2027 ixgbe_reset(adapter);
1973 ixgbe_clean_all_tx_rings(adapter); 2028 ixgbe_clean_all_tx_rings(adapter);
1974 ixgbe_clean_all_rx_rings(adapter); 2029 ixgbe_clean_all_rx_rings(adapter);
1975 2030
@@ -2489,12 +2544,18 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
2489 struct pci_dev *pdev = adapter->pdev; 2544 struct pci_dev *pdev = adapter->pdev;
2490 int size; 2545 int size;
2491 2546
2547 size = sizeof(struct net_lro_desc) * IXGBE_MAX_LRO_DESCRIPTORS;
2548 rxdr->lro_mgr.lro_arr = vmalloc(size);
2549 if (!rxdr->lro_mgr.lro_arr)
2550 return -ENOMEM;
2551 memset(rxdr->lro_mgr.lro_arr, 0, size);
2552
2492 size = sizeof(struct ixgbe_rx_buffer) * rxdr->count; 2553 size = sizeof(struct ixgbe_rx_buffer) * rxdr->count;
2493 rxdr->rx_buffer_info = vmalloc(size); 2554 rxdr->rx_buffer_info = vmalloc(size);
2494 if (!rxdr->rx_buffer_info) { 2555 if (!rxdr->rx_buffer_info) {
2495 DPRINTK(PROBE, ERR, 2556 DPRINTK(PROBE, ERR,
2496 "vmalloc allocation failed for the rx desc ring\n"); 2557 "vmalloc allocation failed for the rx desc ring\n");
2497 return -ENOMEM; 2558 goto alloc_failed;
2498 } 2559 }
2499 memset(rxdr->rx_buffer_info, 0, size); 2560 memset(rxdr->rx_buffer_info, 0, size);
2500 2561
@@ -2508,13 +2569,18 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
2508 DPRINTK(PROBE, ERR, 2569 DPRINTK(PROBE, ERR,
2509 "Memory allocation failed for the rx desc ring\n"); 2570 "Memory allocation failed for the rx desc ring\n");
2510 vfree(rxdr->rx_buffer_info); 2571 vfree(rxdr->rx_buffer_info);
2511 return -ENOMEM; 2572 goto alloc_failed;
2512 } 2573 }
2513 2574
2514 rxdr->next_to_clean = 0; 2575 rxdr->next_to_clean = 0;
2515 rxdr->next_to_use = 0; 2576 rxdr->next_to_use = 0;
2516 2577
2517 return 0; 2578 return 0;
2579
2580alloc_failed:
2581 vfree(rxdr->lro_mgr.lro_arr);
2582 rxdr->lro_mgr.lro_arr = NULL;
2583 return -ENOMEM;
2518} 2584}
2519 2585
2520/** 2586/**
@@ -2565,6 +2631,9 @@ static void ixgbe_free_rx_resources(struct ixgbe_adapter *adapter,
2565{ 2631{
2566 struct pci_dev *pdev = adapter->pdev; 2632 struct pci_dev *pdev = adapter->pdev;
2567 2633
2634 vfree(rx_ring->lro_mgr.lro_arr);
2635 rx_ring->lro_mgr.lro_arr = NULL;
2636
2568 ixgbe_clean_rx_ring(adapter, rx_ring); 2637 ixgbe_clean_rx_ring(adapter, rx_ring);
2569 2638
2570 vfree(rx_ring->rx_buffer_info); 2639 vfree(rx_ring->rx_buffer_info);
@@ -3517,6 +3586,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3517 NETIF_F_HW_VLAN_RX | 3586 NETIF_F_HW_VLAN_RX |
3518 NETIF_F_HW_VLAN_FILTER; 3587 NETIF_F_HW_VLAN_FILTER;
3519 3588
3589 netdev->features |= NETIF_F_LRO;
3520 netdev->features |= NETIF_F_TSO; 3590 netdev->features |= NETIF_F_TSO;
3521 netdev->features |= NETIF_F_TSO6; 3591 netdev->features |= NETIF_F_TSO6;
3522 3592
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 6797ed069f1f..63cd67b931e7 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -71,14 +71,18 @@ static irqreturn_t netxen_intr(int irq, void *data);
71static irqreturn_t netxen_msi_intr(int irq, void *data); 71static irqreturn_t netxen_msi_intr(int irq, void *data);
72 72
73/* PCI Device ID Table */ 73/* PCI Device ID Table */
74#define ENTRY(device) \
75 {PCI_DEVICE(0x4040, (device)), \
76 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0}
77
74static struct pci_device_id netxen_pci_tbl[] __devinitdata = { 78static struct pci_device_id netxen_pci_tbl[] __devinitdata = {
75 {PCI_DEVICE(0x4040, 0x0001), PCI_DEVICE_CLASS(0x020000, ~0)}, 79 ENTRY(0x0001),
76 {PCI_DEVICE(0x4040, 0x0002), PCI_DEVICE_CLASS(0x020000, ~0)}, 80 ENTRY(0x0002),
77 {PCI_DEVICE(0x4040, 0x0003), PCI_DEVICE_CLASS(0x020000, ~0)}, 81 ENTRY(0x0003),
78 {PCI_DEVICE(0x4040, 0x0004), PCI_DEVICE_CLASS(0x020000, ~0)}, 82 ENTRY(0x0004),
79 {PCI_DEVICE(0x4040, 0x0005), PCI_DEVICE_CLASS(0x020000, ~0)}, 83 ENTRY(0x0005),
80 {PCI_DEVICE(0x4040, 0x0024), PCI_DEVICE_CLASS(0x020000, ~0)}, 84 ENTRY(0x0024),
81 {PCI_DEVICE(0x4040, 0x0025), PCI_DEVICE_CLASS(0x020000, ~0)}, 85 ENTRY(0x0025),
82 {0,} 86 {0,}
83}; 87};
84 88
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index fffc49befe04..53451c3b2c0d 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -1739,7 +1739,6 @@ static int netdrv_close (struct net_device *dev)
1739 1739
1740 spin_unlock_irqrestore (&tp->lock, flags); 1740 spin_unlock_irqrestore (&tp->lock, flags);
1741 1741
1742 synchronize_irq (dev->irq);
1743 free_irq (dev->irq, dev); 1742 free_irq (dev->irq, dev);
1744 1743
1745 netdrv_tx_clear (dev); 1744 netdrv_tx_clear (dev);
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index d7018ff9e171..3f682d49a4e6 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -525,12 +525,14 @@ static int axnet_open(struct net_device *dev)
525 int ret; 525 int ret;
526 axnet_dev_t *info = PRIV(dev); 526 axnet_dev_t *info = PRIV(dev);
527 struct pcmcia_device *link = info->p_dev; 527 struct pcmcia_device *link = info->p_dev;
528 unsigned int nic_base = dev->base_addr;
528 529
529 DEBUG(2, "axnet_open('%s')\n", dev->name); 530 DEBUG(2, "axnet_open('%s')\n", dev->name);
530 531
531 if (!pcmcia_dev_present(link)) 532 if (!pcmcia_dev_present(link))
532 return -ENODEV; 533 return -ENODEV;
533 534
535 outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */
534 ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, "axnet_cs", dev); 536 ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, "axnet_cs", dev);
535 if (ret) 537 if (ret)
536 return ret; 538 return ret;
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index fd8158a86f64..2d4c4ad89b8d 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -969,6 +969,7 @@ static int pcnet_open(struct net_device *dev)
969 int ret; 969 int ret;
970 pcnet_dev_t *info = PRIV(dev); 970 pcnet_dev_t *info = PRIV(dev);
971 struct pcmcia_device *link = info->p_dev; 971 struct pcmcia_device *link = info->p_dev;
972 unsigned int nic_base = dev->base_addr;
972 973
973 DEBUG(2, "pcnet_open('%s')\n", dev->name); 974 DEBUG(2, "pcnet_open('%s')\n", dev->name);
974 975
@@ -976,6 +977,8 @@ static int pcnet_open(struct net_device *dev)
976 return -ENODEV; 977 return -ENODEV;
977 978
978 set_misc_reg(dev); 979 set_misc_reg(dev);
980
981 outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */
979 ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev_info, dev); 982 ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev_info, dev);
980 if (ret) 983 if (ret)
981 return ret; 984 return ret;
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index bafb69b6f7cb..fc6f4b8c64b3 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -942,7 +942,7 @@ static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
942 m->msg_namelen = 0; 942 m->msg_namelen = 0;
943 943
944 if (skb) { 944 if (skb) {
945 total_len = min(total_len, skb->len); 945 total_len = min_t(size_t, total_len, skb->len);
946 error = skb_copy_datagram_iovec(skb, 0, m->msg_iov, total_len); 946 error = skb_copy_datagram_iovec(skb, 0, m->msg_iov, total_len);
947 if (error == 0) 947 if (error == 0)
948 error = total_len; 948 error = total_len;
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index 5f608780c3e8..e7d48a352beb 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -3701,7 +3701,9 @@ static int ql_cycle_adapter(struct ql3_adapter *qdev, int reset)
3701 printk(KERN_ERR PFX 3701 printk(KERN_ERR PFX
3702 "%s: Driver up/down cycle failed, " 3702 "%s: Driver up/down cycle failed, "
3703 "closing device\n",qdev->ndev->name); 3703 "closing device\n",qdev->ndev->name);
3704 rtnl_lock();
3704 dev_close(qdev->ndev); 3705 dev_close(qdev->ndev);
3706 rtnl_unlock();
3705 return -1; 3707 return -1;
3706 } 3708 }
3707 return 0; 3709 return 0;
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 858b191517b3..504a48ff73c8 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -273,7 +273,7 @@ static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring,
273 dma_addr_t mapping = desc_dma; 273 dma_addr_t mapping = desc_dma;
274 274
275 while (size-- > 0) { 275 while (size-- > 0) {
276 mapping += sizeof(sizeof(*desc)); 276 mapping += sizeof(*desc);
277 desc->ndesc = cpu_to_le32(mapping); 277 desc->ndesc = cpu_to_le32(mapping);
278 desc->vndescp = desc + 1; 278 desc->vndescp = desc + 1;
279 desc++; 279 desc++;
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 5694e894fc7a..e7a3dbec674c 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -2625,9 +2625,7 @@ static int fill_rx_buffers(struct ring_info *ring)
2625 rxdp1->Buffer0_ptr = pci_map_single 2625 rxdp1->Buffer0_ptr = pci_map_single
2626 (ring->pdev, skb->data, size - NET_IP_ALIGN, 2626 (ring->pdev, skb->data, size - NET_IP_ALIGN,
2627 PCI_DMA_FROMDEVICE); 2627 PCI_DMA_FROMDEVICE);
2628 if( (rxdp1->Buffer0_ptr == 0) || 2628 if(pci_dma_mapping_error(rxdp1->Buffer0_ptr))
2629 (rxdp1->Buffer0_ptr ==
2630 DMA_ERROR_CODE))
2631 goto pci_map_failed; 2629 goto pci_map_failed;
2632 2630
2633 rxdp->Control_2 = 2631 rxdp->Control_2 =
@@ -2657,6 +2655,7 @@ static int fill_rx_buffers(struct ring_info *ring)
2657 skb->data = (void *) (unsigned long)tmp; 2655 skb->data = (void *) (unsigned long)tmp;
2658 skb_reset_tail_pointer(skb); 2656 skb_reset_tail_pointer(skb);
2659 2657
2658 /* AK: check is wrong. 0 can be valid dma address */
2660 if (!(rxdp3->Buffer0_ptr)) 2659 if (!(rxdp3->Buffer0_ptr))
2661 rxdp3->Buffer0_ptr = 2660 rxdp3->Buffer0_ptr =
2662 pci_map_single(ring->pdev, ba->ba_0, 2661 pci_map_single(ring->pdev, ba->ba_0,
@@ -2665,8 +2664,7 @@ static int fill_rx_buffers(struct ring_info *ring)
2665 pci_dma_sync_single_for_device(ring->pdev, 2664 pci_dma_sync_single_for_device(ring->pdev,
2666 (dma_addr_t) rxdp3->Buffer0_ptr, 2665 (dma_addr_t) rxdp3->Buffer0_ptr,
2667 BUF0_LEN, PCI_DMA_FROMDEVICE); 2666 BUF0_LEN, PCI_DMA_FROMDEVICE);
2668 if( (rxdp3->Buffer0_ptr == 0) || 2667 if (pci_dma_mapping_error(rxdp3->Buffer0_ptr))
2669 (rxdp3->Buffer0_ptr == DMA_ERROR_CODE))
2670 goto pci_map_failed; 2668 goto pci_map_failed;
2671 2669
2672 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); 2670 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
@@ -2681,18 +2679,17 @@ static int fill_rx_buffers(struct ring_info *ring)
2681 (ring->pdev, skb->data, ring->mtu + 4, 2679 (ring->pdev, skb->data, ring->mtu + 4,
2682 PCI_DMA_FROMDEVICE); 2680 PCI_DMA_FROMDEVICE);
2683 2681
2684 if( (rxdp3->Buffer2_ptr == 0) || 2682 if (pci_dma_mapping_error(rxdp3->Buffer2_ptr))
2685 (rxdp3->Buffer2_ptr == DMA_ERROR_CODE))
2686 goto pci_map_failed; 2683 goto pci_map_failed;
2687 2684
2685 /* AK: check is wrong */
2688 if (!rxdp3->Buffer1_ptr) 2686 if (!rxdp3->Buffer1_ptr)
2689 rxdp3->Buffer1_ptr = 2687 rxdp3->Buffer1_ptr =
2690 pci_map_single(ring->pdev, 2688 pci_map_single(ring->pdev,
2691 ba->ba_1, BUF1_LEN, 2689 ba->ba_1, BUF1_LEN,
2692 PCI_DMA_FROMDEVICE); 2690 PCI_DMA_FROMDEVICE);
2693 2691
2694 if( (rxdp3->Buffer1_ptr == 0) || 2692 if (pci_dma_mapping_error(rxdp3->Buffer1_ptr)) {
2695 (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) {
2696 pci_unmap_single 2693 pci_unmap_single
2697 (ring->pdev, 2694 (ring->pdev,
2698 (dma_addr_t)(unsigned long) 2695 (dma_addr_t)(unsigned long)
@@ -4264,16 +4261,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4264 txdp->Buffer_Pointer = pci_map_single(sp->pdev, 4261 txdp->Buffer_Pointer = pci_map_single(sp->pdev,
4265 fifo->ufo_in_band_v, 4262 fifo->ufo_in_band_v,
4266 sizeof(u64), PCI_DMA_TODEVICE); 4263 sizeof(u64), PCI_DMA_TODEVICE);
4267 if((txdp->Buffer_Pointer == 0) || 4264 if (pci_dma_mapping_error(txdp->Buffer_Pointer))
4268 (txdp->Buffer_Pointer == DMA_ERROR_CODE))
4269 goto pci_map_failed; 4265 goto pci_map_failed;
4270 txdp++; 4266 txdp++;
4271 } 4267 }
4272 4268
4273 txdp->Buffer_Pointer = pci_map_single 4269 txdp->Buffer_Pointer = pci_map_single
4274 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); 4270 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
4275 if((txdp->Buffer_Pointer == 0) || 4271 if (pci_dma_mapping_error(txdp->Buffer_Pointer))
4276 (txdp->Buffer_Pointer == DMA_ERROR_CODE))
4277 goto pci_map_failed; 4272 goto pci_map_failed;
4278 4273
4279 txdp->Host_Control = (unsigned long) skb; 4274 txdp->Host_Control = (unsigned long) skb;
@@ -6884,10 +6879,8 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6884 pci_map_single( sp->pdev, (*skb)->data, 6879 pci_map_single( sp->pdev, (*skb)->data,
6885 size - NET_IP_ALIGN, 6880 size - NET_IP_ALIGN,
6886 PCI_DMA_FROMDEVICE); 6881 PCI_DMA_FROMDEVICE);
6887 if( (rxdp1->Buffer0_ptr == 0) || 6882 if (pci_dma_mapping_error(rxdp1->Buffer0_ptr))
6888 (rxdp1->Buffer0_ptr == DMA_ERROR_CODE)) {
6889 goto memalloc_failed; 6883 goto memalloc_failed;
6890 }
6891 rxdp->Host_Control = (unsigned long) (*skb); 6884 rxdp->Host_Control = (unsigned long) (*skb);
6892 } 6885 }
6893 } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) { 6886 } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) {
@@ -6913,15 +6906,12 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6913 pci_map_single(sp->pdev, (*skb)->data, 6906 pci_map_single(sp->pdev, (*skb)->data,
6914 dev->mtu + 4, 6907 dev->mtu + 4,
6915 PCI_DMA_FROMDEVICE); 6908 PCI_DMA_FROMDEVICE);
6916 if( (rxdp3->Buffer2_ptr == 0) || 6909 if (pci_dma_mapping_error(rxdp3->Buffer2_ptr))
6917 (rxdp3->Buffer2_ptr == DMA_ERROR_CODE)) {
6918 goto memalloc_failed; 6910 goto memalloc_failed;
6919 }
6920 rxdp3->Buffer0_ptr = *temp0 = 6911 rxdp3->Buffer0_ptr = *temp0 =
6921 pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN, 6912 pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN,
6922 PCI_DMA_FROMDEVICE); 6913 PCI_DMA_FROMDEVICE);
6923 if( (rxdp3->Buffer0_ptr == 0) || 6914 if (pci_dma_mapping_error(rxdp3->Buffer0_ptr)) {
6924 (rxdp3->Buffer0_ptr == DMA_ERROR_CODE)) {
6925 pci_unmap_single (sp->pdev, 6915 pci_unmap_single (sp->pdev,
6926 (dma_addr_t)rxdp3->Buffer2_ptr, 6916 (dma_addr_t)rxdp3->Buffer2_ptr,
6927 dev->mtu + 4, PCI_DMA_FROMDEVICE); 6917 dev->mtu + 4, PCI_DMA_FROMDEVICE);
@@ -6933,8 +6923,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6933 rxdp3->Buffer1_ptr = *temp1 = 6923 rxdp3->Buffer1_ptr = *temp1 =
6934 pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN, 6924 pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN,
6935 PCI_DMA_FROMDEVICE); 6925 PCI_DMA_FROMDEVICE);
6936 if( (rxdp3->Buffer1_ptr == 0) || 6926 if (pci_dma_mapping_error(rxdp3->Buffer1_ptr)) {
6937 (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) {
6938 pci_unmap_single (sp->pdev, 6927 pci_unmap_single (sp->pdev,
6939 (dma_addr_t)rxdp3->Buffer0_ptr, 6928 (dma_addr_t)rxdp3->Buffer0_ptr,
6940 BUF0_LEN, PCI_DMA_FROMDEVICE); 6929 BUF0_LEN, PCI_DMA_FROMDEVICE);
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index d0a84ba887a5..483b17c34ae8 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -75,10 +75,6 @@ static int debug_level = ERR_DBG;
75/* DEBUG message print. */ 75/* DEBUG message print. */
76#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) 76#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args)
77 77
78#ifndef DMA_ERROR_CODE
79#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
80#endif
81
82/* Protocol assist features of the NIC */ 78/* Protocol assist features of the NIC */
83#define L3_CKSUM_OK 0xFFFF 79#define L3_CKSUM_OK 0xFFFF
84#define L4_CKSUM_OK 0xFFFF 80#define L4_CKSUM_OK 0xFFFF
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index f64d987140a9..37f3116ea6bd 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -322,7 +322,7 @@ static int sh_eth_dev_init(struct net_device *ndev)
322 ctrl_outl((FIFO_SIZE_T | FIFO_SIZE_R), ioaddr + FDR); 322 ctrl_outl((FIFO_SIZE_T | FIFO_SIZE_R), ioaddr + FDR);
323 ctrl_outl(0, ioaddr + TFTR); 323 ctrl_outl(0, ioaddr + TFTR);
324 324
325 ctrl_outl(RMCR_RST, ioaddr + RMCR); 325 ctrl_outl(0, ioaddr + RMCR);
326 326
327 rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5; 327 rx_int_var = mdp->rx_int_var = DESC_I_RINT8 | DESC_I_RINT5;
328 tx_int_var = mdp->tx_int_var = DESC_I_TINT2; 328 tx_int_var = mdp->tx_int_var = DESC_I_TINT2;
@@ -994,7 +994,7 @@ static int sh_mdio_init(struct net_device *ndev, int id)
994 /* Hook up MII support for ethtool */ 994 /* Hook up MII support for ethtool */
995 mdp->mii_bus->name = "sh_mii"; 995 mdp->mii_bus->name = "sh_mii";
996 mdp->mii_bus->dev = &ndev->dev; 996 mdp->mii_bus->dev = &ndev->dev;
997 mdp->mii_bus->id = id; 997 mdp->mii_bus->id[0] = id;
998 998
999 /* PHY IRQ */ 999 /* PHY IRQ */
1000 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1000 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
index ca2db6bb3c61..e01e1c347715 100644
--- a/drivers/net/sh_eth.h
+++ b/drivers/net/sh_eth.h
@@ -40,8 +40,6 @@
40#define PKT_BUF_SZ 1538 40#define PKT_BUF_SZ 1538
41 41
42/* Chip Base Address */ 42/* Chip Base Address */
43#define SH_ETH0_BASE 0xA7000000
44#define SH_ETH1_BASE 0xA7000400
45#define SH_TSU_ADDR 0xA7000804 43#define SH_TSU_ADDR 0xA7000804
46 44
47/* Chip Registers */ 45/* Chip Registers */
@@ -462,3 +460,5 @@ static void swaps(char *src, int len)
462 *p = swab32(*p); 460 *p = swab32(*p);
463#endif 461#endif
464} 462}
463
464#endif
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index 10e4e85da3fc..b07b8cbadeaf 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -1394,6 +1394,7 @@ tc35815_open(struct net_device *dev)
1394 tc35815_chip_init(dev); 1394 tc35815_chip_init(dev);
1395 spin_unlock_irq(&lp->lock); 1395 spin_unlock_irq(&lp->lock);
1396 1396
1397 netif_carrier_off(dev);
1397 /* schedule a link state check */ 1398 /* schedule a link state check */
1398 phy_start(lp->phy_dev); 1399 phy_start(lp->phy_dev);
1399 1400
@@ -1735,7 +1736,6 @@ tc35815_rx(struct net_device *dev)
1735 skb = lp->rx_skbs[cur_bd].skb; 1736 skb = lp->rx_skbs[cur_bd].skb;
1736 prefetch(skb->data); 1737 prefetch(skb->data);
1737 lp->rx_skbs[cur_bd].skb = NULL; 1738 lp->rx_skbs[cur_bd].skb = NULL;
1738 lp->fbl_count--;
1739 pci_unmap_single(lp->pci_dev, 1739 pci_unmap_single(lp->pci_dev,
1740 lp->rx_skbs[cur_bd].skb_dma, 1740 lp->rx_skbs[cur_bd].skb_dma,
1741 RX_BUF_SIZE, PCI_DMA_FROMDEVICE); 1741 RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
@@ -1791,6 +1791,7 @@ tc35815_rx(struct net_device *dev)
1791#ifdef TC35815_USE_PACKEDBUFFER 1791#ifdef TC35815_USE_PACKEDBUFFER
1792 while (lp->fbl_curid != id) 1792 while (lp->fbl_curid != id)
1793#else 1793#else
1794 lp->fbl_count--;
1794 while (lp->fbl_count < RX_BUF_NUM) 1795 while (lp->fbl_count < RX_BUF_NUM)
1795#endif 1796#endif
1796 { 1797 {
@@ -2453,6 +2454,7 @@ static int tc35815_resume(struct pci_dev *pdev)
2453 return 0; 2454 return 0;
2454 pci_set_power_state(pdev, PCI_D0); 2455 pci_set_power_state(pdev, PCI_D0);
2455 tc35815_restart(dev); 2456 tc35815_restart(dev);
2457 netif_carrier_off(dev);
2456 if (lp->phy_dev) 2458 if (lp->phy_dev)
2457 phy_start(lp->phy_dev); 2459 phy_start(lp->phy_dev);
2458 netif_device_attach(dev); 2460 netif_device_attach(dev);
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index febfaee44fe9..43fde99b24ac 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -1437,7 +1437,6 @@ static int tsi108_close(struct net_device *dev)
1437 dev_kfree_skb(skb); 1437 dev_kfree_skb(skb);
1438 } 1438 }
1439 1439
1440 synchronize_irq(data->irq_num);
1441 free_irq(data->irq_num, dev); 1440 free_irq(data->irq_num, dev);
1442 1441
1443 /* Discard the RX ring. */ 1442 /* Discard the RX ring. */
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index 6c400ccd38b4..1210fb3748a7 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/21142.c 2 drivers/net/tulip/21142.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,8 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/ 12 Please submit bugs to http://bugzilla.kernel.org/ .
14
15*/ 13*/
16 14
17#include <linux/delay.h> 15#include <linux/delay.h>
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 1b5edd646a8c..9281d06d5aaa 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -124,8 +124,6 @@ MODULE_PARM_DESC (rx_copybreak, "de2104x Breakpoint at which Rx packets are copi
124/* Time in jiffies before concluding the transmitter is hung. */ 124/* Time in jiffies before concluding the transmitter is hung. */
125#define TX_TIMEOUT (6*HZ) 125#define TX_TIMEOUT (6*HZ)
126 126
127#define DE_UNALIGNED_16(a) (u16)(get_unaligned((u16 *)(a)))
128
129/* This is a mysterious value that can be written to CSR11 in the 21040 (only) 127/* This is a mysterious value that can be written to CSR11 in the 21040 (only)
130 to support a pre-NWay full-duplex signaling mechanism using short frames. 128 to support a pre-NWay full-duplex signaling mechanism using short frames.
131 No one knows what it should be, but if left at its default value some 129 No one knows what it should be, but if left at its default value some
@@ -1811,7 +1809,7 @@ static void __devinit de21041_get_srom_info (struct de_private *de)
1811 goto bad_srom; 1809 goto bad_srom;
1812 1810
1813 /* get default media type */ 1811 /* get default media type */
1814 switch (DE_UNALIGNED_16(&il->default_media)) { 1812 switch (get_unaligned(&il->default_media)) {
1815 case 0x0001: de->media_type = DE_MEDIA_BNC; break; 1813 case 0x0001: de->media_type = DE_MEDIA_BNC; break;
1816 case 0x0002: de->media_type = DE_MEDIA_AUI; break; 1814 case 0x0002: de->media_type = DE_MEDIA_AUI; break;
1817 case 0x0204: de->media_type = DE_MEDIA_TP_FD; break; 1815 case 0x0204: de->media_type = DE_MEDIA_TP_FD; break;
@@ -1875,9 +1873,9 @@ static void __devinit de21041_get_srom_info (struct de_private *de)
1875 bufp += sizeof (ib->opts); 1873 bufp += sizeof (ib->opts);
1876 1874
1877 if (ib->opts & MediaCustomCSRs) { 1875 if (ib->opts & MediaCustomCSRs) {
1878 de->media[idx].csr13 = DE_UNALIGNED_16(&ib->csr13); 1876 de->media[idx].csr13 = get_unaligned(&ib->csr13);
1879 de->media[idx].csr14 = DE_UNALIGNED_16(&ib->csr14); 1877 de->media[idx].csr14 = get_unaligned(&ib->csr14);
1880 de->media[idx].csr15 = DE_UNALIGNED_16(&ib->csr15); 1878 de->media[idx].csr15 = get_unaligned(&ib->csr15);
1881 bufp += sizeof(ib->csr13) + sizeof(ib->csr14) + 1879 bufp += sizeof(ib->csr13) + sizeof(ib->csr14) +
1882 sizeof(ib->csr15); 1880 sizeof(ib->csr15);
1883 1881
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index da2206f6021d..0dcced1263b9 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/eeprom.c 2 drivers/net/tulip/eeprom.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,8 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/ 12 Please submit bug reports to http://bugzilla.kernel.org/.
14
15*/ 13*/
16 14
17#include <linux/pci.h> 15#include <linux/pci.h>
diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
index 6284afd14bbb..c6bad987d63e 100644
--- a/drivers/net/tulip/interrupt.c
+++ b/drivers/net/tulip/interrupt.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/interrupt.c 2 drivers/net/tulip/interrupt.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,8 +8,8 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/ 12 Please submit bugs to http://bugzilla.kernel.org/ .
14 13
15*/ 14*/
16 15
diff --git a/drivers/net/tulip/media.c b/drivers/net/tulip/media.c
index b56256636543..91cf9c863910 100644
--- a/drivers/net/tulip/media.c
+++ b/drivers/net/tulip/media.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/media.c 2 drivers/net/tulip/media.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,9 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 14*/
16 15
17#include <linux/kernel.h> 16#include <linux/kernel.h>
diff --git a/drivers/net/tulip/pnic.c b/drivers/net/tulip/pnic.c
index be82a2effee3..d3253ed09dfc 100644
--- a/drivers/net/tulip/pnic.c
+++ b/drivers/net/tulip/pnic.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/pnic.c 2 drivers/net/tulip/pnic.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,9 +8,9 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 14*/
16 15
17#include <linux/kernel.h> 16#include <linux/kernel.h>
diff --git a/drivers/net/tulip/pnic2.c b/drivers/net/tulip/pnic2.c
index 4e4a879c3fa5..f49579128fb5 100644
--- a/drivers/net/tulip/pnic2.c
+++ b/drivers/net/tulip/pnic2.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/pnic2.c 2 drivers/net/tulip/pnic2.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 Modified to hep support PNIC_II by Kevin B. Hendricks 6 Modified to hep support PNIC_II by Kevin B. Hendricks
@@ -10,9 +9,9 @@
10 of the GNU General Public License, incorporated herein by reference. 9 of the GNU General Public License, incorporated herein by reference.
11 10
12 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
13 for more information on this driver, or visit the project 12 for more information on this driver.
14 Web page at http://sourceforge.net/projects/tulip/
15 13
14 Please submit bugs to http://bugzilla.kernel.org/ .
16*/ 15*/
17 16
18 17
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
index d2c1f42109b0..a0e084223082 100644
--- a/drivers/net/tulip/timer.c
+++ b/drivers/net/tulip/timer.c
@@ -1,7 +1,6 @@
1/* 1/*
2 drivers/net/tulip/timer.c 2 drivers/net/tulip/timer.c
3 3
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
7 6
@@ -9,11 +8,12 @@
9 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
10 9
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 11 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 14*/
16 15
16
17#include "tulip.h" 17#include "tulip.h"
18 18
19 19
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index 92c68a22f16b..19abbc36b60a 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -8,9 +8,9 @@
8 of the GNU General Public License, incorporated herein by reference. 8 of the GNU General Public License, incorporated herein by reference.
9 9
10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 10 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
11 for more information on this driver, or visit the project 11 for more information on this driver.
12 Web page at http://sourceforge.net/projects/tulip/
13 12
13 Please submit bugs to http://bugzilla.kernel.org/ .
14*/ 14*/
15 15
16#ifndef __NET_TULIP_H__ 16#ifndef __NET_TULIP_H__
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index af8d2c436efd..cafa89e60167 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1,7 +1,5 @@
1/* tulip_core.c: A DEC 21x4x-family ethernet driver for Linux. */ 1/* tulip_core.c: A DEC 21x4x-family ethernet driver for Linux.
2 2
3/*
4 Maintained by Valerie Henson <val_henson@linux.intel.com>
5 Copyright 2000,2001 The Linux Kernel Team 3 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker. 4 Written/copyright 1994-2001 by Donald Becker.
7 5
@@ -9,9 +7,9 @@
9 of the GNU General Public License, incorporated herein by reference. 7 of the GNU General Public License, incorporated herein by reference.
10 8
11 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} 9 Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
12 for more information on this driver, or visit the project 10 for more information on this driver.
13 Web page at http://sourceforge.net/projects/tulip/
14 11
12 Please submit bugs to http://bugzilla.kernel.org/ .
15*/ 13*/
16 14
17 15
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index c0dd25ba7a18..8549f1159a30 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -334,8 +334,6 @@ enum state_values {
334#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY) 334#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY)
335#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY) 335#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY)
336 336
337#define typhoon_synchronize_irq(x) synchronize_irq(x)
338
339#if defined(NETIF_F_TSO) 337#if defined(NETIF_F_TSO)
340#define skb_tso_size(x) (skb_shinfo(x)->gso_size) 338#define skb_tso_size(x) (skb_shinfo(x)->gso_size)
341#define TSO_NUM_DESCRIPTORS 2 339#define TSO_NUM_DESCRIPTORS 2
@@ -2143,7 +2141,6 @@ typhoon_close(struct net_device *dev)
2143 printk(KERN_ERR "%s: unable to stop runtime\n", dev->name); 2141 printk(KERN_ERR "%s: unable to stop runtime\n", dev->name);
2144 2142
2145 /* Make sure there is no irq handler running on a different CPU. */ 2143 /* Make sure there is no irq handler running on a different CPU. */
2146 typhoon_synchronize_irq(dev->irq);
2147 free_irq(dev->irq, dev); 2144 free_irq(dev->irq, dev);
2148 2145
2149 typhoon_free_rx_rings(tp); 2146 typhoon_free_rx_rings(tp);
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index ae467f182c40..61c98beb4d17 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(rndis_status);
74 * Call context is likely probe(), before interface name is known, 74 * Call context is likely probe(), before interface name is known,
75 * which is why we won't try to use it in the diagnostics. 75 * which is why we won't try to use it in the diagnostics.
76 */ 76 */
77int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf) 77int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
78{ 78{
79 struct cdc_state *info = (void *) &dev->data; 79 struct cdc_state *info = (void *) &dev->data;
80 int master_ifnum; 80 int master_ifnum;
@@ -121,7 +121,7 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf)
121 USB_CDC_GET_ENCAPSULATED_RESPONSE, 121 USB_CDC_GET_ENCAPSULATED_RESPONSE,
122 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 122 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
123 0, master_ifnum, 123 0, master_ifnum,
124 buf, CONTROL_BUFFER_SIZE, 124 buf, buflen,
125 RNDIS_CONTROL_TIMEOUT_MS); 125 RNDIS_CONTROL_TIMEOUT_MS);
126 if (likely(retval >= 8)) { 126 if (likely(retval >= 8)) {
127 msg_len = le32_to_cpu(buf->msg_len); 127 msg_len = le32_to_cpu(buf->msg_len);
@@ -239,7 +239,7 @@ static int rndis_query(struct usbnet *dev, struct usb_interface *intf,
239 u.get->len = cpu_to_le32(in_len); 239 u.get->len = cpu_to_le32(in_len);
240 u.get->offset = ccpu2(20); 240 u.get->offset = ccpu2(20);
241 241
242 retval = rndis_command(dev, u.header); 242 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
243 if (unlikely(retval < 0)) { 243 if (unlikely(retval < 0)) {
244 dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n", 244 dev_err(&intf->dev, "RNDIS_MSG_QUERY(0x%08x) failed, %d\n",
245 oid, retval); 245 oid, retval);
@@ -328,7 +328,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
328 u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size); 328 u.init->max_transfer_size = cpu_to_le32(dev->rx_urb_size);
329 329
330 net->change_mtu = NULL; 330 net->change_mtu = NULL;
331 retval = rndis_command(dev, u.header); 331 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
332 if (unlikely(retval < 0)) { 332 if (unlikely(retval < 0)) {
333 /* it might not even be an RNDIS device!! */ 333 /* it might not even be an RNDIS device!! */
334 dev_err(&intf->dev, "RNDIS init failed, %d\n", retval); 334 dev_err(&intf->dev, "RNDIS init failed, %d\n", retval);
@@ -409,7 +409,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags)
409 u.set->offset = ccpu2((sizeof *u.set) - 8); 409 u.set->offset = ccpu2((sizeof *u.set) - 8);
410 *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER; 410 *(__le32 *)(u.buf + sizeof *u.set) = RNDIS_DEFAULT_FILTER;
411 411
412 retval = rndis_command(dev, u.header); 412 retval = rndis_command(dev, u.header, CONTROL_BUFFER_SIZE);
413 if (unlikely(retval < 0)) { 413 if (unlikely(retval < 0)) {
414 dev_err(&intf->dev, "rndis set packet filter, %d\n", retval); 414 dev_err(&intf->dev, "rndis set packet filter, %d\n", retval);
415 goto halt_fail_and_release; 415 goto halt_fail_and_release;
@@ -424,7 +424,7 @@ halt_fail_and_release:
424 memset(u.halt, 0, sizeof *u.halt); 424 memset(u.halt, 0, sizeof *u.halt);
425 u.halt->msg_type = RNDIS_MSG_HALT; 425 u.halt->msg_type = RNDIS_MSG_HALT;
426 u.halt->msg_len = ccpu2(sizeof *u.halt); 426 u.halt->msg_len = ccpu2(sizeof *u.halt);
427 (void) rndis_command(dev, (void *)u.halt); 427 (void) rndis_command(dev, (void *)u.halt, CONTROL_BUFFER_SIZE);
428fail_and_release: 428fail_and_release:
429 usb_set_intfdata(info->data, NULL); 429 usb_set_intfdata(info->data, NULL);
430 usb_driver_release_interface(driver_of(intf), info->data); 430 usb_driver_release_interface(driver_of(intf), info->data);
@@ -449,7 +449,7 @@ void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
449 if (halt) { 449 if (halt) {
450 halt->msg_type = RNDIS_MSG_HALT; 450 halt->msg_type = RNDIS_MSG_HALT;
451 halt->msg_len = ccpu2(sizeof *halt); 451 halt->msg_len = ccpu2(sizeof *halt);
452 (void) rndis_command(dev, (void *)halt); 452 (void) rndis_command(dev, (void *)halt, CONTROL_BUFFER_SIZE);
453 kfree(halt); 453 kfree(halt);
454 } 454 }
455 455
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 249e18053d5f..069f8bb0a99f 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -32,6 +32,7 @@
32#include <linux/x25.h> 32#include <linux/x25.h>
33#include <linux/lapb.h> 33#include <linux/lapb.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/rtnetlink.h>
35#include "x25_asy.h" 36#include "x25_asy.h"
36 37
37#include <net/x25device.h> 38#include <net/x25device.h>
@@ -601,8 +602,10 @@ static void x25_asy_close_tty(struct tty_struct *tty)
601 if (!sl || sl->magic != X25_ASY_MAGIC) 602 if (!sl || sl->magic != X25_ASY_MAGIC)
602 return; 603 return;
603 604
605 rtnl_lock();
604 if (sl->dev->flags & IFF_UP) 606 if (sl->dev->flags & IFF_UP)
605 dev_close(sl->dev); 607 dev_close(sl->dev);
608 rtnl_unlock();
606 609
607 tty->disc_data = NULL; 610 tty->disc_data = NULL;
608 sl->tty = NULL; 611 sl->tty = NULL;
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c
index 36a9c42df835..76f4c7bad8b8 100644
--- a/drivers/net/wireless/b43/leds.c
+++ b/drivers/net/wireless/b43/leds.c
@@ -72,6 +72,9 @@ static void b43_led_brightness_set(struct led_classdev *led_dev,
72 struct b43_wldev *dev = led->dev; 72 struct b43_wldev *dev = led->dev;
73 bool radio_enabled; 73 bool radio_enabled;
74 74
75 if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED))
76 return;
77
75 /* Checking the radio-enabled status here is slightly racy, 78 /* Checking the radio-enabled status here is slightly racy,
76 * but we want to avoid the locking overhead and we don't care 79 * but we want to avoid the locking overhead and we don't care
77 * whether the LED has the wrong state for a second. */ 80 * whether the LED has the wrong state for a second. */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 82cca19137f4..9d2eb273b726 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -3028,12 +3028,11 @@ static int b43_op_tx(struct ieee80211_hw *hw,
3028 3028
3029 if (unlikely(skb->len < 2 + 2 + 6)) { 3029 if (unlikely(skb->len < 2 + 2 + 6)) {
3030 /* Too short, this can't be a valid frame. */ 3030 /* Too short, this can't be a valid frame. */
3031 dev_kfree_skb_any(skb); 3031 goto drop_packet;
3032 return NETDEV_TX_OK;
3033 } 3032 }
3034 B43_WARN_ON(skb_shinfo(skb)->nr_frags); 3033 B43_WARN_ON(skb_shinfo(skb)->nr_frags);
3035 if (unlikely(!dev)) 3034 if (unlikely(!dev))
3036 return NETDEV_TX_BUSY; 3035 goto drop_packet;
3037 3036
3038 /* Transmissions on seperate queues can run concurrently. */ 3037 /* Transmissions on seperate queues can run concurrently. */
3039 read_lock_irqsave(&wl->tx_lock, flags); 3038 read_lock_irqsave(&wl->tx_lock, flags);
@@ -3049,7 +3048,12 @@ static int b43_op_tx(struct ieee80211_hw *hw,
3049 read_unlock_irqrestore(&wl->tx_lock, flags); 3048 read_unlock_irqrestore(&wl->tx_lock, flags);
3050 3049
3051 if (unlikely(err)) 3050 if (unlikely(err))
3052 return NETDEV_TX_BUSY; 3051 goto drop_packet;
3052 return NETDEV_TX_OK;
3053
3054drop_packet:
3055 /* We can not transmit this packet. Drop it. */
3056 dev_kfree_skb_any(skb);
3053 return NETDEV_TX_OK; 3057 return NETDEV_TX_OK;
3054} 3058}
3055 3059
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index 9736b2f56a75..eb0243a22691 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -875,6 +875,7 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev,
875 if (!ring) 875 if (!ring)
876 goto out; 876 goto out;
877 ring->type = type; 877 ring->type = type;
878 ring->dev = dev;
878 879
879 nr_slots = B43legacy_RXRING_SLOTS; 880 nr_slots = B43legacy_RXRING_SLOTS;
880 if (for_tx) 881 if (for_tx)
@@ -921,7 +922,6 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev,
921 DMA_TO_DEVICE); 922 DMA_TO_DEVICE);
922 } 923 }
923 924
924 ring->dev = dev;
925 ring->nr_slots = nr_slots; 925 ring->nr_slots = nr_slots;
926 ring->mmio_base = b43legacy_dmacontroller_base(type, controller_index); 926 ring->mmio_base = b43legacy_dmacontroller_base(type, controller_index);
927 ring->index = controller_index; 927 ring->index = controller_index;
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index 5f533b93ad5d..069157eea05c 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -2377,8 +2377,10 @@ static int b43legacy_op_tx(struct ieee80211_hw *hw,
2377 } else 2377 } else
2378 err = b43legacy_dma_tx(dev, skb); 2378 err = b43legacy_dma_tx(dev, skb);
2379out: 2379out:
2380 if (unlikely(err)) 2380 if (unlikely(err)) {
2381 return NETDEV_TX_BUSY; 2381 /* Drop the packet. */
2382 dev_kfree_skb_any(skb);
2383 }
2382 return NETDEV_TX_OK; 2384 return NETDEV_TX_OK;
2383} 2385}
2384 2386
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 5ca181f7125d..5b420b43af5c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -276,13 +276,18 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
276 cancel_delayed_work(&priv->scan_check); 276 cancel_delayed_work(&priv->scan_check);
277 277
278 IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", 278 IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n",
279 (priv->scan_bands == 2) ? "2.4" : "5.2", 279 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ?
280 "2.4" : "5.2",
280 jiffies_to_msecs(elapsed_jiffies 281 jiffies_to_msecs(elapsed_jiffies
281 (priv->scan_pass_start, jiffies))); 282 (priv->scan_pass_start, jiffies)));
282 283
283 /* Remove this scanned band from the list 284 /* Remove this scanned band from the list of pending
284 * of pending bands to scan */ 285 * bands to scan, band G precedes A in order of scanning
285 priv->scan_bands--; 286 * as seen in iwl_bg_request_scan */
287 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ))
288 priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ);
289 else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ))
290 priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ);
286 291
287 /* If a request to abort was given, or the scan did not succeed 292 /* If a request to abort was given, or the scan did not succeed
288 * then we reset the scan state machine and terminate, 293 * then we reset the scan state machine and terminate,
@@ -292,7 +297,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
292 clear_bit(STATUS_SCAN_ABORTING, &priv->status); 297 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
293 } else { 298 } else {
294 /* If there are more bands on this scan pass reschedule */ 299 /* If there are more bands on this scan pass reschedule */
295 if (priv->scan_bands > 0) 300 if (priv->scan_bands)
296 goto reschedule; 301 goto reschedule;
297 } 302 }
298 303
@@ -389,7 +394,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
389 394
390 ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); 395 ch_info = iwl_get_channel_info(priv, band, scan_ch->channel);
391 if (!is_channel_valid(ch_info)) { 396 if (!is_channel_valid(ch_info)) {
392 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 397 IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n",
393 scan_ch->channel); 398 scan_ch->channel);
394 continue; 399 continue;
395 } 400 }
@@ -465,7 +470,10 @@ int iwl_scan_initiate(struct iwl_priv *priv)
465 } 470 }
466 471
467 IWL_DEBUG_INFO("Starting scan...\n"); 472 IWL_DEBUG_INFO("Starting scan...\n");
468 priv->scan_bands = 2; 473 if (priv->cfg->sku & IWL_SKU_G)
474 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
475 if (priv->cfg->sku & IWL_SKU_A)
476 priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ);
469 set_bit(STATUS_SCANNING, &priv->status); 477 set_bit(STATUS_SCANNING, &priv->status);
470 priv->scan_start = jiffies; 478 priv->scan_start = jiffies;
471 priv->scan_pass_start = priv->scan_start; 479 priv->scan_pass_start = priv->scan_start;
@@ -803,8 +811,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
803 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 811 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
804 812
805 813
806 switch (priv->scan_bands) { 814 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) {
807 case 2:
808 band = IEEE80211_BAND_2GHZ; 815 band = IEEE80211_BAND_2GHZ;
809 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 816 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
810 tx_ant = iwl_scan_tx_ant(priv, band); 817 tx_ant = iwl_scan_tx_ant(priv, band);
@@ -818,9 +825,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
818 tx_ant | 825 tx_ant |
819 RATE_MCS_CCK_MSK); 826 RATE_MCS_CCK_MSK);
820 scan->good_CRC_th = 0; 827 scan->good_CRC_th = 0;
821 break; 828 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
822
823 case 1:
824 band = IEEE80211_BAND_5GHZ; 829 band = IEEE80211_BAND_5GHZ;
825 tx_ant = iwl_scan_tx_ant(priv, band); 830 tx_ant = iwl_scan_tx_ant(priv, band);
826 scan->tx_cmd.rate_n_flags = 831 scan->tx_cmd.rate_n_flags =
@@ -833,9 +838,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
833 * MIMO is not used here, but value is required */ 838 * MIMO is not used here, but value is required */
834 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) 839 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
835 rx_chain = 0x6; 840 rx_chain = 0x6;
836 841 } else {
837 break;
838 default:
839 IWL_WARNING("Invalid scan band count\n"); 842 IWL_WARNING("Invalid scan band count\n");
840 goto done; 843 goto done;
841 } 844 }
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 47cf4b997f50..92d1b2e312d4 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2217,7 +2217,10 @@ static int iwl3945_scan_initiate(struct iwl3945_priv *priv)
2217 } 2217 }
2218 2218
2219 IWL_DEBUG_INFO("Starting scan...\n"); 2219 IWL_DEBUG_INFO("Starting scan...\n");
2220 priv->scan_bands = 2; 2220 if (priv->cfg->sku & IWL_SKU_G)
2221 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
2222 if (priv->cfg->sku & IWL_SKU_A)
2223 priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ);
2221 set_bit(STATUS_SCANNING, &priv->status); 2224 set_bit(STATUS_SCANNING, &priv->status);
2222 priv->scan_start = jiffies; 2225 priv->scan_start = jiffies;
2223 priv->scan_pass_start = priv->scan_start; 2226 priv->scan_pass_start = priv->scan_start;
@@ -3342,13 +3345,18 @@ static void iwl3945_rx_scan_complete_notif(struct iwl3945_priv *priv,
3342 cancel_delayed_work(&priv->scan_check); 3345 cancel_delayed_work(&priv->scan_check);
3343 3346
3344 IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", 3347 IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n",
3345 (priv->scan_bands == 2) ? "2.4" : "5.2", 3348 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ?
3349 "2.4" : "5.2",
3346 jiffies_to_msecs(elapsed_jiffies 3350 jiffies_to_msecs(elapsed_jiffies
3347 (priv->scan_pass_start, jiffies))); 3351 (priv->scan_pass_start, jiffies)));
3348 3352
3349 /* Remove this scanned band from the list 3353 /* Remove this scanned band from the list of pending
3350 * of pending bands to scan */ 3354 * bands to scan, band G precedes A in order of scanning
3351 priv->scan_bands--; 3355 * as seen in iwl3945_bg_request_scan */
3356 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ))
3357 priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ);
3358 else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ))
3359 priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ);
3352 3360
3353 /* If a request to abort was given, or the scan did not succeed 3361 /* If a request to abort was given, or the scan did not succeed
3354 * then we reset the scan state machine and terminate, 3362 * then we reset the scan state machine and terminate,
@@ -4961,7 +4969,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv,
4961 4969
4962 ch_info = iwl3945_get_channel_info(priv, band, scan_ch->channel); 4970 ch_info = iwl3945_get_channel_info(priv, band, scan_ch->channel);
4963 if (!is_channel_valid(ch_info)) { 4971 if (!is_channel_valid(ch_info)) {
4964 IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", 4972 IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n",
4965 scan_ch->channel); 4973 scan_ch->channel);
4966 continue; 4974 continue;
4967 } 4975 }
@@ -6316,21 +6324,16 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
6316 6324
6317 /* flags + rate selection */ 6325 /* flags + rate selection */
6318 6326
6319 switch (priv->scan_bands) { 6327 if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) {
6320 case 2:
6321 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 6328 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
6322 scan->tx_cmd.rate = IWL_RATE_1M_PLCP; 6329 scan->tx_cmd.rate = IWL_RATE_1M_PLCP;
6323 scan->good_CRC_th = 0; 6330 scan->good_CRC_th = 0;
6324 band = IEEE80211_BAND_2GHZ; 6331 band = IEEE80211_BAND_2GHZ;
6325 break; 6332 } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) {
6326
6327 case 1:
6328 scan->tx_cmd.rate = IWL_RATE_6M_PLCP; 6333 scan->tx_cmd.rate = IWL_RATE_6M_PLCP;
6329 scan->good_CRC_th = IWL_GOOD_CRC_TH; 6334 scan->good_CRC_th = IWL_GOOD_CRC_TH;
6330 band = IEEE80211_BAND_5GHZ; 6335 band = IEEE80211_BAND_5GHZ;
6331 break; 6336 } else {
6332
6333 default:
6334 IWL_WARNING("Invalid scan band count\n"); 6337 IWL_WARNING("Invalid scan band count\n");
6335 goto done; 6338 goto done;
6336 } 6339 }
@@ -6770,7 +6773,7 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co
6770 ch_info = iwl3945_get_channel_info(priv, conf->channel->band, 6773 ch_info = iwl3945_get_channel_info(priv, conf->channel->band,
6771 conf->channel->hw_value); 6774 conf->channel->hw_value);
6772 if (!is_channel_valid(ch_info)) { 6775 if (!is_channel_valid(ch_info)) {
6773 IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n", 6776 IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this band.\n",
6774 conf->channel->hw_value, conf->channel->band); 6777 conf->channel->hw_value, conf->channel->band);
6775 IWL_DEBUG_MAC80211("leave - invalid channel\n"); 6778 IWL_DEBUG_MAC80211("leave - invalid channel\n");
6776 spin_unlock_irqrestore(&priv->lock, flags); 6779 spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index 762e85bef55d..e43bae97ed8f 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -290,7 +290,7 @@ islpci_monitor_rx(islpci_private *priv, struct sk_buff **skb)
290 290
291 avs->version = cpu_to_be32(P80211CAPTURE_VERSION); 291 avs->version = cpu_to_be32(P80211CAPTURE_VERSION);
292 avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header)); 292 avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header));
293 avs->mactime = cpu_to_be64(le64_to_cpu(clock)); 293 avs->mactime = cpu_to_be64(clock);
294 avs->hosttime = cpu_to_be64(jiffies); 294 avs->hosttime = cpu_to_be64(jiffies);
295 avs->phytype = cpu_to_be32(6); /*OFDM: 6 for (g), 8 for (a) */ 295 avs->phytype = cpu_to_be32(6); /*OFDM: 6 for (g), 8 for (a) */
296 avs->channel = cpu_to_be32(channel_of_freq(freq)); 296 avs->channel = cpu_to_be32(channel_of_freq(freq));
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 65c50025c88f..00e965b9da75 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -448,7 +448,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
448 u.get->msg_len = ccpu2(sizeof *u.get); 448 u.get->msg_len = ccpu2(sizeof *u.get);
449 u.get->oid = oid; 449 u.get->oid = oid;
450 450
451 ret = rndis_command(dev, u.header); 451 ret = rndis_command(dev, u.header, buflen);
452 if (ret == 0) { 452 if (ret == 0) {
453 ret = le32_to_cpu(u.get_c->len); 453 ret = le32_to_cpu(u.get_c->len);
454 *len = (*len > ret) ? ret : *len; 454 *len = (*len > ret) ? ret : *len;
@@ -498,7 +498,7 @@ static int rndis_set_oid(struct usbnet *dev, __le32 oid, void *data, int len)
498 u.set->handle = ccpu2(0); 498 u.set->handle = ccpu2(0);
499 memcpy(u.buf + sizeof(*u.set), data, len); 499 memcpy(u.buf + sizeof(*u.set), data, len);
500 500
501 ret = rndis_command(dev, u.header); 501 ret = rndis_command(dev, u.header, buflen);
502 if (ret == 0) 502 if (ret == 0)
503 ret = rndis_error_status(u.set_c->status); 503 ret = rndis_error_status(u.set_c->status);
504 504
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index d0958008c013..0dd1cb537b92 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -138,11 +138,8 @@ static void rt2500usb_bbp_write(struct rt2x00_dev *rt2x00dev,
138 * Wait until the BBP becomes ready. 138 * Wait until the BBP becomes ready.
139 */ 139 */
140 reg = rt2500usb_bbp_check(rt2x00dev); 140 reg = rt2500usb_bbp_check(rt2x00dev);
141 if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) { 141 if (rt2x00_get_field16(reg, PHY_CSR8_BUSY))
142 ERROR(rt2x00dev, "PHY_CSR8 register busy. Write failed.\n"); 142 goto exit_fail;
143 mutex_unlock(&rt2x00dev->usb_cache_mutex);
144 return;
145 }
146 143
147 /* 144 /*
148 * Write the data into the BBP. 145 * Write the data into the BBP.
@@ -155,6 +152,13 @@ static void rt2500usb_bbp_write(struct rt2x00_dev *rt2x00dev,
155 rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg); 152 rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg);
156 153
157 mutex_unlock(&rt2x00dev->usb_cache_mutex); 154 mutex_unlock(&rt2x00dev->usb_cache_mutex);
155
156 return;
157
158exit_fail:
159 mutex_unlock(&rt2x00dev->usb_cache_mutex);
160
161 ERROR(rt2x00dev, "PHY_CSR8 register busy. Write failed.\n");
158} 162}
159 163
160static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev, 164static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev,
@@ -168,10 +172,8 @@ static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev,
168 * Wait until the BBP becomes ready. 172 * Wait until the BBP becomes ready.
169 */ 173 */
170 reg = rt2500usb_bbp_check(rt2x00dev); 174 reg = rt2500usb_bbp_check(rt2x00dev);
171 if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) { 175 if (rt2x00_get_field16(reg, PHY_CSR8_BUSY))
172 ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n"); 176 goto exit_fail;
173 return;
174 }
175 177
176 /* 178 /*
177 * Write the request into the BBP. 179 * Write the request into the BBP.
@@ -186,17 +188,21 @@ static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev,
186 * Wait until the BBP becomes ready. 188 * Wait until the BBP becomes ready.
187 */ 189 */
188 reg = rt2500usb_bbp_check(rt2x00dev); 190 reg = rt2500usb_bbp_check(rt2x00dev);
189 if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) { 191 if (rt2x00_get_field16(reg, PHY_CSR8_BUSY))
190 ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n"); 192 goto exit_fail;
191 *value = 0xff;
192 mutex_unlock(&rt2x00dev->usb_cache_mutex);
193 return;
194 }
195 193
196 rt2500usb_register_read_lock(rt2x00dev, PHY_CSR7, &reg); 194 rt2500usb_register_read_lock(rt2x00dev, PHY_CSR7, &reg);
197 *value = rt2x00_get_field16(reg, PHY_CSR7_DATA); 195 *value = rt2x00_get_field16(reg, PHY_CSR7_DATA);
198 196
199 mutex_unlock(&rt2x00dev->usb_cache_mutex); 197 mutex_unlock(&rt2x00dev->usb_cache_mutex);
198
199 return;
200
201exit_fail:
202 mutex_unlock(&rt2x00dev->usb_cache_mutex);
203
204 ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n");
205 *value = 0xff;
200} 206}
201 207
202static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev, 208static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index d2ddab179c9e..6842464dcf3e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -788,6 +788,7 @@ struct rt2x00_dev {
788 /* 788 /*
789 * Scheduled work. 789 * Scheduled work.
790 */ 790 */
791 struct workqueue_struct *workqueue;
791 struct work_struct intf_work; 792 struct work_struct intf_work;
792 struct work_struct filter_work; 793 struct work_struct filter_work;
793 794
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 2a63a7b911b4..ae8ab71fe474 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -74,7 +74,7 @@ static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev)
74 74
75 rt2x00lib_reset_link_tuner(rt2x00dev); 75 rt2x00lib_reset_link_tuner(rt2x00dev);
76 76
77 queue_delayed_work(rt2x00dev->hw->workqueue, 77 queue_delayed_work(rt2x00dev->workqueue,
78 &rt2x00dev->link.work, LINK_TUNE_INTERVAL); 78 &rt2x00dev->link.work, LINK_TUNE_INTERVAL);
79} 79}
80 80
@@ -138,14 +138,6 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
138 return; 138 return;
139 139
140 /* 140 /*
141 * Stop all scheduled work.
142 */
143 if (work_pending(&rt2x00dev->intf_work))
144 cancel_work_sync(&rt2x00dev->intf_work);
145 if (work_pending(&rt2x00dev->filter_work))
146 cancel_work_sync(&rt2x00dev->filter_work);
147
148 /*
149 * Stop the TX queues. 141 * Stop the TX queues.
150 */ 142 */
151 ieee80211_stop_queues(rt2x00dev->hw); 143 ieee80211_stop_queues(rt2x00dev->hw);
@@ -400,8 +392,8 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
400 * Increase tuner counter, and reschedule the next link tuner run. 392 * Increase tuner counter, and reschedule the next link tuner run.
401 */ 393 */
402 rt2x00dev->link.count++; 394 rt2x00dev->link.count++;
403 queue_delayed_work(rt2x00dev->hw->workqueue, &rt2x00dev->link.work, 395 queue_delayed_work(rt2x00dev->workqueue,
404 LINK_TUNE_INTERVAL); 396 &rt2x00dev->link.work, LINK_TUNE_INTERVAL);
405} 397}
406 398
407static void rt2x00lib_packetfilter_scheduled(struct work_struct *work) 399static void rt2x00lib_packetfilter_scheduled(struct work_struct *work)
@@ -434,6 +426,15 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
434 426
435 spin_unlock(&intf->lock); 427 spin_unlock(&intf->lock);
436 428
429 /*
430 * It is possible the radio was disabled while the work had been
431 * scheduled. If that happens we should return here immediately,
432 * note that in the spinlock protected area above the delayed_flags
433 * have been cleared correctly.
434 */
435 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
436 return;
437
437 if (delayed_flags & DELAYED_UPDATE_BEACON) { 438 if (delayed_flags & DELAYED_UPDATE_BEACON) {
438 skb = ieee80211_beacon_get(rt2x00dev->hw, vif); 439 skb = ieee80211_beacon_get(rt2x00dev->hw, vif);
439 if (skb && 440 if (skb &&
@@ -442,7 +443,7 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
442 } 443 }
443 444
444 if (delayed_flags & DELAYED_CONFIG_ERP) 445 if (delayed_flags & DELAYED_CONFIG_ERP)
445 rt2x00lib_config_erp(rt2x00dev, intf, &intf->conf); 446 rt2x00lib_config_erp(rt2x00dev, intf, &conf);
446 447
447 if (delayed_flags & DELAYED_LED_ASSOC) 448 if (delayed_flags & DELAYED_LED_ASSOC)
448 rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated); 449 rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated);
@@ -495,7 +496,7 @@ void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev)
495 rt2x00lib_beacondone_iter, 496 rt2x00lib_beacondone_iter,
496 rt2x00dev); 497 rt2x00dev);
497 498
498 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work); 499 queue_work(rt2x00dev->workqueue, &rt2x00dev->intf_work);
499} 500}
500EXPORT_SYMBOL_GPL(rt2x00lib_beacondone); 501EXPORT_SYMBOL_GPL(rt2x00lib_beacondone);
501 502
@@ -1063,6 +1064,10 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1063 /* 1064 /*
1064 * Initialize configuration work. 1065 * Initialize configuration work.
1065 */ 1066 */
1067 rt2x00dev->workqueue = create_singlethread_workqueue("rt2x00lib");
1068 if (!rt2x00dev->workqueue)
1069 goto exit;
1070
1066 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); 1071 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
1067 INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled); 1072 INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled);
1068 INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner); 1073 INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner);
@@ -1123,6 +1128,13 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
1123 rt2x00leds_unregister(rt2x00dev); 1128 rt2x00leds_unregister(rt2x00dev);
1124 1129
1125 /* 1130 /*
1131 * Stop all queued work. Note that most tasks will already be halted
1132 * during rt2x00lib_disable_radio() and rt2x00lib_uninitialize().
1133 */
1134 flush_workqueue(rt2x00dev->workqueue);
1135 destroy_workqueue(rt2x00dev->workqueue);
1136
1137 /*
1126 * Free ieee80211_hw memory. 1138 * Free ieee80211_hw memory.
1127 */ 1139 */
1128 rt2x00lib_remove_hw(rt2x00dev); 1140 rt2x00lib_remove_hw(rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index c90992f613fe..1253da89295b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -431,7 +431,7 @@ void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
431 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags)) 431 if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags))
432 rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags); 432 rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags);
433 else 433 else
434 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work); 434 queue_work(rt2x00dev->workqueue, &rt2x00dev->filter_work);
435} 435}
436EXPORT_SYMBOL_GPL(rt2x00mac_configure_filter); 436EXPORT_SYMBOL_GPL(rt2x00mac_configure_filter);
437 437
@@ -512,7 +512,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
512 memcpy(&intf->conf, bss_conf, sizeof(*bss_conf)); 512 memcpy(&intf->conf, bss_conf, sizeof(*bss_conf));
513 if (delayed) { 513 if (delayed) {
514 intf->delayed_flags |= delayed; 514 intf->delayed_flags |= delayed;
515 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work); 515 queue_work(rt2x00dev->workqueue, &rt2x00dev->intf_work);
516 } 516 }
517 spin_unlock(&intf->lock); 517 spin_unlock(&intf->lock);
518} 518}
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index ead6db04d60a..3ef318e098e7 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -134,11 +134,8 @@ static void rt73usb_bbp_write(struct rt2x00_dev *rt2x00dev,
134 * Wait until the BBP becomes ready. 134 * Wait until the BBP becomes ready.
135 */ 135 */
136 reg = rt73usb_bbp_check(rt2x00dev); 136 reg = rt73usb_bbp_check(rt2x00dev);
137 if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { 137 if (rt2x00_get_field32(reg, PHY_CSR3_BUSY))
138 ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n"); 138 goto exit_fail;
139 mutex_unlock(&rt2x00dev->usb_cache_mutex);
140 return;
141 }
142 139
143 /* 140 /*
144 * Write the data into the BBP. 141 * Write the data into the BBP.
@@ -151,6 +148,13 @@ static void rt73usb_bbp_write(struct rt2x00_dev *rt2x00dev,
151 148
152 rt73usb_register_write_lock(rt2x00dev, PHY_CSR3, reg); 149 rt73usb_register_write_lock(rt2x00dev, PHY_CSR3, reg);
153 mutex_unlock(&rt2x00dev->usb_cache_mutex); 150 mutex_unlock(&rt2x00dev->usb_cache_mutex);
151
152 return;
153
154exit_fail:
155 mutex_unlock(&rt2x00dev->usb_cache_mutex);
156
157 ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n");
154} 158}
155 159
156static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev, 160static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev,
@@ -164,11 +168,8 @@ static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev,
164 * Wait until the BBP becomes ready. 168 * Wait until the BBP becomes ready.
165 */ 169 */
166 reg = rt73usb_bbp_check(rt2x00dev); 170 reg = rt73usb_bbp_check(rt2x00dev);
167 if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { 171 if (rt2x00_get_field32(reg, PHY_CSR3_BUSY))
168 ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); 172 goto exit_fail;
169 mutex_unlock(&rt2x00dev->usb_cache_mutex);
170 return;
171 }
172 173
173 /* 174 /*
174 * Write the request into the BBP. 175 * Write the request into the BBP.
@@ -184,14 +185,19 @@ static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev,
184 * Wait until the BBP becomes ready. 185 * Wait until the BBP becomes ready.
185 */ 186 */
186 reg = rt73usb_bbp_check(rt2x00dev); 187 reg = rt73usb_bbp_check(rt2x00dev);
187 if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { 188 if (rt2x00_get_field32(reg, PHY_CSR3_BUSY))
188 ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); 189 goto exit_fail;
189 *value = 0xff;
190 return;
191 }
192 190
193 *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE); 191 *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE);
194 mutex_unlock(&rt2x00dev->usb_cache_mutex); 192 mutex_unlock(&rt2x00dev->usb_cache_mutex);
193
194 return;
195
196exit_fail:
197 mutex_unlock(&rt2x00dev->usb_cache_mutex);
198
199 ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n");
200 *value = 0xff;
195} 201}
196 202
197static void rt73usb_rf_write(struct rt2x00_dev *rt2x00dev, 203static void rt73usb_rf_write(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 9d6fc8e6285d..f7904ff2ace0 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -315,6 +315,25 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev,
315 } 315 }
316 return PCI_POWER_ERROR; 316 return PCI_POWER_ERROR;
317} 317}
318
319static int acpi_platform_enable_wakeup(struct device *dev, int is_on)
320{
321 struct acpi_device *adev;
322 int status;
323
324 if (!device_can_wakeup(dev))
325 return -EINVAL;
326
327 if (is_on && !device_may_wakeup(dev))
328 return -EINVAL;
329
330 status = acpi_bus_get_device(DEVICE_ACPI_HANDLE(dev), &adev);
331 if (status < 0)
332 return status;
333
334 adev->wakeup.state.enabled = !!is_on;
335 return 0;
336}
318#endif 337#endif
319 338
320static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) 339static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
@@ -399,6 +418,7 @@ static int __init acpi_pci_init(void)
399 return 0; 418 return 0;
400#ifdef CONFIG_ACPI_SLEEP 419#ifdef CONFIG_ACPI_SLEEP
401 platform_pci_choose_state = acpi_pci_choose_state; 420 platform_pci_choose_state = acpi_pci_choose_state;
421 platform_enable_wakeup = acpi_platform_enable_wakeup;
402#endif 422#endif
403 platform_pci_set_power_state = acpi_pci_set_power_state; 423 platform_pci_set_power_state = acpi_pci_set_power_state;
404 return 0; 424 return 0;