aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-04-27 15:49:13 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-27 15:49:13 -0400
commite1703b36c358dde24ececba4fd609ecd91433ba3 (patch)
treed59c333d0ad5bf72f165264eba6048c87fdc4e0f /drivers/net
parent7ec75c582e639d956ce3afd499f67febe6f902a4 (diff)
parente95ef5d3f6bc60433883e1ef65dac747acd0bf1a (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts: drivers/net/e100.c drivers/net/e1000e/netdev.c
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/can/usb/ems_usb.c8
-rw-r--r--drivers/net/cxgb3/ael1002.c2
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c2
-rw-r--r--drivers/net/e100.c10
-rw-r--r--drivers/net/e1000e/82571.c20
-rw-r--r--drivers/net/e1000e/e1000.h5
-rw-r--r--drivers/net/e1000e/netdev.c73
-rw-r--r--drivers/net/fsl_pq_mdio.c20
-rw-r--r--drivers/net/gianfar.c6
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c62
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c22
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h2
-rw-r--r--drivers/net/ks8851.c12
-rw-r--r--drivers/net/pcmcia/3c574_cs.c7
-rw-r--r--drivers/net/r8169.c32
-rw-r--r--drivers/net/tg3.c1
-rw-r--r--drivers/net/usb/Kconfig12
-rw-r--r--drivers/net/usb/Makefile1
-rw-r--r--drivers/net/usb/ipheth.c568
20 files changed, 762 insertions, 104 deletions
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index ebf80b983063..0a0512ae77da 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -273,6 +273,7 @@ obj-$(CONFIG_USB_RTL8150) += usb/
273obj-$(CONFIG_USB_HSO) += usb/ 273obj-$(CONFIG_USB_HSO) += usb/
274obj-$(CONFIG_USB_USBNET) += usb/ 274obj-$(CONFIG_USB_USBNET) += usb/
275obj-$(CONFIG_USB_ZD1201) += usb/ 275obj-$(CONFIG_USB_ZD1201) += usb/
276obj-$(CONFIG_USB_IPHETH) += usb/
276 277
277obj-y += wireless/ 278obj-y += wireless/
278obj-$(CONFIG_NET_TULIP) += tulip/ 279obj-$(CONFIG_NET_TULIP) += tulip/
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 33451092b8e8..d800b598ae3d 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -1006,7 +1006,7 @@ static int ems_usb_probe(struct usb_interface *intf,
1006 1006
1007 netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS); 1007 netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS);
1008 if (!netdev) { 1008 if (!netdev) {
1009 dev_err(netdev->dev.parent, "Couldn't alloc candev\n"); 1009 dev_err(&intf->dev, "ems_usb: Couldn't alloc candev\n");
1010 return -ENOMEM; 1010 return -ENOMEM;
1011 } 1011 }
1012 1012
@@ -1036,20 +1036,20 @@ static int ems_usb_probe(struct usb_interface *intf,
1036 1036
1037 dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); 1037 dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
1038 if (!dev->intr_urb) { 1038 if (!dev->intr_urb) {
1039 dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n"); 1039 dev_err(&intf->dev, "Couldn't alloc intr URB\n");
1040 goto cleanup_candev; 1040 goto cleanup_candev;
1041 } 1041 }
1042 1042
1043 dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); 1043 dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL);
1044 if (!dev->intr_in_buffer) { 1044 if (!dev->intr_in_buffer) {
1045 dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n"); 1045 dev_err(&intf->dev, "Couldn't alloc Intr buffer\n");
1046 goto cleanup_intr_urb; 1046 goto cleanup_intr_urb;
1047 } 1047 }
1048 1048
1049 dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + 1049 dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE +
1050 sizeof(struct ems_cpc_msg), GFP_KERNEL); 1050 sizeof(struct ems_cpc_msg), GFP_KERNEL);
1051 if (!dev->tx_msg_buffer) { 1051 if (!dev->tx_msg_buffer) {
1052 dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n"); 1052 dev_err(&intf->dev, "Couldn't alloc Tx buffer\n");
1053 goto cleanup_intr_in_buffer; 1053 goto cleanup_intr_in_buffer;
1054 } 1054 }
1055 1055
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c
index 5248f9e0b2f4..35cd36729155 100644
--- a/drivers/net/cxgb3/ael1002.c
+++ b/drivers/net/cxgb3/ael1002.c
@@ -934,7 +934,7 @@ static struct cphy_ops xaui_direct_ops = {
934int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, 934int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter,
935 int phy_addr, const struct mdio_ops *mdio_ops) 935 int phy_addr, const struct mdio_ops *mdio_ops)
936{ 936{
937 cphy_init(phy, adapter, MDIO_PRTAD_NONE, &xaui_direct_ops, mdio_ops, 937 cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops,
938 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, 938 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP,
939 "10GBASE-CX4"); 939 "10GBASE-CX4");
940 return 0; 940 return 0;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index aced6c5e635c..e3f1b8566495 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -439,7 +439,7 @@ static void free_irq_resources(struct adapter *adapter)
439static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt, 439static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt,
440 unsigned long n) 440 unsigned long n)
441{ 441{
442 int attempts = 5; 442 int attempts = 10;
443 443
444 while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) { 444 while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) {
445 if (!--attempts) 445 if (!--attempts)
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 3e8d0005540f..ef97bfcef9dd 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -168,6 +168,7 @@
168#include <linux/ethtool.h> 168#include <linux/ethtool.h>
169#include <linux/string.h> 169#include <linux/string.h>
170#include <linux/firmware.h> 170#include <linux/firmware.h>
171#include <linux/rtnetlink.h>
171#include <asm/unaligned.h> 172#include <asm/unaligned.h>
172 173
173 174
@@ -2280,8 +2281,13 @@ static void e100_tx_timeout_task(struct work_struct *work)
2280 2281
2281 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev, 2282 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
2282 "scb.status=0x%02X\n", ioread8(&nic->csr->scb.status)); 2283 "scb.status=0x%02X\n", ioread8(&nic->csr->scb.status));
2283 e100_down(netdev_priv(netdev)); 2284
2284 e100_up(netdev_priv(netdev)); 2285 rtnl_lock();
2286 if (netif_running(netdev)) {
2287 e100_down(netdev_priv(netdev));
2288 e100_up(netdev_priv(netdev));
2289 }
2290 rtnl_unlock();
2285} 2291}
2286 2292
2287static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) 2293static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 4b0016d69530..17a25e19bbba 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -336,7 +336,6 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
336 struct e1000_hw *hw = &adapter->hw; 336 struct e1000_hw *hw = &adapter->hw;
337 static int global_quad_port_a; /* global port a indication */ 337 static int global_quad_port_a; /* global port a indication */
338 struct pci_dev *pdev = adapter->pdev; 338 struct pci_dev *pdev = adapter->pdev;
339 u16 eeprom_data = 0;
340 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; 339 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
341 s32 rc; 340 s32 rc;
342 341
@@ -387,16 +386,15 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
387 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) 386 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
388 adapter->flags &= ~FLAG_HAS_WOL; 387 adapter->flags &= ~FLAG_HAS_WOL;
389 break; 388 break;
390
391 case e1000_82573: 389 case e1000_82573:
390 case e1000_82574:
391 case e1000_82583:
392 /* Disable ASPM L0s due to hardware errata */
393 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S);
394
392 if (pdev->device == E1000_DEV_ID_82573L) { 395 if (pdev->device == E1000_DEV_ID_82573L) {
393 if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1, 396 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
394 &eeprom_data) < 0) 397 adapter->max_hw_frame_size = DEFAULT_JUMBO;
395 break;
396 if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) {
397 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
398 adapter->max_hw_frame_size = DEFAULT_JUMBO;
399 }
400 } 398 }
401 break; 399 break;
402 default: 400 default:
@@ -1792,6 +1790,7 @@ struct e1000_info e1000_82571_info = {
1792 | FLAG_RESET_OVERWRITES_LAA /* errata */ 1790 | FLAG_RESET_OVERWRITES_LAA /* errata */
1793 | FLAG_TARC_SPEED_MODE_BIT /* errata */ 1791 | FLAG_TARC_SPEED_MODE_BIT /* errata */
1794 | FLAG_APME_CHECK_PORT_B, 1792 | FLAG_APME_CHECK_PORT_B,
1793 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
1795 .pba = 38, 1794 .pba = 38,
1796 .max_hw_frame_size = DEFAULT_JUMBO, 1795 .max_hw_frame_size = DEFAULT_JUMBO,
1797 .get_variants = e1000_get_variants_82571, 1796 .get_variants = e1000_get_variants_82571,
@@ -1809,6 +1808,7 @@ struct e1000_info e1000_82572_info = {
1809 | FLAG_RX_CSUM_ENABLED 1808 | FLAG_RX_CSUM_ENABLED
1810 | FLAG_HAS_CTRLEXT_ON_LOAD 1809 | FLAG_HAS_CTRLEXT_ON_LOAD
1811 | FLAG_TARC_SPEED_MODE_BIT, /* errata */ 1810 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
1811 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
1812 .pba = 38, 1812 .pba = 38,
1813 .max_hw_frame_size = DEFAULT_JUMBO, 1813 .max_hw_frame_size = DEFAULT_JUMBO,
1814 .get_variants = e1000_get_variants_82571, 1814 .get_variants = e1000_get_variants_82571,
@@ -1820,13 +1820,11 @@ struct e1000_info e1000_82572_info = {
1820struct e1000_info e1000_82573_info = { 1820struct e1000_info e1000_82573_info = {
1821 .mac = e1000_82573, 1821 .mac = e1000_82573,
1822 .flags = FLAG_HAS_HW_VLAN_FILTER 1822 .flags = FLAG_HAS_HW_VLAN_FILTER
1823 | FLAG_HAS_JUMBO_FRAMES
1824 | FLAG_HAS_WOL 1823 | FLAG_HAS_WOL
1825 | FLAG_APME_IN_CTRL3 1824 | FLAG_APME_IN_CTRL3
1826 | FLAG_RX_CSUM_ENABLED 1825 | FLAG_RX_CSUM_ENABLED
1827 | FLAG_HAS_SMART_POWER_DOWN 1826 | FLAG_HAS_SMART_POWER_DOWN
1828 | FLAG_HAS_AMT 1827 | FLAG_HAS_AMT
1829 | FLAG_HAS_ERT
1830 | FLAG_HAS_SWSM_ON_LOAD, 1828 | FLAG_HAS_SWSM_ON_LOAD,
1831 .pba = 20, 1829 .pba = 20,
1832 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, 1830 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 12648a1cdb78..906c4daaabe9 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -37,6 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/pci-aspm.h>
40 41
41#include "hw.h" 42#include "hw.h"
42 43
@@ -370,7 +371,7 @@ struct e1000_adapter {
370struct e1000_info { 371struct e1000_info {
371 enum e1000_mac_type mac; 372 enum e1000_mac_type mac;
372 unsigned int flags; 373 unsigned int flags;
373 unsigned int flags2; 374 unsigned int flags2;
374 u32 pba; 375 u32 pba;
375 u32 max_hw_frame_size; 376 u32 max_hw_frame_size;
376 s32 (*get_variants)(struct e1000_adapter *); 377 s32 (*get_variants)(struct e1000_adapter *);
@@ -417,6 +418,7 @@ struct e1000_info {
417#define FLAG2_CRC_STRIPPING (1 << 0) 418#define FLAG2_CRC_STRIPPING (1 << 0)
418#define FLAG2_HAS_PHY_WAKEUP (1 << 1) 419#define FLAG2_HAS_PHY_WAKEUP (1 << 1)
419#define FLAG2_IS_DISCARDING (1 << 2) 420#define FLAG2_IS_DISCARDING (1 << 2)
421#define FLAG2_DISABLE_ASPM_L1 (1 << 3)
420 422
421#define E1000_RX_DESC_PS(R, i) \ 423#define E1000_RX_DESC_PS(R, i) \
422 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) 424 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
@@ -457,6 +459,7 @@ extern void e1000e_update_stats(struct e1000_adapter *adapter);
457extern bool e1000e_has_link(struct e1000_adapter *adapter); 459extern bool e1000e_has_link(struct e1000_adapter *adapter);
458extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); 460extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
459extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); 461extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
462extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
460 463
461extern unsigned int copybreak; 464extern unsigned int copybreak;
462 465
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 5f70c437fa41..2476f8c24c54 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4310,6 +4310,14 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
4310 return -EINVAL; 4310 return -EINVAL;
4311 } 4311 }
4312 4312
4313 /* 82573 Errata 17 */
4314 if (((adapter->hw.mac.type == e1000_82573) ||
4315 (adapter->hw.mac.type == e1000_82574)) &&
4316 (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN)) {
4317 adapter->flags2 |= FLAG2_DISABLE_ASPM_L1;
4318 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L1);
4319 }
4320
4313 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 4321 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4314 msleep(1); 4322 msleep(1);
4315 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */ 4323 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
@@ -4634,29 +4642,39 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
4634 } 4642 }
4635} 4643}
4636 4644
4637static void e1000e_disable_l1aspm(struct pci_dev *pdev) 4645#ifdef CONFIG_PCIEASPM
4646static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4647{
4648 pci_disable_link_state(pdev, state);
4649}
4650#else
4651static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4638{ 4652{
4639 int pos; 4653 int pos;
4640 u16 val; 4654 u16 reg16;
4641 4655
4642 /* 4656 /*
4643 * 82573 workaround - disable L1 ASPM on mobile chipsets 4657 * Both device and parent should have the same ASPM setting.
4644 * 4658 * Disable ASPM in downstream component first and then upstream.
4645 * L1 ASPM on various mobile (ich7) chipsets do not behave properly
4646 * resulting in lost data or garbage information on the pci-e link
4647 * level. This could result in (false) bad EEPROM checksum errors,
4648 * long ping times (up to 2s) or even a system freeze/hang.
4649 *
4650 * Unfortunately this feature saves about 1W power consumption when
4651 * active.
4652 */ 4659 */
4653 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 4660 pos = pci_pcie_cap(pdev);
4654 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val); 4661 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
4655 if (val & 0x2) { 4662 reg16 &= ~state;
4656 dev_warn(&pdev->dev, "Disabling L1 ASPM\n"); 4663 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
4657 val &= ~0x2; 4664
4658 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val); 4665 pos = pci_pcie_cap(pdev->bus->self);
4659 } 4666 pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, &reg16);
4667 reg16 &= ~state;
4668 pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
4669}
4670#endif
4671void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4672{
4673 dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
4674 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
4675 (state & PCIE_LINK_STATE_L1) ? "L1" : "");
4676
4677 __e1000e_disable_aspm(pdev, state);
4660} 4678}
4661 4679
4662#ifdef CONFIG_PM_OPS 4680#ifdef CONFIG_PM_OPS
@@ -4672,7 +4690,11 @@ static int __e1000_resume(struct pci_dev *pdev)
4672 struct e1000_hw *hw = &adapter->hw; 4690 struct e1000_hw *hw = &adapter->hw;
4673 u32 err; 4691 u32 err;
4674 4692
4675 e1000e_disable_l1aspm(pdev); 4693 pci_set_power_state(pdev, PCI_D0);
4694 pci_restore_state(pdev);
4695 pci_save_state(pdev);
4696 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
4697 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4676 4698
4677 e1000e_set_interrupt_capability(adapter); 4699 e1000e_set_interrupt_capability(adapter);
4678 if (netif_running(netdev)) { 4700 if (netif_running(netdev)) {
@@ -4877,7 +4899,8 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4877 int err; 4899 int err;
4878 pci_ers_result_t result; 4900 pci_ers_result_t result;
4879 4901
4880 e1000e_disable_l1aspm(pdev); 4902 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
4903 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4881 err = pci_enable_device_mem(pdev); 4904 err = pci_enable_device_mem(pdev);
4882 if (err) { 4905 if (err) {
4883 dev_err(&pdev->dev, 4906 dev_err(&pdev->dev,
@@ -4971,13 +4994,6 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
4971 dev_warn(&adapter->pdev->dev, 4994 dev_warn(&adapter->pdev->dev,
4972 "Warning: detected DSPD enabled in EEPROM\n"); 4995 "Warning: detected DSPD enabled in EEPROM\n");
4973 } 4996 }
4974
4975 ret_val = e1000_read_nvm(hw, NVM_INIT_3GIO_3, 1, &buf);
4976 if (!ret_val && (le16_to_cpu(buf) & (3 << 2))) {
4977 /* ASPM enable */
4978 dev_warn(&adapter->pdev->dev,
4979 "Warning: detected ASPM enabled in EEPROM\n");
4980 }
4981} 4997}
4982 4998
4983static const struct net_device_ops e1000e_netdev_ops = { 4999static const struct net_device_ops e1000e_netdev_ops = {
@@ -5026,7 +5042,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5026 u16 eeprom_data = 0; 5042 u16 eeprom_data = 0;
5027 u16 eeprom_apme_mask = E1000_EEPROM_APME; 5043 u16 eeprom_apme_mask = E1000_EEPROM_APME;
5028 5044
5029 e1000e_disable_l1aspm(pdev); 5045 if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
5046 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
5030 5047
5031 err = pci_enable_device_mem(pdev); 5048 err = pci_enable_device_mem(pdev);
5032 if (err) 5049 if (err)
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index d5160edf2fcf..3acac5f930c8 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -205,8 +205,6 @@ static int fsl_pq_mdio_find_free(struct mii_bus *new_bus)
205static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) 205static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np)
206{ 206{
207 struct gfar __iomem *enet_regs; 207 struct gfar __iomem *enet_regs;
208 u32 __iomem *ioremap_tbipa;
209 u64 addr, size;
210 208
211 /* 209 /*
212 * This is mildly evil, but so is our hardware for doing this. 210 * This is mildly evil, but so is our hardware for doing this.
@@ -220,9 +218,7 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct devi
220 return &enet_regs->tbipa; 218 return &enet_regs->tbipa;
221 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || 219 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") ||
222 of_device_is_compatible(np, "fsl,etsec2-tbi")) { 220 of_device_is_compatible(np, "fsl,etsec2-tbi")) {
223 addr = of_translate_address(np, of_get_address(np, 1, &size, NULL)); 221 return of_iomap(np, 1);
224 ioremap_tbipa = ioremap(addr, size);
225 return ioremap_tbipa;
226 } else 222 } else
227 return NULL; 223 return NULL;
228} 224}
@@ -279,6 +275,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
279 u32 __iomem *tbipa; 275 u32 __iomem *tbipa;
280 struct mii_bus *new_bus; 276 struct mii_bus *new_bus;
281 int tbiaddr = -1; 277 int tbiaddr = -1;
278 const u32 *addrp;
282 u64 addr = 0, size = 0; 279 u64 addr = 0, size = 0;
283 int err = 0; 280 int err = 0;
284 281
@@ -297,8 +294,19 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
297 new_bus->priv = priv; 294 new_bus->priv = priv;
298 fsl_pq_mdio_bus_name(new_bus->id, np); 295 fsl_pq_mdio_bus_name(new_bus->id, np);
299 296
297 addrp = of_get_address(np, 0, &size, NULL);
298 if (!addrp) {
299 err = -EINVAL;
300 goto err_free_bus;
301 }
302
300 /* Set the PHY base address */ 303 /* Set the PHY base address */
301 addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); 304 addr = of_translate_address(np, addrp);
305 if (addr == OF_BAD_ADDR) {
306 err = -EINVAL;
307 goto err_free_bus;
308 }
309
302 map = ioremap(addr, size); 310 map = ioremap(addr, size);
303 if (!map) { 311 if (!map) {
304 err = -ENOMEM; 312 err = -ENOMEM;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 032073d1e3d2..0cef967499d3 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -558,12 +558,8 @@ static int gfar_parse_group(struct device_node *np,
558 struct gfar_private *priv, const char *model) 558 struct gfar_private *priv, const char *model)
559{ 559{
560 u32 *queue_mask; 560 u32 *queue_mask;
561 u64 addr, size;
562
563 addr = of_translate_address(np,
564 of_get_address(np, 0, &size, NULL));
565 priv->gfargrp[priv->num_grps].regs = ioremap(addr, size);
566 561
562 priv->gfargrp[priv->num_grps].regs = of_iomap(np, 0);
567 if (!priv->gfargrp[priv->num_grps].regs) 563 if (!priv->gfargrp[priv->num_grps].regs)
568 return -ENOMEM; 564 return -ENOMEM;
569 565
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index f894bb633040..d189ba7e8f15 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -39,6 +39,8 @@
39#define IXGBE_82599_MC_TBL_SIZE 128 39#define IXGBE_82599_MC_TBL_SIZE 128
40#define IXGBE_82599_VFT_TBL_SIZE 128 40#define IXGBE_82599_VFT_TBL_SIZE 128
41 41
42void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
43void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
42void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw); 44void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
43s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, 45s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
44 ixgbe_link_speed speed, 46 ixgbe_link_speed speed,
@@ -69,8 +71,14 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
69 if (hw->phy.multispeed_fiber) { 71 if (hw->phy.multispeed_fiber) {
70 /* Set up dual speed SFP+ support */ 72 /* Set up dual speed SFP+ support */
71 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber; 73 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
74 mac->ops.disable_tx_laser =
75 &ixgbe_disable_tx_laser_multispeed_fiber;
76 mac->ops.enable_tx_laser =
77 &ixgbe_enable_tx_laser_multispeed_fiber;
72 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber; 78 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
73 } else { 79 } else {
80 mac->ops.disable_tx_laser = NULL;
81 mac->ops.enable_tx_laser = NULL;
74 mac->ops.flap_tx_laser = NULL; 82 mac->ops.flap_tx_laser = NULL;
75 if ((mac->ops.get_media_type(hw) == 83 if ((mac->ops.get_media_type(hw) ==
76 ixgbe_media_type_backplane) && 84 ixgbe_media_type_backplane) &&
@@ -415,6 +423,44 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
415 return status; 423 return status;
416} 424}
417 425
426 /**
427 * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
428 * @hw: pointer to hardware structure
429 *
430 * The base drivers may require better control over SFP+ module
431 * PHY states. This includes selectively shutting down the Tx
432 * laser on the PHY, effectively halting physical link.
433 **/
434void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
435{
436 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
437
438 /* Disable tx laser; allow 100us to go dark per spec */
439 esdp_reg |= IXGBE_ESDP_SDP3;
440 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
441 IXGBE_WRITE_FLUSH(hw);
442 udelay(100);
443}
444
445/**
446 * ixgbe_enable_tx_laser_multispeed_fiber - Enable Tx laser
447 * @hw: pointer to hardware structure
448 *
449 * The base drivers may require better control over SFP+ module
450 * PHY states. This includes selectively turning on the Tx
451 * laser on the PHY, effectively starting physical link.
452 **/
453void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
454{
455 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
456
457 /* Enable tx laser; allow 100ms to light up */
458 esdp_reg &= ~IXGBE_ESDP_SDP3;
459 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
460 IXGBE_WRITE_FLUSH(hw);
461 msleep(100);
462}
463
418/** 464/**
419 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser 465 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
420 * @hw: pointer to hardware structure 466 * @hw: pointer to hardware structure
@@ -429,23 +475,11 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
429 **/ 475 **/
430void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) 476void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
431{ 477{
432 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
433
434 hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n"); 478 hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n");
435 479
436 if (hw->mac.autotry_restart) { 480 if (hw->mac.autotry_restart) {
437 /* Disable tx laser; allow 100us to go dark per spec */ 481 ixgbe_disable_tx_laser_multispeed_fiber(hw);
438 esdp_reg |= IXGBE_ESDP_SDP3; 482 ixgbe_enable_tx_laser_multispeed_fiber(hw);
439 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
440 IXGBE_WRITE_FLUSH(hw);
441 udelay(100);
442
443 /* Enable tx laser; allow 100ms to light up */
444 esdp_reg &= ~IXGBE_ESDP_SDP3;
445 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
446 IXGBE_WRITE_FLUSH(hw);
447 msleep(100);
448
449 hw->mac.autotry_restart = false; 483 hw->mac.autotry_restart = false;
450 } 484 }
451} 485}
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index a98ff0e76e86..32781b3f8964 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2991,6 +2991,10 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
2991 else 2991 else
2992 ixgbe_configure_msi_and_legacy(adapter); 2992 ixgbe_configure_msi_and_legacy(adapter);
2993 2993
2994 /* enable the optics */
2995 if (hw->phy.multispeed_fiber)
2996 hw->mac.ops.enable_tx_laser(hw);
2997
2994 clear_bit(__IXGBE_DOWN, &adapter->state); 2998 clear_bit(__IXGBE_DOWN, &adapter->state);
2995 ixgbe_napi_enable_all(adapter); 2999 ixgbe_napi_enable_all(adapter);
2996 3000
@@ -3252,6 +3256,10 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3252 /* signal that we are down to the interrupt handler */ 3256 /* signal that we are down to the interrupt handler */
3253 set_bit(__IXGBE_DOWN, &adapter->state); 3257 set_bit(__IXGBE_DOWN, &adapter->state);
3254 3258
3259 /* power down the optics */
3260 if (hw->phy.multispeed_fiber)
3261 hw->mac.ops.disable_tx_laser(hw);
3262
3255 /* disable receive for all VFs and wait one second */ 3263 /* disable receive for all VFs and wait one second */
3256 if (adapter->num_vfs) { 3264 if (adapter->num_vfs) {
3257 /* ping all the active vfs to let them know we are going down */ 3265 /* ping all the active vfs to let them know we are going down */
@@ -6262,6 +6270,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6262 goto err_eeprom; 6270 goto err_eeprom;
6263 } 6271 }
6264 6272
6273 /* power down the optics */
6274 if (hw->phy.multispeed_fiber)
6275 hw->mac.ops.disable_tx_laser(hw);
6276
6265 init_timer(&adapter->watchdog_timer); 6277 init_timer(&adapter->watchdog_timer);
6266 adapter->watchdog_timer.function = &ixgbe_watchdog; 6278 adapter->watchdog_timer.function = &ixgbe_watchdog;
6267 adapter->watchdog_timer.data = (unsigned long)adapter; 6279 adapter->watchdog_timer.data = (unsigned long)adapter;
@@ -6409,16 +6421,6 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
6409 del_timer_sync(&adapter->sfp_timer); 6421 del_timer_sync(&adapter->sfp_timer);
6410 cancel_work_sync(&adapter->watchdog_task); 6422 cancel_work_sync(&adapter->watchdog_task);
6411 cancel_work_sync(&adapter->sfp_task); 6423 cancel_work_sync(&adapter->sfp_task);
6412 if (adapter->hw.phy.multispeed_fiber) {
6413 struct ixgbe_hw *hw = &adapter->hw;
6414 /*
6415 * Restart clause 37 autoneg, disable and re-enable
6416 * the tx laser, to clear & alert the link partner
6417 * that it needs to restart autotry
6418 */
6419 hw->mac.autotry_restart = true;
6420 hw->mac.ops.flap_tx_laser(hw);
6421 }
6422 cancel_work_sync(&adapter->multispeed_fiber_task); 6424 cancel_work_sync(&adapter->multispeed_fiber_task);
6423 cancel_work_sync(&adapter->sfp_config_module_task); 6425 cancel_work_sync(&adapter->sfp_config_module_task);
6424 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || 6426 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE ||
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index aed4ed665648..a0f9084c81cd 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -2398,6 +2398,8 @@ struct ixgbe_mac_operations {
2398 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); 2398 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);
2399 2399
2400 /* Link */ 2400 /* Link */
2401 void (*disable_tx_laser)(struct ixgbe_hw *);
2402 void (*enable_tx_laser)(struct ixgbe_hw *);
2401 void (*flap_tx_laser)(struct ixgbe_hw *); 2403 void (*flap_tx_laser)(struct ixgbe_hw *);
2402 s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool); 2404 s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
2403 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool); 2405 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index 4dcd61f81ec2..b8ed1ee37ac1 100644
--- a/drivers/net/ks8851.c
+++ b/drivers/net/ks8851.c
@@ -717,12 +717,14 @@ static void ks8851_tx_work(struct work_struct *work)
717 txb = skb_dequeue(&ks->txq); 717 txb = skb_dequeue(&ks->txq);
718 last = skb_queue_empty(&ks->txq); 718 last = skb_queue_empty(&ks->txq);
719 719
720 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); 720 if (txb != NULL) {
721 ks8851_wrpkt(ks, txb, last); 721 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
722 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); 722 ks8851_wrpkt(ks, txb, last);
723 ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE); 723 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
724 ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE);
724 725
725 ks8851_done_tx(ks, txb); 726 ks8851_done_tx(ks, txb);
727 }
726 } 728 }
727 729
728 mutex_unlock(&ks->lock); 730 mutex_unlock(&ks->lock);
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 3d1d3a7b7ed3..757f87bb1db3 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -781,8 +781,13 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
781 inw(ioaddr + EL3_STATUS)); 781 inw(ioaddr + EL3_STATUS));
782 782
783 spin_lock_irqsave(&lp->window_lock, flags); 783 spin_lock_irqsave(&lp->window_lock, flags);
784
785 dev->stats.tx_bytes += skb->len;
786
787 /* Put out the doubleword header... */
784 outw(skb->len, ioaddr + TX_FIFO); 788 outw(skb->len, ioaddr + TX_FIFO);
785 outw(0, ioaddr + TX_FIFO); 789 outw(0, ioaddr + TX_FIFO);
790 /* ... and the packet rounded to a doubleword. */
786 outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2); 791 outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2);
787 792
788 dev->trans_start = jiffies; 793 dev->trans_start = jiffies;
@@ -1021,8 +1026,6 @@ static void update_stats(struct net_device *dev)
1021 /* BadSSD */ inb(ioaddr + 12); 1026 /* BadSSD */ inb(ioaddr + 12);
1022 up = inb(ioaddr + 13); 1027 up = inb(ioaddr + 13);
1023 1028
1024 dev->stats.tx_bytes += tx + ((up & 0xf0) << 12);
1025
1026 EL3WINDOW(1); 1029 EL3WINDOW(1);
1027} 1030}
1028 1031
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 340da3915b96..217e709bda3e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -2775,6 +2775,7 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
2775{ 2775{
2776 iounmap(ioaddr); 2776 iounmap(ioaddr);
2777 pci_release_regions(pdev); 2777 pci_release_regions(pdev);
2778 pci_clear_mwi(pdev);
2778 pci_disable_device(pdev); 2779 pci_disable_device(pdev);
2779 free_netdev(dev); 2780 free_netdev(dev);
2780} 2781}
@@ -2841,8 +2842,13 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
2841 spin_lock_irq(&tp->lock); 2842 spin_lock_irq(&tp->lock);
2842 2843
2843 RTL_W8(Cfg9346, Cfg9346_Unlock); 2844 RTL_W8(Cfg9346, Cfg9346_Unlock);
2845
2844 RTL_W32(MAC4, high); 2846 RTL_W32(MAC4, high);
2847 RTL_R32(MAC4);
2848
2845 RTL_W32(MAC0, low); 2849 RTL_W32(MAC0, low);
2850 RTL_R32(MAC0);
2851
2846 RTL_W8(Cfg9346, Cfg9346_Lock); 2852 RTL_W8(Cfg9346, Cfg9346_Lock);
2847 2853
2848 spin_unlock_irq(&tp->lock); 2854 spin_unlock_irq(&tp->lock);
@@ -3030,9 +3036,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3030 goto err_out_free_dev_1; 3036 goto err_out_free_dev_1;
3031 } 3037 }
3032 3038
3033 rc = pci_set_mwi(pdev); 3039 if (pci_set_mwi(pdev) < 0)
3034 if (rc < 0) 3040 netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n");
3035 goto err_out_disable_2;
3036 3041
3037 /* make sure PCI base addr 1 is MMIO */ 3042 /* make sure PCI base addr 1 is MMIO */
3038 if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { 3043 if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) {
@@ -3040,7 +3045,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3040 "region #%d not an MMIO resource, aborting\n", 3045 "region #%d not an MMIO resource, aborting\n",
3041 region); 3046 region);
3042 rc = -ENODEV; 3047 rc = -ENODEV;
3043 goto err_out_mwi_3; 3048 goto err_out_mwi_2;
3044 } 3049 }
3045 3050
3046 /* check for weird/broken PCI region reporting */ 3051 /* check for weird/broken PCI region reporting */
@@ -3048,13 +3053,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3048 netif_err(tp, probe, dev, 3053 netif_err(tp, probe, dev,
3049 "Invalid PCI region size(s), aborting\n"); 3054 "Invalid PCI region size(s), aborting\n");
3050 rc = -ENODEV; 3055 rc = -ENODEV;
3051 goto err_out_mwi_3; 3056 goto err_out_mwi_2;
3052 } 3057 }
3053 3058
3054 rc = pci_request_regions(pdev, MODULENAME); 3059 rc = pci_request_regions(pdev, MODULENAME);
3055 if (rc < 0) { 3060 if (rc < 0) {
3056 netif_err(tp, probe, dev, "could not request regions\n"); 3061 netif_err(tp, probe, dev, "could not request regions\n");
3057 goto err_out_mwi_3; 3062 goto err_out_mwi_2;
3058 } 3063 }
3059 3064
3060 tp->cp_cmd = PCIMulRW | RxChkSum; 3065 tp->cp_cmd = PCIMulRW | RxChkSum;
@@ -3067,7 +3072,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3067 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 3072 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
3068 if (rc < 0) { 3073 if (rc < 0) {
3069 netif_err(tp, probe, dev, "DMA configuration failed\n"); 3074 netif_err(tp, probe, dev, "DMA configuration failed\n");
3070 goto err_out_free_res_4; 3075 goto err_out_free_res_3;
3071 } 3076 }
3072 } 3077 }
3073 3078
@@ -3076,7 +3081,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3076 if (!ioaddr) { 3081 if (!ioaddr) {
3077 netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); 3082 netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n");
3078 rc = -EIO; 3083 rc = -EIO;
3079 goto err_out_free_res_4; 3084 goto err_out_free_res_3;
3080 } 3085 }
3081 3086
3082 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); 3087 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
@@ -3118,7 +3123,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3118 if (i == ARRAY_SIZE(rtl_chip_info)) { 3123 if (i == ARRAY_SIZE(rtl_chip_info)) {
3119 dev_err(&pdev->dev, 3124 dev_err(&pdev->dev,
3120 "driver bug, MAC version not found in rtl_chip_info\n"); 3125 "driver bug, MAC version not found in rtl_chip_info\n");
3121 goto err_out_msi_5; 3126 goto err_out_msi_4;
3122 } 3127 }
3123 tp->chipset = i; 3128 tp->chipset = i;
3124 3129
@@ -3183,7 +3188,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3183 3188
3184 rc = register_netdev(dev); 3189 rc = register_netdev(dev);
3185 if (rc < 0) 3190 if (rc < 0)
3186 goto err_out_msi_5; 3191 goto err_out_msi_4;
3187 3192
3188 pci_set_drvdata(pdev, dev); 3193 pci_set_drvdata(pdev, dev);
3189 3194
@@ -3212,14 +3217,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3212out: 3217out:
3213 return rc; 3218 return rc;
3214 3219
3215err_out_msi_5: 3220err_out_msi_4:
3216 rtl_disable_msi(pdev, tp); 3221 rtl_disable_msi(pdev, tp);
3217 iounmap(ioaddr); 3222 iounmap(ioaddr);
3218err_out_free_res_4: 3223err_out_free_res_3:
3219 pci_release_regions(pdev); 3224 pci_release_regions(pdev);
3220err_out_mwi_3: 3225err_out_mwi_2:
3221 pci_clear_mwi(pdev); 3226 pci_clear_mwi(pdev);
3222err_out_disable_2:
3223 pci_disable_device(pdev); 3227 pci_disable_device(pdev);
3224err_out_free_dev_1: 3228err_out_free_dev_1:
3225 free_netdev(dev); 3229 free_netdev(dev);
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7724d7e4ebd6..573054ae7b58 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -8700,6 +8700,7 @@ static int tg3_test_msi(struct tg3 *tp)
8700 pci_disable_msi(tp->pdev); 8700 pci_disable_msi(tp->pdev);
8701 8701
8702 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; 8702 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
8703 tp->napi[0].irq_vec = tp->pdev->irq;
8703 8704
8704 err = tg3_request_irq(tp, 0); 8705 err = tg3_request_irq(tp, 0);
8705 if (err) 8706 if (err)
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ba56ce4382d9..63be4caec70e 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -385,4 +385,16 @@ config USB_CDC_PHONET
385 cellular modem, as found on most Nokia handsets with the 385 cellular modem, as found on most Nokia handsets with the
386 "PC suite" USB profile. 386 "PC suite" USB profile.
387 387
388config USB_IPHETH
389 tristate "Apple iPhone USB Ethernet driver"
390 default n
391 ---help---
392 Module used to share Internet connection (tethering) from your
393 iPhone (Original, 3G and 3GS) to your system.
394 Note that you need userspace libraries and programs that are needed
395 to pair your device with your system and that understand the iPhone
396 protocol.
397
398 For more information: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver
399
388endmenu 400endmenu
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 82ea62955b56..edb09c0ddf8e 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -23,4 +23,5 @@ obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
23obj-$(CONFIG_USB_USBNET) += usbnet.o 23obj-$(CONFIG_USB_USBNET) += usbnet.o
24obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o 24obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o
25obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o 25obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o
26obj-$(CONFIG_USB_IPHETH) += ipheth.o
26 27
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
new file mode 100644
index 000000000000..fd1033130a81
--- /dev/null
+++ b/drivers/net/usb/ipheth.c
@@ -0,0 +1,568 @@
1/*
2 * ipheth.c - Apple iPhone USB Ethernet driver
3 *
4 * Copyright (c) 2009 Diego Giagio <diego@giagio.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of GIAGIO.COM nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * Alternatively, provided that this notice is retained in full, this
20 * software may be distributed under the terms of the GNU General
21 * Public License ("GPL") version 2, in which case the provisions of the
22 * GPL apply INSTEAD OF those given above.
23 *
24 * The provided data structures and external interfaces from this code
25 * are not restricted to be used by modules with a GPL compatible license.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38 * DAMAGE.
39 *
40 *
41 * Attention: iPhone device must be paired, otherwise it won't respond to our
42 * driver. For more info: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver
43 *
44 */
45
46#include <linux/kernel.h>
47#include <linux/errno.h>
48#include <linux/init.h>
49#include <linux/slab.h>
50#include <linux/module.h>
51#include <linux/netdevice.h>
52#include <linux/etherdevice.h>
53#include <linux/ethtool.h>
54#include <linux/usb.h>
55#include <linux/workqueue.h>
56
57#define USB_VENDOR_APPLE 0x05ac
58#define USB_PRODUCT_IPHONE 0x1290
59#define USB_PRODUCT_IPHONE_3G 0x1292
60#define USB_PRODUCT_IPHONE_3GS 0x1294
61
62#define IPHETH_USBINTF_CLASS 255
63#define IPHETH_USBINTF_SUBCLASS 253
64#define IPHETH_USBINTF_PROTO 1
65
66#define IPHETH_BUF_SIZE 1516
67#define IPHETH_TX_TIMEOUT (5 * HZ)
68
69#define IPHETH_INTFNUM 2
70#define IPHETH_ALT_INTFNUM 1
71
72#define IPHETH_CTRL_ENDP 0x00
73#define IPHETH_CTRL_BUF_SIZE 0x40
74#define IPHETH_CTRL_TIMEOUT (5 * HZ)
75
76#define IPHETH_CMD_GET_MACADDR 0x00
77#define IPHETH_CMD_CARRIER_CHECK 0x45
78
79#define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ)
80#define IPHETH_CARRIER_ON 0x04
81
82static struct usb_device_id ipheth_table[] = {
83 { USB_DEVICE_AND_INTERFACE_INFO(
84 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE,
85 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
86 IPHETH_USBINTF_PROTO) },
87 { USB_DEVICE_AND_INTERFACE_INFO(
88 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G,
89 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
90 IPHETH_USBINTF_PROTO) },
91 { USB_DEVICE_AND_INTERFACE_INFO(
92 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS,
93 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
94 IPHETH_USBINTF_PROTO) },
95 { }
96};
97MODULE_DEVICE_TABLE(usb, ipheth_table);
98
99struct ipheth_device {
100 struct usb_device *udev;
101 struct usb_interface *intf;
102 struct net_device *net;
103 struct sk_buff *tx_skb;
104 struct urb *tx_urb;
105 struct urb *rx_urb;
106 unsigned char *tx_buf;
107 unsigned char *rx_buf;
108 unsigned char *ctrl_buf;
109 u8 bulk_in;
110 u8 bulk_out;
111 struct delayed_work carrier_work;
112};
113
114static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags);
115
116static int ipheth_alloc_urbs(struct ipheth_device *iphone)
117{
118 struct urb *tx_urb = NULL;
119 struct urb *rx_urb = NULL;
120 u8 *tx_buf = NULL;
121 u8 *rx_buf = NULL;
122
123 tx_urb = usb_alloc_urb(0, GFP_KERNEL);
124 if (tx_urb == NULL)
125 goto error;
126
127 rx_urb = usb_alloc_urb(0, GFP_KERNEL);
128 if (rx_urb == NULL)
129 goto error;
130
131 tx_buf = usb_buffer_alloc(iphone->udev,
132 IPHETH_BUF_SIZE,
133 GFP_KERNEL,
134 &tx_urb->transfer_dma);
135 if (tx_buf == NULL)
136 goto error;
137
138 rx_buf = usb_buffer_alloc(iphone->udev,
139 IPHETH_BUF_SIZE,
140 GFP_KERNEL,
141 &rx_urb->transfer_dma);
142 if (rx_buf == NULL)
143 goto error;
144
145
146 iphone->tx_urb = tx_urb;
147 iphone->rx_urb = rx_urb;
148 iphone->tx_buf = tx_buf;
149 iphone->rx_buf = rx_buf;
150 return 0;
151
152error:
153 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, rx_buf,
154 rx_urb->transfer_dma);
155 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf,
156 tx_urb->transfer_dma);
157 usb_free_urb(rx_urb);
158 usb_free_urb(tx_urb);
159 return -ENOMEM;
160}
161
162static void ipheth_free_urbs(struct ipheth_device *iphone)
163{
164 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf,
165 iphone->rx_urb->transfer_dma);
166 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->tx_buf,
167 iphone->tx_urb->transfer_dma);
168 usb_free_urb(iphone->rx_urb);
169 usb_free_urb(iphone->tx_urb);
170}
171
172static void ipheth_kill_urbs(struct ipheth_device *dev)
173{
174 usb_kill_urb(dev->tx_urb);
175 usb_kill_urb(dev->rx_urb);
176}
177
178static void ipheth_rcvbulk_callback(struct urb *urb)
179{
180 struct ipheth_device *dev;
181 struct sk_buff *skb;
182 int status;
183 char *buf;
184 int len;
185
186 dev = urb->context;
187 if (dev == NULL)
188 return;
189
190 status = urb->status;
191 switch (status) {
192 case -ENOENT:
193 case -ECONNRESET:
194 case -ESHUTDOWN:
195 return;
196 case 0:
197 break;
198 default:
199 err("%s: urb status: %d", __func__, urb->status);
200 return;
201 }
202
203 len = urb->actual_length;
204 buf = urb->transfer_buffer;
205
206 skb = dev_alloc_skb(NET_IP_ALIGN + len);
207 if (!skb) {
208 err("%s: dev_alloc_skb: -ENOMEM", __func__);
209 dev->net->stats.rx_dropped++;
210 return;
211 }
212
213 skb_reserve(skb, NET_IP_ALIGN);
214 memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN);
215 skb->dev = dev->net;
216 skb->protocol = eth_type_trans(skb, dev->net);
217
218 dev->net->stats.rx_packets++;
219 dev->net->stats.rx_bytes += len;
220
221 netif_rx(skb);
222 ipheth_rx_submit(dev, GFP_ATOMIC);
223}
224
225static void ipheth_sndbulk_callback(struct urb *urb)
226{
227 struct ipheth_device *dev;
228
229 dev = urb->context;
230 if (dev == NULL)
231 return;
232
233 if (urb->status != 0 &&
234 urb->status != -ENOENT &&
235 urb->status != -ECONNRESET &&
236 urb->status != -ESHUTDOWN)
237 err("%s: urb status: %d", __func__, urb->status);
238
239 dev_kfree_skb_irq(dev->tx_skb);
240 netif_wake_queue(dev->net);
241}
242
243static int ipheth_carrier_set(struct ipheth_device *dev)
244{
245 struct usb_device *udev = dev->udev;
246 int retval;
247
248 retval = usb_control_msg(udev,
249 usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
250 IPHETH_CMD_CARRIER_CHECK, /* request */
251 0xc0, /* request type */
252 0x00, /* value */
253 0x02, /* index */
254 dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE,
255 IPHETH_CTRL_TIMEOUT);
256 if (retval < 0) {
257 err("%s: usb_control_msg: %d", __func__, retval);
258 return retval;
259 }
260
261 if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON)
262 netif_carrier_on(dev->net);
263 else
264 netif_carrier_off(dev->net);
265
266 return 0;
267}
268
269static void ipheth_carrier_check_work(struct work_struct *work)
270{
271 struct ipheth_device *dev = container_of(work, struct ipheth_device,
272 carrier_work.work);
273
274 ipheth_carrier_set(dev);
275 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
276}
277
278static int ipheth_get_macaddr(struct ipheth_device *dev)
279{
280 struct usb_device *udev = dev->udev;
281 struct net_device *net = dev->net;
282 int retval;
283
284 retval = usb_control_msg(udev,
285 usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
286 IPHETH_CMD_GET_MACADDR, /* request */
287 0xc0, /* request type */
288 0x00, /* value */
289 0x02, /* index */
290 dev->ctrl_buf,
291 IPHETH_CTRL_BUF_SIZE,
292 IPHETH_CTRL_TIMEOUT);
293 if (retval < 0) {
294 err("%s: usb_control_msg: %d", __func__, retval);
295 } else if (retval < ETH_ALEN) {
296 err("%s: usb_control_msg: short packet: %d bytes",
297 __func__, retval);
298 retval = -EINVAL;
299 } else {
300 memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN);
301 retval = 0;
302 }
303
304 return retval;
305}
306
307static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags)
308{
309 struct usb_device *udev = dev->udev;
310 int retval;
311
312 usb_fill_bulk_urb(dev->rx_urb, udev,
313 usb_rcvbulkpipe(udev, dev->bulk_in),
314 dev->rx_buf, IPHETH_BUF_SIZE,
315 ipheth_rcvbulk_callback,
316 dev);
317 dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
318
319 retval = usb_submit_urb(dev->rx_urb, mem_flags);
320 if (retval)
321 err("%s: usb_submit_urb: %d", __func__, retval);
322 return retval;
323}
324
325static int ipheth_open(struct net_device *net)
326{
327 struct ipheth_device *dev = netdev_priv(net);
328 struct usb_device *udev = dev->udev;
329 int retval = 0;
330
331 usb_set_interface(udev, IPHETH_INTFNUM, IPHETH_ALT_INTFNUM);
332
333 retval = ipheth_carrier_set(dev);
334 if (retval)
335 return retval;
336
337 retval = ipheth_rx_submit(dev, GFP_KERNEL);
338 if (retval)
339 return retval;
340
341 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
342 netif_start_queue(net);
343 return retval;
344}
345
346static int ipheth_close(struct net_device *net)
347{
348 struct ipheth_device *dev = netdev_priv(net);
349
350 cancel_delayed_work_sync(&dev->carrier_work);
351 netif_stop_queue(net);
352 return 0;
353}
354
355static int ipheth_tx(struct sk_buff *skb, struct net_device *net)
356{
357 struct ipheth_device *dev = netdev_priv(net);
358 struct usb_device *udev = dev->udev;
359 int retval;
360
361 /* Paranoid */
362 if (skb->len > IPHETH_BUF_SIZE) {
363 WARN(1, "%s: skb too large: %d bytes", __func__, skb->len);
364 dev->net->stats.tx_dropped++;
365 dev_kfree_skb_irq(skb);
366 return NETDEV_TX_OK;
367 }
368
369 memcpy(dev->tx_buf, skb->data, skb->len);
370 if (skb->len < IPHETH_BUF_SIZE)
371 memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len);
372
373 usb_fill_bulk_urb(dev->tx_urb, udev,
374 usb_sndbulkpipe(udev, dev->bulk_out),
375 dev->tx_buf, IPHETH_BUF_SIZE,
376 ipheth_sndbulk_callback,
377 dev);
378 dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
379
380 retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC);
381 if (retval) {
382 err("%s: usb_submit_urb: %d", __func__, retval);
383 dev->net->stats.tx_errors++;
384 dev_kfree_skb_irq(skb);
385 } else {
386 dev->tx_skb = skb;
387
388 dev->net->stats.tx_packets++;
389 dev->net->stats.tx_bytes += skb->len;
390 netif_stop_queue(net);
391 }
392
393 return NETDEV_TX_OK;
394}
395
396static void ipheth_tx_timeout(struct net_device *net)
397{
398 struct ipheth_device *dev = netdev_priv(net);
399
400 err("%s: TX timeout", __func__);
401 dev->net->stats.tx_errors++;
402 usb_unlink_urb(dev->tx_urb);
403}
404
405static struct net_device_stats *ipheth_stats(struct net_device *net)
406{
407 struct ipheth_device *dev = netdev_priv(net);
408 return &dev->net->stats;
409}
410
411static u32 ipheth_ethtool_op_get_link(struct net_device *net)
412{
413 struct ipheth_device *dev = netdev_priv(net);
414 return netif_carrier_ok(dev->net);
415}
416
417static struct ethtool_ops ops = {
418 .get_link = ipheth_ethtool_op_get_link
419};
420
421static const struct net_device_ops ipheth_netdev_ops = {
422 .ndo_open = &ipheth_open,
423 .ndo_stop = &ipheth_close,
424 .ndo_start_xmit = &ipheth_tx,
425 .ndo_tx_timeout = &ipheth_tx_timeout,
426 .ndo_get_stats = &ipheth_stats,
427};
428
429static struct device_type ipheth_type = {
430 .name = "wwan",
431};
432
433static int ipheth_probe(struct usb_interface *intf,
434 const struct usb_device_id *id)
435{
436 struct usb_device *udev = interface_to_usbdev(intf);
437 struct usb_host_interface *hintf;
438 struct usb_endpoint_descriptor *endp;
439 struct ipheth_device *dev;
440 struct net_device *netdev;
441 int i;
442 int retval;
443
444 netdev = alloc_etherdev(sizeof(struct ipheth_device));
445 if (!netdev)
446 return -ENOMEM;
447
448 netdev->netdev_ops = &ipheth_netdev_ops;
449 netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;
450 strcpy(netdev->name, "wwan%d");
451
452 dev = netdev_priv(netdev);
453 dev->udev = udev;
454 dev->net = netdev;
455 dev->intf = intf;
456
457 /* Set up endpoints */
458 hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM);
459 if (hintf == NULL) {
460 retval = -ENODEV;
461 err("Unable to find alternate settings interface");
462 goto err_endpoints;
463 }
464
465 for (i = 0; i < hintf->desc.bNumEndpoints; i++) {
466 endp = &hintf->endpoint[i].desc;
467 if (usb_endpoint_is_bulk_in(endp))
468 dev->bulk_in = endp->bEndpointAddress;
469 else if (usb_endpoint_is_bulk_out(endp))
470 dev->bulk_out = endp->bEndpointAddress;
471 }
472 if (!(dev->bulk_in && dev->bulk_out)) {
473 retval = -ENODEV;
474 err("Unable to find endpoints");
475 goto err_endpoints;
476 }
477
478 dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);
479 if (dev->ctrl_buf == NULL) {
480 retval = -ENOMEM;
481 goto err_alloc_ctrl_buf;
482 }
483
484 retval = ipheth_get_macaddr(dev);
485 if (retval)
486 goto err_get_macaddr;
487
488 INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work);
489
490 retval = ipheth_alloc_urbs(dev);
491 if (retval) {
492 err("error allocating urbs: %d", retval);
493 goto err_alloc_urbs;
494 }
495
496 usb_set_intfdata(intf, dev);
497
498 SET_NETDEV_DEV(netdev, &intf->dev);
499 SET_ETHTOOL_OPS(netdev, &ops);
500 SET_NETDEV_DEVTYPE(netdev, &ipheth_type);
501
502 retval = register_netdev(netdev);
503 if (retval) {
504 err("error registering netdev: %d", retval);
505 retval = -EIO;
506 goto err_register_netdev;
507 }
508
509 dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n");
510 return 0;
511
512err_register_netdev:
513 ipheth_free_urbs(dev);
514err_alloc_urbs:
515err_get_macaddr:
516err_alloc_ctrl_buf:
517 kfree(dev->ctrl_buf);
518err_endpoints:
519 free_netdev(netdev);
520 return retval;
521}
522
523static void ipheth_disconnect(struct usb_interface *intf)
524{
525 struct ipheth_device *dev;
526
527 dev = usb_get_intfdata(intf);
528 if (dev != NULL) {
529 unregister_netdev(dev->net);
530 ipheth_kill_urbs(dev);
531 ipheth_free_urbs(dev);
532 kfree(dev->ctrl_buf);
533 free_netdev(dev->net);
534 }
535 usb_set_intfdata(intf, NULL);
536 dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n");
537}
538
539static struct usb_driver ipheth_driver = {
540 .name = "ipheth",
541 .probe = ipheth_probe,
542 .disconnect = ipheth_disconnect,
543 .id_table = ipheth_table,
544};
545
546static int __init ipheth_init(void)
547{
548 int retval;
549
550 retval = usb_register(&ipheth_driver);
551 if (retval) {
552 err("usb_register failed: %d", retval);
553 return retval;
554 }
555 return 0;
556}
557
558static void __exit ipheth_exit(void)
559{
560 usb_deregister(&ipheth_driver);
561}
562
563module_init(ipheth_init);
564module_exit(ipheth_exit);
565
566MODULE_AUTHOR("Diego Giagio <diego@giagio.com>");
567MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver");
568MODULE_LICENSE("Dual BSD/GPL");