aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2010-06-16 12:08:13 -0400
committerJiri Kosina <jkosina@suse.cz>2010-06-16 12:08:13 -0400
commitf1bbbb6912662b9f6070c5bfc4ca9eb1f06a9d5b (patch)
treec2c130a74be25b0b2dff992e1a195e2728bdaadd /drivers/net
parentfd0961ff67727482bb20ca7e8ea97b83e9de2ddb (diff)
parent7e27d6e778cd87b6f2415515d7127eba53fe5d02 (diff)
Merge branch 'master' into for-next
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/3c507.c3
-rw-r--r--drivers/net/8139cp.c2
-rw-r--r--drivers/net/8139too.c3
-rw-r--r--drivers/net/benet/be.h2
-rw-r--r--drivers/net/benet/be_cmds.c32
-rw-r--r--drivers/net/benet/be_main.c13
-rw-r--r--drivers/net/bfin_mac.c2
-rw-r--r--drivers/net/bmac.c7
-rw-r--r--drivers/net/bnx2.c14
-rw-r--r--drivers/net/can/Kconfig10
-rw-r--r--drivers/net/can/Makefile1
-rw-r--r--drivers/net/can/janz-ican3.c1830
-rw-r--r--drivers/net/can/mscan/mpc5xxx_can.c18
-rw-r--r--drivers/net/can/sja1000/sja1000.c2
-rw-r--r--drivers/net/can/sja1000/sja1000_of_platform.c12
-rw-r--r--drivers/net/cnic.c10
-rw-r--r--drivers/net/cnic_if.h4
-rw-r--r--drivers/net/e1000e/netdev.c2
-rw-r--r--drivers/net/ehea/ehea_main.c21
-rw-r--r--drivers/net/enic/enic.h7
-rw-r--r--drivers/net/enic/enic_main.c197
-rw-r--r--drivers/net/epic100.c7
-rw-r--r--drivers/net/ethoc.c34
-rw-r--r--drivers/net/fec.c66
-rw-r--r--drivers/net/fec.h2
-rw-r--r--drivers/net/fec_mpc52xx.c20
-rw-r--r--drivers/net/fec_mpc52xx_phy.c11
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c15
-rw-r--r--drivers/net/fs_enet/mac-fcc.c57
-rw-r--r--drivers/net/fs_enet/mac-fec.c4
-rw-r--r--drivers/net/fs_enet/mac-scc.c6
-rw-r--r--drivers/net/fs_enet/mii-bitbang.c11
-rw-r--r--drivers/net/fs_enet/mii-fec.c13
-rw-r--r--drivers/net/fsl_pq_mdio.c9
-rw-r--r--drivers/net/gianfar.c19
-rw-r--r--drivers/net/greth.c14
-rw-r--r--drivers/net/hamradio/yam.c3
-rw-r--r--drivers/net/ibm_newemac/core.c21
-rw-r--r--drivers/net/ibm_newemac/debug.c9
-rw-r--r--drivers/net/ibm_newemac/debug.h4
-rw-r--r--drivers/net/ibm_newemac/mal.c36
-rw-r--r--drivers/net/ibm_newemac/rgmii.c20
-rw-r--r--drivers/net/ibm_newemac/tah.c15
-rw-r--r--drivers/net/ibm_newemac/zmii.c17
-rw-r--r--drivers/net/irda/bfin_sir.c8
-rw-r--r--drivers/net/ixgbe/ixgbe.h3
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c1
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c1
-rw-r--r--drivers/net/ixgbe/ixgbe_common.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c71
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.c30
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.h3
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h5
-rw-r--r--drivers/net/korina.c32
-rw-r--r--drivers/net/ksz884x.c3
-rw-r--r--drivers/net/ll_temac.h5
-rw-r--r--drivers/net/ll_temac_main.c96
-rw-r--r--drivers/net/mace.c7
-rw-r--r--drivers/net/macvlan.c9
-rw-r--r--drivers/net/mlx4/icm.c36
-rw-r--r--drivers/net/myri_sbus.c9
-rw-r--r--drivers/net/niu.c17
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c1
-rw-r--r--drivers/net/phy/lxt.c51
-rw-r--r--drivers/net/phy/mdio-gpio.c13
-rw-r--r--drivers/net/ppp_generic.c6
-rw-r--r--drivers/net/pppoe.c1
-rw-r--r--drivers/net/r8169.c11
-rw-r--r--drivers/net/sfc/net_driver.h2
-rw-r--r--drivers/net/sfc/siena.c4
-rw-r--r--drivers/net/sh_eth.c3
-rw-r--r--drivers/net/sunbmac.c13
-rw-r--r--drivers/net/sunhme.c15
-rw-r--r--drivers/net/sunlance.c13
-rw-r--r--drivers/net/sunqe.c13
-rw-r--r--drivers/net/tehuti.c4
-rw-r--r--drivers/net/tun.c3
-rw-r--r--drivers/net/ucc_geth.c9
-rw-r--r--drivers/net/usb/asix.c6
-rw-r--r--drivers/net/usb/hso.c3
-rw-r--r--drivers/net/virtio_net.c48
-rw-r--r--drivers/net/wan/x25_asy.c2
-rw-r--r--drivers/net/wimax/i2400m/fw.c2
-rw-r--r--drivers/net/wimax/i2400m/rx.c4
-rw-r--r--drivers/net/wireless/airo.c15
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c14
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c36
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c75
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c28
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c17
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c6
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ict.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c30
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c318
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c39
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c21
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c56
-rw-r--r--drivers/net/wireless/libertas/rx.c5
-rw-r--r--drivers/net/wireless/orinoco/airport.c7
-rw-r--r--drivers/net/wireless/p54/p54usb.c1
-rw-r--r--drivers/net/wireless/rndis_wlan.c16
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c7
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_sdio.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_rx.c2
-rw-r--r--drivers/net/xilinx_emaclite.c17
118 files changed, 3135 insertions, 809 deletions
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c
index 82eaf65d2d85..ea9b7a098c9b 100644
--- a/drivers/net/3c507.c
+++ b/drivers/net/3c507.c
@@ -551,8 +551,7 @@ static irqreturn_t el16_interrupt(int irq, void *dev_id)
551 void __iomem *shmem; 551 void __iomem *shmem;
552 552
553 if (dev == NULL) { 553 if (dev == NULL) {
554 pr_err("%s: net_interrupt(): irq %d for unknown device.\n", 554 pr_err("net_interrupt(): irq %d for unknown device.\n", irq);
555 dev->name, irq);
556 return IRQ_NONE; 555 return IRQ_NONE;
557 } 556 }
558 557
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 9c149750e2bf..284a5f4a63ac 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -598,8 +598,8 @@ rx_next:
598 goto rx_status_loop; 598 goto rx_status_loop;
599 599
600 spin_lock_irqsave(&cp->lock, flags); 600 spin_lock_irqsave(&cp->lock, flags);
601 cpw16_f(IntrMask, cp_intr_mask);
602 __napi_complete(napi); 601 __napi_complete(napi);
602 cpw16_f(IntrMask, cp_intr_mask);
603 spin_unlock_irqrestore(&cp->lock, flags); 603 spin_unlock_irqrestore(&cp->lock, flags);
604 } 604 }
605 605
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 4ba72933f0da..97d8068b372b 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -860,6 +860,7 @@ retry:
860 } 860 }
861 861
862 /* if unknown chip, assume array element #0, original RTL-8139 in this case */ 862 /* if unknown chip, assume array element #0, original RTL-8139 in this case */
863 i = 0;
863 dev_dbg(&pdev->dev, "unknown chip version, assuming RTL-8139\n"); 864 dev_dbg(&pdev->dev, "unknown chip version, assuming RTL-8139\n");
864 dev_dbg(&pdev->dev, "TxConfig = 0x%lx\n", RTL_R32 (TxConfig)); 865 dev_dbg(&pdev->dev, "TxConfig = 0x%lx\n", RTL_R32 (TxConfig));
865 tp->chipset = 0; 866 tp->chipset = 0;
@@ -2088,8 +2089,8 @@ static int rtl8139_poll(struct napi_struct *napi, int budget)
2088 * again when we think we are done. 2089 * again when we think we are done.
2089 */ 2090 */
2090 spin_lock_irqsave(&tp->lock, flags); 2091 spin_lock_irqsave(&tp->lock, flags);
2091 RTL_W16_F(IntrMask, rtl8139_intr_mask);
2092 __napi_complete(napi); 2092 __napi_complete(napi);
2093 RTL_W16_F(IntrMask, rtl8139_intr_mask);
2093 spin_unlock_irqrestore(&tp->lock, flags); 2094 spin_unlock_irqrestore(&tp->lock, flags);
2094 } 2095 }
2095 spin_unlock(&tp->rx_lock); 2096 spin_unlock(&tp->rx_lock);
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index 373c1a563474..b46be490cd2a 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -283,6 +283,8 @@ struct be_adapter {
283 u8 port_type; 283 u8 port_type;
284 u8 transceiver; 284 u8 transceiver;
285 u8 generation; /* BladeEngine ASIC generation */ 285 u8 generation; /* BladeEngine ASIC generation */
286 u32 flash_status;
287 struct completion flash_compl;
286 288
287 bool sriov_enabled; 289 bool sriov_enabled;
288 u32 vf_if_handle[BE_MAX_VF]; 290 u32 vf_if_handle[BE_MAX_VF];
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index e79bf8b9af3b..b9ad799c719f 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -59,6 +59,13 @@ static int be_mcc_compl_process(struct be_adapter *adapter,
59 59
60 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) & 60 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &
61 CQE_STATUS_COMPL_MASK; 61 CQE_STATUS_COMPL_MASK;
62
63 if ((compl->tag0 == OPCODE_COMMON_WRITE_FLASHROM) &&
64 (compl->tag1 == CMD_SUBSYSTEM_COMMON)) {
65 adapter->flash_status = compl_status;
66 complete(&adapter->flash_compl);
67 }
68
62 if (compl_status == MCC_STATUS_SUCCESS) { 69 if (compl_status == MCC_STATUS_SUCCESS) {
63 if (compl->tag0 == OPCODE_ETH_GET_STATISTICS) { 70 if (compl->tag0 == OPCODE_ETH_GET_STATISTICS) {
64 struct be_cmd_resp_get_stats *resp = 71 struct be_cmd_resp_get_stats *resp =
@@ -287,7 +294,7 @@ int be_cmd_POST(struct be_adapter *adapter)
287 } else { 294 } else {
288 return 0; 295 return 0;
289 } 296 }
290 } while (timeout < 20); 297 } while (timeout < 40);
291 298
292 dev_err(&adapter->pdev->dev, "POST timeout; stage=0x%x\n", stage); 299 dev_err(&adapter->pdev->dev, "POST timeout; stage=0x%x\n", stage);
293 return -1; 300 return -1;
@@ -1417,17 +1424,19 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
1417 int status; 1424 int status;
1418 1425
1419 spin_lock_bh(&adapter->mcc_lock); 1426 spin_lock_bh(&adapter->mcc_lock);
1427 adapter->flash_status = 0;
1420 1428
1421 wrb = wrb_from_mccq(adapter); 1429 wrb = wrb_from_mccq(adapter);
1422 if (!wrb) { 1430 if (!wrb) {
1423 status = -EBUSY; 1431 status = -EBUSY;
1424 goto err; 1432 goto err_unlock;
1425 } 1433 }
1426 req = cmd->va; 1434 req = cmd->va;
1427 sge = nonembedded_sgl(wrb); 1435 sge = nonembedded_sgl(wrb);
1428 1436
1429 be_wrb_hdr_prepare(wrb, cmd->size, false, 1, 1437 be_wrb_hdr_prepare(wrb, cmd->size, false, 1,
1430 OPCODE_COMMON_WRITE_FLASHROM); 1438 OPCODE_COMMON_WRITE_FLASHROM);
1439 wrb->tag1 = CMD_SUBSYSTEM_COMMON;
1431 1440
1432 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 1441 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1433 OPCODE_COMMON_WRITE_FLASHROM, cmd->size); 1442 OPCODE_COMMON_WRITE_FLASHROM, cmd->size);
@@ -1439,9 +1448,18 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
1439 req->params.op_code = cpu_to_le32(flash_opcode); 1448 req->params.op_code = cpu_to_le32(flash_opcode);
1440 req->params.data_buf_size = cpu_to_le32(buf_size); 1449 req->params.data_buf_size = cpu_to_le32(buf_size);
1441 1450
1442 status = be_mcc_notify_wait(adapter); 1451 be_mcc_notify(adapter);
1452 spin_unlock_bh(&adapter->mcc_lock);
1443 1453
1444err: 1454 if (!wait_for_completion_timeout(&adapter->flash_compl,
1455 msecs_to_jiffies(12000)))
1456 status = -1;
1457 else
1458 status = adapter->flash_status;
1459
1460 return status;
1461
1462err_unlock:
1445 spin_unlock_bh(&adapter->mcc_lock); 1463 spin_unlock_bh(&adapter->mcc_lock);
1446 return status; 1464 return status;
1447} 1465}
@@ -1482,7 +1500,7 @@ err:
1482 return status; 1500 return status;
1483} 1501}
1484 1502
1485extern int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac, 1503int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac,
1486 struct be_dma_mem *nonemb_cmd) 1504 struct be_dma_mem *nonemb_cmd)
1487{ 1505{
1488 struct be_mcc_wrb *wrb; 1506 struct be_mcc_wrb *wrb;
@@ -1575,7 +1593,7 @@ int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
1575 1593
1576 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, 1594 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL,
1577 OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req)); 1595 OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req));
1578 req->hdr.timeout = 4; 1596 req->hdr.timeout = cpu_to_le32(4);
1579 1597
1580 req->pattern = cpu_to_le64(pattern); 1598 req->pattern = cpu_to_le64(pattern);
1581 req->src_port = cpu_to_le32(port_num); 1599 req->src_port = cpu_to_le32(port_num);
@@ -1647,7 +1665,7 @@ err:
1647 return status; 1665 return status;
1648} 1666}
1649 1667
1650extern int be_cmd_get_seeprom_data(struct be_adapter *adapter, 1668int be_cmd_get_seeprom_data(struct be_adapter *adapter,
1651 struct be_dma_mem *nonemb_cmd) 1669 struct be_dma_mem *nonemb_cmd)
1652{ 1670{
1653 struct be_mcc_wrb *wrb; 1671 struct be_mcc_wrb *wrb;
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 058d7f95f5ae..54b14272f333 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -1861,7 +1861,7 @@ static int be_setup(struct be_adapter *adapter)
1861 goto if_destroy; 1861 goto if_destroy;
1862 } 1862 }
1863 vf++; 1863 vf++;
1864 } while (vf < num_vfs); 1864 }
1865 } else if (!be_physfn(adapter)) { 1865 } else if (!be_physfn(adapter)) {
1866 status = be_cmd_mac_addr_query(adapter, mac, 1866 status = be_cmd_mac_addr_query(adapter, mac,
1867 MAC_ADDRESS_TYPE_NETWORK, false, adapter->if_handle); 1867 MAC_ADDRESS_TYPE_NETWORK, false, adapter->if_handle);
@@ -2319,6 +2319,7 @@ static int be_ctrl_init(struct be_adapter *adapter)
2319 spin_lock_init(&adapter->mcc_lock); 2319 spin_lock_init(&adapter->mcc_lock);
2320 spin_lock_init(&adapter->mcc_cq_lock); 2320 spin_lock_init(&adapter->mcc_cq_lock);
2321 2321
2322 init_completion(&adapter->flash_compl);
2322 pci_save_state(adapter->pdev); 2323 pci_save_state(adapter->pdev);
2323 return 0; 2324 return 0;
2324 2325
@@ -2487,10 +2488,6 @@ static int __devinit be_probe(struct pci_dev *pdev,
2487 status = be_cmd_POST(adapter); 2488 status = be_cmd_POST(adapter);
2488 if (status) 2489 if (status)
2489 goto ctrl_clean; 2490 goto ctrl_clean;
2490
2491 status = be_cmd_reset_function(adapter);
2492 if (status)
2493 goto ctrl_clean;
2494 } 2491 }
2495 2492
2496 /* tell fw we're ready to fire cmds */ 2493 /* tell fw we're ready to fire cmds */
@@ -2498,6 +2495,12 @@ static int __devinit be_probe(struct pci_dev *pdev,
2498 if (status) 2495 if (status)
2499 goto ctrl_clean; 2496 goto ctrl_clean;
2500 2497
2498 if (be_physfn(adapter)) {
2499 status = be_cmd_reset_function(adapter);
2500 if (status)
2501 goto ctrl_clean;
2502 }
2503
2501 status = be_stats_init(adapter); 2504 status = be_stats_init(adapter);
2502 if (status) 2505 if (status)
2503 goto ctrl_clean; 2506 goto ctrl_clean;
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 39a54bad397f..368f33313fb6 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -1626,6 +1626,7 @@ static int __devinit bfin_mii_bus_probe(struct platform_device *pdev)
1626 return 0; 1626 return 0;
1627 1627
1628out_err_mdiobus_register: 1628out_err_mdiobus_register:
1629 kfree(miibus->irq);
1629 mdiobus_free(miibus); 1630 mdiobus_free(miibus);
1630out_err_alloc: 1631out_err_alloc:
1631 peripheral_free_list(pin_req); 1632 peripheral_free_list(pin_req);
@@ -1638,6 +1639,7 @@ static int __devexit bfin_mii_bus_remove(struct platform_device *pdev)
1638 struct mii_bus *miibus = platform_get_drvdata(pdev); 1639 struct mii_bus *miibus = platform_get_drvdata(pdev);
1639 platform_set_drvdata(pdev, NULL); 1640 platform_set_drvdata(pdev, NULL);
1640 mdiobus_unregister(miibus); 1641 mdiobus_unregister(miibus);
1642 kfree(miibus->irq);
1641 mdiobus_free(miibus); 1643 mdiobus_free(miibus);
1642 peripheral_free_list(pin_req); 1644 peripheral_free_list(pin_req);
1643 return 0; 1645 return 0;
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 39250b2ca886..959add2410bf 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -1654,8 +1654,11 @@ MODULE_DEVICE_TABLE (of, bmac_match);
1654 1654
1655static struct macio_driver bmac_driver = 1655static struct macio_driver bmac_driver =
1656{ 1656{
1657 .name = "bmac", 1657 .driver = {
1658 .match_table = bmac_match, 1658 .name = "bmac",
1659 .owner = THIS_MODULE,
1660 .of_match_table = bmac_match,
1661 },
1659 .probe = bmac_probe, 1662 .probe = bmac_probe,
1660 .remove = bmac_remove, 1663 .remove = bmac_remove,
1661#ifdef CONFIG_PM 1664#ifdef CONFIG_PM
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 188e356c30a3..949d7a9dcf92 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -247,6 +247,7 @@ static const struct flash_spec flash_5709 = {
247MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl); 247MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
248 248
249static void bnx2_init_napi(struct bnx2 *bp); 249static void bnx2_init_napi(struct bnx2 *bp);
250static void bnx2_del_napi(struct bnx2 *bp);
250 251
251static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr) 252static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
252{ 253{
@@ -6270,6 +6271,7 @@ open_err:
6270 bnx2_free_skbs(bp); 6271 bnx2_free_skbs(bp);
6271 bnx2_free_irq(bp); 6272 bnx2_free_irq(bp);
6272 bnx2_free_mem(bp); 6273 bnx2_free_mem(bp);
6274 bnx2_del_napi(bp);
6273 return rc; 6275 return rc;
6274} 6276}
6275 6277
@@ -6537,6 +6539,7 @@ bnx2_close(struct net_device *dev)
6537 bnx2_free_irq(bp); 6539 bnx2_free_irq(bp);
6538 bnx2_free_skbs(bp); 6540 bnx2_free_skbs(bp);
6539 bnx2_free_mem(bp); 6541 bnx2_free_mem(bp);
6542 bnx2_del_napi(bp);
6540 bp->link_up = 0; 6543 bp->link_up = 0;
6541 netif_carrier_off(bp->dev); 6544 netif_carrier_off(bp->dev);
6542 bnx2_set_power_state(bp, PCI_D3hot); 6545 bnx2_set_power_state(bp, PCI_D3hot);
@@ -8227,7 +8230,16 @@ bnx2_bus_string(struct bnx2 *bp, char *str)
8227 return str; 8230 return str;
8228} 8231}
8229 8232
8230static void __devinit 8233static void
8234bnx2_del_napi(struct bnx2 *bp)
8235{
8236 int i;
8237
8238 for (i = 0; i < bp->irq_nvecs; i++)
8239 netif_napi_del(&bp->bnx2_napi[i].napi);
8240}
8241
8242static void
8231bnx2_init_napi(struct bnx2 *bp) 8243bnx2_init_napi(struct bnx2 *bp)
8232{ 8244{
8233 int i; 8245 int i;
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index 05b751719bd5..2c5227c02fa0 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -63,6 +63,16 @@ config CAN_BFIN
63 To compile this driver as a module, choose M here: the 63 To compile this driver as a module, choose M here: the
64 module will be called bfin_can. 64 module will be called bfin_can.
65 65
66config CAN_JANZ_ICAN3
67 tristate "Janz VMOD-ICAN3 Intelligent CAN controller"
68 depends on CAN_DEV && MFD_JANZ_CMODIO
69 ---help---
70 Driver for Janz VMOD-ICAN3 Intelligent CAN controller module, which
71 connects to a MODULbus carrier board.
72
73 This driver can also be built as a module. If so, the module will be
74 called janz-ican3.ko.
75
66source "drivers/net/can/mscan/Kconfig" 76source "drivers/net/can/mscan/Kconfig"
67 77
68source "drivers/net/can/sja1000/Kconfig" 78source "drivers/net/can/sja1000/Kconfig"
diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile
index 7a702f28d01c..9047cd066fea 100644
--- a/drivers/net/can/Makefile
+++ b/drivers/net/can/Makefile
@@ -15,5 +15,6 @@ obj-$(CONFIG_CAN_AT91) += at91_can.o
15obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o 15obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o
16obj-$(CONFIG_CAN_MCP251X) += mcp251x.o 16obj-$(CONFIG_CAN_MCP251X) += mcp251x.o
17obj-$(CONFIG_CAN_BFIN) += bfin_can.o 17obj-$(CONFIG_CAN_BFIN) += bfin_can.o
18obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o
18 19
19ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG 20ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
new file mode 100644
index 000000000000..6e533dcc36c0
--- /dev/null
+++ b/drivers/net/can/janz-ican3.c
@@ -0,0 +1,1830 @@
1/*
2 * Janz MODULbus VMOD-ICAN3 CAN Interface Driver
3 *
4 * Copyright (c) 2010 Ira W. Snyder <iws@ovro.caltech.edu>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/delay.h>
17#include <linux/platform_device.h>
18
19#include <linux/netdevice.h>
20#include <linux/can.h>
21#include <linux/can/dev.h>
22#include <linux/can/error.h>
23
24#include <linux/mfd/janz.h>
25
26/* the DPM has 64k of memory, organized into 256x 256 byte pages */
27#define DPM_NUM_PAGES 256
28#define DPM_PAGE_SIZE 256
29#define DPM_PAGE_ADDR(p) ((p) * DPM_PAGE_SIZE)
30
31/* JANZ ICAN3 "old-style" host interface queue page numbers */
32#define QUEUE_OLD_CONTROL 0
33#define QUEUE_OLD_RB0 1
34#define QUEUE_OLD_RB1 2
35#define QUEUE_OLD_WB0 3
36#define QUEUE_OLD_WB1 4
37
38/* Janz ICAN3 "old-style" host interface control registers */
39#define MSYNC_PEER 0x00 /* ICAN only */
40#define MSYNC_LOCL 0x01 /* host only */
41#define TARGET_RUNNING 0x02
42
43#define MSYNC_RB0 0x01
44#define MSYNC_RB1 0x02
45#define MSYNC_RBLW 0x04
46#define MSYNC_RB_MASK (MSYNC_RB0 | MSYNC_RB1)
47
48#define MSYNC_WB0 0x10
49#define MSYNC_WB1 0x20
50#define MSYNC_WBLW 0x40
51#define MSYNC_WB_MASK (MSYNC_WB0 | MSYNC_WB1)
52
53/* Janz ICAN3 "new-style" host interface queue page numbers */
54#define QUEUE_TOHOST 5
55#define QUEUE_FROMHOST_MID 6
56#define QUEUE_FROMHOST_HIGH 7
57#define QUEUE_FROMHOST_LOW 8
58
59/* The first free page in the DPM is #9 */
60#define DPM_FREE_START 9
61
62/* Janz ICAN3 "new-style" and "fast" host interface descriptor flags */
63#define DESC_VALID 0x80
64#define DESC_WRAP 0x40
65#define DESC_INTERRUPT 0x20
66#define DESC_IVALID 0x10
67#define DESC_LEN(len) (len)
68
69/* Janz ICAN3 Firmware Messages */
70#define MSG_CONNECTI 0x02
71#define MSG_DISCONNECT 0x03
72#define MSG_IDVERS 0x04
73#define MSG_MSGLOST 0x05
74#define MSG_NEWHOSTIF 0x08
75#define MSG_INQUIRY 0x0a
76#define MSG_SETAFILMASK 0x10
77#define MSG_INITFDPMQUEUE 0x11
78#define MSG_HWCONF 0x12
79#define MSG_FMSGLOST 0x15
80#define MSG_CEVTIND 0x37
81#define MSG_CBTRREQ 0x41
82#define MSG_COFFREQ 0x42
83#define MSG_CONREQ 0x43
84#define MSG_CCONFREQ 0x47
85
86/*
87 * Janz ICAN3 CAN Inquiry Message Types
88 *
89 * NOTE: there appears to be a firmware bug here. You must send
90 * NOTE: INQUIRY_STATUS and expect to receive an INQUIRY_EXTENDED
91 * NOTE: response. The controller never responds to a message with
92 * NOTE: the INQUIRY_EXTENDED subspec :(
93 */
94#define INQUIRY_STATUS 0x00
95#define INQUIRY_TERMINATION 0x01
96#define INQUIRY_EXTENDED 0x04
97
98/* Janz ICAN3 CAN Set Acceptance Filter Mask Message Types */
99#define SETAFILMASK_REJECT 0x00
100#define SETAFILMASK_FASTIF 0x02
101
102/* Janz ICAN3 CAN Hardware Configuration Message Types */
103#define HWCONF_TERMINATE_ON 0x01
104#define HWCONF_TERMINATE_OFF 0x00
105
106/* Janz ICAN3 CAN Event Indication Message Types */
107#define CEVTIND_EI 0x01
108#define CEVTIND_DOI 0x02
109#define CEVTIND_LOST 0x04
110#define CEVTIND_FULL 0x08
111#define CEVTIND_BEI 0x10
112
113#define CEVTIND_CHIP_SJA1000 0x02
114
115#define ICAN3_BUSERR_QUOTA_MAX 255
116
117/* Janz ICAN3 CAN Frame Conversion */
118#define ICAN3_ECHO 0x10
119#define ICAN3_EFF_RTR 0x40
120#define ICAN3_SFF_RTR 0x10
121#define ICAN3_EFF 0x80
122
123#define ICAN3_CAN_TYPE_MASK 0x0f
124#define ICAN3_CAN_TYPE_SFF 0x00
125#define ICAN3_CAN_TYPE_EFF 0x01
126
127#define ICAN3_CAN_DLC_MASK 0x0f
128
129/*
130 * SJA1000 Status and Error Register Definitions
131 *
132 * Copied from drivers/net/can/sja1000/sja1000.h
133 */
134
135/* status register content */
136#define SR_BS 0x80
137#define SR_ES 0x40
138#define SR_TS 0x20
139#define SR_RS 0x10
140#define SR_TCS 0x08
141#define SR_TBS 0x04
142#define SR_DOS 0x02
143#define SR_RBS 0x01
144
145#define SR_CRIT (SR_BS|SR_ES)
146
147/* ECC register */
148#define ECC_SEG 0x1F
149#define ECC_DIR 0x20
150#define ECC_ERR 6
151#define ECC_BIT 0x00
152#define ECC_FORM 0x40
153#define ECC_STUFF 0x80
154#define ECC_MASK 0xc0
155
156/* Number of buffers for use in the "new-style" host interface */
157#define ICAN3_NEW_BUFFERS 16
158
159/* Number of buffers for use in the "fast" host interface */
160#define ICAN3_TX_BUFFERS 512
161#define ICAN3_RX_BUFFERS 1024
162
163/* SJA1000 Clock Input */
164#define ICAN3_CAN_CLOCK 8000000
165
166/* Driver Name */
167#define DRV_NAME "janz-ican3"
168
169/* DPM Control Registers -- starts at offset 0x100 in the MODULbus registers */
170struct ican3_dpm_control {
171 /* window address register */
172 u8 window_address;
173 u8 unused1;
174
175 /*
176 * Read access: clear interrupt from microcontroller
177 * Write access: send interrupt to microcontroller
178 */
179 u8 interrupt;
180 u8 unused2;
181
182 /* write-only: reset all hardware on the module */
183 u8 hwreset;
184 u8 unused3;
185
186 /* write-only: generate an interrupt to the TPU */
187 u8 tpuinterrupt;
188};
189
190struct ican3_dev {
191
192 /* must be the first member */
193 struct can_priv can;
194
195 /* CAN network device */
196 struct net_device *ndev;
197 struct napi_struct napi;
198
199 /* Device for printing */
200 struct device *dev;
201
202 /* module number */
203 unsigned int num;
204
205 /* base address of registers and IRQ */
206 struct janz_cmodio_onboard_regs __iomem *ctrl;
207 struct ican3_dpm_control __iomem *dpmctrl;
208 void __iomem *dpm;
209 int irq;
210
211 /* CAN bus termination status */
212 struct completion termination_comp;
213 bool termination_enabled;
214
215 /* CAN bus error status registers */
216 struct completion buserror_comp;
217 struct can_berr_counter bec;
218
219 /* old and new style host interface */
220 unsigned int iftype;
221
222 /*
223 * Any function which changes the current DPM page must hold this
224 * lock while it is performing data accesses. This ensures that the
225 * function will not be preempted and end up reading data from a
226 * different DPM page than it expects.
227 */
228 spinlock_t lock;
229
230 /* new host interface */
231 unsigned int rx_int;
232 unsigned int rx_num;
233 unsigned int tx_num;
234
235 /* fast host interface */
236 unsigned int fastrx_start;
237 unsigned int fastrx_int;
238 unsigned int fastrx_num;
239 unsigned int fasttx_start;
240 unsigned int fasttx_num;
241
242 /* first free DPM page */
243 unsigned int free_page;
244};
245
246struct ican3_msg {
247 u8 control;
248 u8 spec;
249 __le16 len;
250 u8 data[252];
251};
252
253struct ican3_new_desc {
254 u8 control;
255 u8 pointer;
256};
257
258struct ican3_fast_desc {
259 u8 control;
260 u8 command;
261 u8 data[14];
262};
263
264/* write to the window basic address register */
265static inline void ican3_set_page(struct ican3_dev *mod, unsigned int page)
266{
267 BUG_ON(page >= DPM_NUM_PAGES);
268 iowrite8(page, &mod->dpmctrl->window_address);
269}
270
271/*
272 * ICAN3 "old-style" host interface
273 */
274
275/*
276 * Recieve a message from the ICAN3 "old-style" firmware interface
277 *
278 * LOCKING: must hold mod->lock
279 *
280 * returns 0 on success, -ENOMEM when no message exists
281 */
282static int ican3_old_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg)
283{
284 unsigned int mbox, mbox_page;
285 u8 locl, peer, xord;
286
287 /* get the MSYNC registers */
288 ican3_set_page(mod, QUEUE_OLD_CONTROL);
289 peer = ioread8(mod->dpm + MSYNC_PEER);
290 locl = ioread8(mod->dpm + MSYNC_LOCL);
291 xord = locl ^ peer;
292
293 if ((xord & MSYNC_RB_MASK) == 0x00) {
294 dev_dbg(mod->dev, "no mbox for reading\n");
295 return -ENOMEM;
296 }
297
298 /* find the first free mbox to read */
299 if ((xord & MSYNC_RB_MASK) == MSYNC_RB_MASK)
300 mbox = (xord & MSYNC_RBLW) ? MSYNC_RB0 : MSYNC_RB1;
301 else
302 mbox = (xord & MSYNC_RB0) ? MSYNC_RB0 : MSYNC_RB1;
303
304 /* copy the message */
305 mbox_page = (mbox == MSYNC_RB0) ? QUEUE_OLD_RB0 : QUEUE_OLD_RB1;
306 ican3_set_page(mod, mbox_page);
307 memcpy_fromio(msg, mod->dpm, sizeof(*msg));
308
309 /*
310 * notify the firmware that the read buffer is available
311 * for it to fill again
312 */
313 locl ^= mbox;
314
315 ican3_set_page(mod, QUEUE_OLD_CONTROL);
316 iowrite8(locl, mod->dpm + MSYNC_LOCL);
317 return 0;
318}
319
320/*
321 * Send a message through the "old-style" firmware interface
322 *
323 * LOCKING: must hold mod->lock
324 *
325 * returns 0 on success, -ENOMEM when no free space exists
326 */
327static int ican3_old_send_msg(struct ican3_dev *mod, struct ican3_msg *msg)
328{
329 unsigned int mbox, mbox_page;
330 u8 locl, peer, xord;
331
332 /* get the MSYNC registers */
333 ican3_set_page(mod, QUEUE_OLD_CONTROL);
334 peer = ioread8(mod->dpm + MSYNC_PEER);
335 locl = ioread8(mod->dpm + MSYNC_LOCL);
336 xord = locl ^ peer;
337
338 if ((xord & MSYNC_WB_MASK) == MSYNC_WB_MASK) {
339 dev_err(mod->dev, "no mbox for writing\n");
340 return -ENOMEM;
341 }
342
343 /* calculate a free mbox to use */
344 mbox = (xord & MSYNC_WB0) ? MSYNC_WB1 : MSYNC_WB0;
345
346 /* copy the message to the DPM */
347 mbox_page = (mbox == MSYNC_WB0) ? QUEUE_OLD_WB0 : QUEUE_OLD_WB1;
348 ican3_set_page(mod, mbox_page);
349 memcpy_toio(mod->dpm, msg, sizeof(*msg));
350
351 locl ^= mbox;
352 if (mbox == MSYNC_WB1)
353 locl |= MSYNC_WBLW;
354
355 ican3_set_page(mod, QUEUE_OLD_CONTROL);
356 iowrite8(locl, mod->dpm + MSYNC_LOCL);
357 return 0;
358}
359
360/*
361 * ICAN3 "new-style" Host Interface Setup
362 */
363
364static void __devinit ican3_init_new_host_interface(struct ican3_dev *mod)
365{
366 struct ican3_new_desc desc;
367 unsigned long flags;
368 void __iomem *dst;
369 int i;
370
371 spin_lock_irqsave(&mod->lock, flags);
372
373 /* setup the internal datastructures for RX */
374 mod->rx_num = 0;
375 mod->rx_int = 0;
376
377 /* tohost queue descriptors are in page 5 */
378 ican3_set_page(mod, QUEUE_TOHOST);
379 dst = mod->dpm;
380
381 /* initialize the tohost (rx) queue descriptors: pages 9-24 */
382 for (i = 0; i < ICAN3_NEW_BUFFERS; i++) {
383 desc.control = DESC_INTERRUPT | DESC_LEN(1); /* I L=1 */
384 desc.pointer = mod->free_page;
385
386 /* set wrap flag on last buffer */
387 if (i == ICAN3_NEW_BUFFERS - 1)
388 desc.control |= DESC_WRAP;
389
390 memcpy_toio(dst, &desc, sizeof(desc));
391 dst += sizeof(desc);
392 mod->free_page++;
393 }
394
395 /* fromhost (tx) mid queue descriptors are in page 6 */
396 ican3_set_page(mod, QUEUE_FROMHOST_MID);
397 dst = mod->dpm;
398
399 /* setup the internal datastructures for TX */
400 mod->tx_num = 0;
401
402 /* initialize the fromhost mid queue descriptors: pages 25-40 */
403 for (i = 0; i < ICAN3_NEW_BUFFERS; i++) {
404 desc.control = DESC_VALID | DESC_LEN(1); /* V L=1 */
405 desc.pointer = mod->free_page;
406
407 /* set wrap flag on last buffer */
408 if (i == ICAN3_NEW_BUFFERS - 1)
409 desc.control |= DESC_WRAP;
410
411 memcpy_toio(dst, &desc, sizeof(desc));
412 dst += sizeof(desc);
413 mod->free_page++;
414 }
415
416 /* fromhost hi queue descriptors are in page 7 */
417 ican3_set_page(mod, QUEUE_FROMHOST_HIGH);
418 dst = mod->dpm;
419
420 /* initialize only a single buffer in the fromhost hi queue (unused) */
421 desc.control = DESC_VALID | DESC_WRAP | DESC_LEN(1); /* VW L=1 */
422 desc.pointer = mod->free_page;
423 memcpy_toio(dst, &desc, sizeof(desc));
424 mod->free_page++;
425
426 /* fromhost low queue descriptors are in page 8 */
427 ican3_set_page(mod, QUEUE_FROMHOST_LOW);
428 dst = mod->dpm;
429
430 /* initialize only a single buffer in the fromhost low queue (unused) */
431 desc.control = DESC_VALID | DESC_WRAP | DESC_LEN(1); /* VW L=1 */
432 desc.pointer = mod->free_page;
433 memcpy_toio(dst, &desc, sizeof(desc));
434 mod->free_page++;
435
436 spin_unlock_irqrestore(&mod->lock, flags);
437}
438
439/*
440 * ICAN3 Fast Host Interface Setup
441 */
442
443static void __devinit ican3_init_fast_host_interface(struct ican3_dev *mod)
444{
445 struct ican3_fast_desc desc;
446 unsigned long flags;
447 unsigned int addr;
448 void __iomem *dst;
449 int i;
450
451 spin_lock_irqsave(&mod->lock, flags);
452
453 /* save the start recv page */
454 mod->fastrx_start = mod->free_page;
455 mod->fastrx_num = 0;
456 mod->fastrx_int = 0;
457
458 /* build a single fast tohost queue descriptor */
459 memset(&desc, 0, sizeof(desc));
460 desc.control = 0x00;
461 desc.command = 1;
462
463 /* build the tohost queue descriptor ring in memory */
464 addr = 0;
465 for (i = 0; i < ICAN3_RX_BUFFERS; i++) {
466
467 /* set the wrap bit on the last buffer */
468 if (i == ICAN3_RX_BUFFERS - 1)
469 desc.control |= DESC_WRAP;
470
471 /* switch to the correct page */
472 ican3_set_page(mod, mod->free_page);
473
474 /* copy the descriptor to the DPM */
475 dst = mod->dpm + addr;
476 memcpy_toio(dst, &desc, sizeof(desc));
477 addr += sizeof(desc);
478
479 /* move to the next page if necessary */
480 if (addr >= DPM_PAGE_SIZE) {
481 addr = 0;
482 mod->free_page++;
483 }
484 }
485
486 /* make sure we page-align the next queue */
487 if (addr != 0)
488 mod->free_page++;
489
490 /* save the start xmit page */
491 mod->fasttx_start = mod->free_page;
492 mod->fasttx_num = 0;
493
494 /* build a single fast fromhost queue descriptor */
495 memset(&desc, 0, sizeof(desc));
496 desc.control = DESC_VALID;
497 desc.command = 1;
498
499 /* build the fromhost queue descriptor ring in memory */
500 addr = 0;
501 for (i = 0; i < ICAN3_TX_BUFFERS; i++) {
502
503 /* set the wrap bit on the last buffer */
504 if (i == ICAN3_TX_BUFFERS - 1)
505 desc.control |= DESC_WRAP;
506
507 /* switch to the correct page */
508 ican3_set_page(mod, mod->free_page);
509
510 /* copy the descriptor to the DPM */
511 dst = mod->dpm + addr;
512 memcpy_toio(dst, &desc, sizeof(desc));
513 addr += sizeof(desc);
514
515 /* move to the next page if necessary */
516 if (addr >= DPM_PAGE_SIZE) {
517 addr = 0;
518 mod->free_page++;
519 }
520 }
521
522 spin_unlock_irqrestore(&mod->lock, flags);
523}
524
525/*
526 * ICAN3 "new-style" Host Interface Message Helpers
527 */
528
529/*
530 * LOCKING: must hold mod->lock
531 */
532static int ican3_new_send_msg(struct ican3_dev *mod, struct ican3_msg *msg)
533{
534 struct ican3_new_desc desc;
535 void __iomem *desc_addr = mod->dpm + (mod->tx_num * sizeof(desc));
536
537 /* switch to the fromhost mid queue, and read the buffer descriptor */
538 ican3_set_page(mod, QUEUE_FROMHOST_MID);
539 memcpy_fromio(&desc, desc_addr, sizeof(desc));
540
541 if (!(desc.control & DESC_VALID)) {
542 dev_dbg(mod->dev, "%s: no free buffers\n", __func__);
543 return -ENOMEM;
544 }
545
546 /* switch to the data page, copy the data */
547 ican3_set_page(mod, desc.pointer);
548 memcpy_toio(mod->dpm, msg, sizeof(*msg));
549
550 /* switch back to the descriptor, set the valid bit, write it back */
551 ican3_set_page(mod, QUEUE_FROMHOST_MID);
552 desc.control ^= DESC_VALID;
553 memcpy_toio(desc_addr, &desc, sizeof(desc));
554
555 /* update the tx number */
556 mod->tx_num = (desc.control & DESC_WRAP) ? 0 : (mod->tx_num + 1);
557 return 0;
558}
559
560/*
561 * LOCKING: must hold mod->lock
562 */
563static int ican3_new_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg)
564{
565 struct ican3_new_desc desc;
566 void __iomem *desc_addr = mod->dpm + (mod->rx_num * sizeof(desc));
567
568 /* switch to the tohost queue, and read the buffer descriptor */
569 ican3_set_page(mod, QUEUE_TOHOST);
570 memcpy_fromio(&desc, desc_addr, sizeof(desc));
571
572 if (!(desc.control & DESC_VALID)) {
573 dev_dbg(mod->dev, "%s: no buffers to recv\n", __func__);
574 return -ENOMEM;
575 }
576
577 /* switch to the data page, copy the data */
578 ican3_set_page(mod, desc.pointer);
579 memcpy_fromio(msg, mod->dpm, sizeof(*msg));
580
581 /* switch back to the descriptor, toggle the valid bit, write it back */
582 ican3_set_page(mod, QUEUE_TOHOST);
583 desc.control ^= DESC_VALID;
584 memcpy_toio(desc_addr, &desc, sizeof(desc));
585
586 /* update the rx number */
587 mod->rx_num = (desc.control & DESC_WRAP) ? 0 : (mod->rx_num + 1);
588 return 0;
589}
590
591/*
592 * Message Send / Recv Helpers
593 */
594
595static int ican3_send_msg(struct ican3_dev *mod, struct ican3_msg *msg)
596{
597 unsigned long flags;
598 int ret;
599
600 spin_lock_irqsave(&mod->lock, flags);
601
602 if (mod->iftype == 0)
603 ret = ican3_old_send_msg(mod, msg);
604 else
605 ret = ican3_new_send_msg(mod, msg);
606
607 spin_unlock_irqrestore(&mod->lock, flags);
608 return ret;
609}
610
611static int ican3_recv_msg(struct ican3_dev *mod, struct ican3_msg *msg)
612{
613 unsigned long flags;
614 int ret;
615
616 spin_lock_irqsave(&mod->lock, flags);
617
618 if (mod->iftype == 0)
619 ret = ican3_old_recv_msg(mod, msg);
620 else
621 ret = ican3_new_recv_msg(mod, msg);
622
623 spin_unlock_irqrestore(&mod->lock, flags);
624 return ret;
625}
626
627/*
628 * Quick Pre-constructed Messages
629 */
630
631static int __devinit ican3_msg_connect(struct ican3_dev *mod)
632{
633 struct ican3_msg msg;
634
635 memset(&msg, 0, sizeof(msg));
636 msg.spec = MSG_CONNECTI;
637 msg.len = cpu_to_le16(0);
638
639 return ican3_send_msg(mod, &msg);
640}
641
642static int __devexit ican3_msg_disconnect(struct ican3_dev *mod)
643{
644 struct ican3_msg msg;
645
646 memset(&msg, 0, sizeof(msg));
647 msg.spec = MSG_DISCONNECT;
648 msg.len = cpu_to_le16(0);
649
650 return ican3_send_msg(mod, &msg);
651}
652
653static int __devinit ican3_msg_newhostif(struct ican3_dev *mod)
654{
655 struct ican3_msg msg;
656 int ret;
657
658 memset(&msg, 0, sizeof(msg));
659 msg.spec = MSG_NEWHOSTIF;
660 msg.len = cpu_to_le16(0);
661
662 /* If we're not using the old interface, switching seems bogus */
663 WARN_ON(mod->iftype != 0);
664
665 ret = ican3_send_msg(mod, &msg);
666 if (ret)
667 return ret;
668
669 /* mark the module as using the new host interface */
670 mod->iftype = 1;
671 return 0;
672}
673
674static int __devinit ican3_msg_fasthostif(struct ican3_dev *mod)
675{
676 struct ican3_msg msg;
677 unsigned int addr;
678
679 memset(&msg, 0, sizeof(msg));
680 msg.spec = MSG_INITFDPMQUEUE;
681 msg.len = cpu_to_le16(8);
682
683 /* write the tohost queue start address */
684 addr = DPM_PAGE_ADDR(mod->fastrx_start);
685 msg.data[0] = addr & 0xff;
686 msg.data[1] = (addr >> 8) & 0xff;
687 msg.data[2] = (addr >> 16) & 0xff;
688 msg.data[3] = (addr >> 24) & 0xff;
689
690 /* write the fromhost queue start address */
691 addr = DPM_PAGE_ADDR(mod->fasttx_start);
692 msg.data[4] = addr & 0xff;
693 msg.data[5] = (addr >> 8) & 0xff;
694 msg.data[6] = (addr >> 16) & 0xff;
695 msg.data[7] = (addr >> 24) & 0xff;
696
697 /* If we're not using the new interface yet, we cannot do this */
698 WARN_ON(mod->iftype != 1);
699
700 return ican3_send_msg(mod, &msg);
701}
702
703/*
704 * Setup the CAN filter to either accept or reject all
705 * messages from the CAN bus.
706 */
707static int __devinit ican3_set_id_filter(struct ican3_dev *mod, bool accept)
708{
709 struct ican3_msg msg;
710 int ret;
711
712 /* Standard Frame Format */
713 memset(&msg, 0, sizeof(msg));
714 msg.spec = MSG_SETAFILMASK;
715 msg.len = cpu_to_le16(5);
716 msg.data[0] = 0x00; /* IDLo LSB */
717 msg.data[1] = 0x00; /* IDLo MSB */
718 msg.data[2] = 0xff; /* IDHi LSB */
719 msg.data[3] = 0x07; /* IDHi MSB */
720
721 /* accept all frames for fast host if, or reject all frames */
722 msg.data[4] = accept ? SETAFILMASK_FASTIF : SETAFILMASK_REJECT;
723
724 ret = ican3_send_msg(mod, &msg);
725 if (ret)
726 return ret;
727
728 /* Extended Frame Format */
729 memset(&msg, 0, sizeof(msg));
730 msg.spec = MSG_SETAFILMASK;
731 msg.len = cpu_to_le16(13);
732 msg.data[0] = 0; /* MUX = 0 */
733 msg.data[1] = 0x00; /* IDLo LSB */
734 msg.data[2] = 0x00;
735 msg.data[3] = 0x00;
736 msg.data[4] = 0x20; /* IDLo MSB */
737 msg.data[5] = 0xff; /* IDHi LSB */
738 msg.data[6] = 0xff;
739 msg.data[7] = 0xff;
740 msg.data[8] = 0x3f; /* IDHi MSB */
741
742 /* accept all frames for fast host if, or reject all frames */
743 msg.data[9] = accept ? SETAFILMASK_FASTIF : SETAFILMASK_REJECT;
744
745 return ican3_send_msg(mod, &msg);
746}
747
748/*
749 * Bring the CAN bus online or offline
750 */
751static int ican3_set_bus_state(struct ican3_dev *mod, bool on)
752{
753 struct ican3_msg msg;
754
755 memset(&msg, 0, sizeof(msg));
756 msg.spec = on ? MSG_CONREQ : MSG_COFFREQ;
757 msg.len = cpu_to_le16(0);
758
759 return ican3_send_msg(mod, &msg);
760}
761
762static int ican3_set_termination(struct ican3_dev *mod, bool on)
763{
764 struct ican3_msg msg;
765
766 memset(&msg, 0, sizeof(msg));
767 msg.spec = MSG_HWCONF;
768 msg.len = cpu_to_le16(2);
769 msg.data[0] = 0x00;
770 msg.data[1] = on ? HWCONF_TERMINATE_ON : HWCONF_TERMINATE_OFF;
771
772 return ican3_send_msg(mod, &msg);
773}
774
775static int ican3_send_inquiry(struct ican3_dev *mod, u8 subspec)
776{
777 struct ican3_msg msg;
778
779 memset(&msg, 0, sizeof(msg));
780 msg.spec = MSG_INQUIRY;
781 msg.len = cpu_to_le16(2);
782 msg.data[0] = subspec;
783 msg.data[1] = 0x00;
784
785 return ican3_send_msg(mod, &msg);
786}
787
788static int ican3_set_buserror(struct ican3_dev *mod, u8 quota)
789{
790 struct ican3_msg msg;
791
792 memset(&msg, 0, sizeof(msg));
793 msg.spec = MSG_CCONFREQ;
794 msg.len = cpu_to_le16(2);
795 msg.data[0] = 0x00;
796 msg.data[1] = quota;
797
798 return ican3_send_msg(mod, &msg);
799}
800
801/*
802 * ICAN3 to Linux CAN Frame Conversion
803 */
804
805static void ican3_to_can_frame(struct ican3_dev *mod,
806 struct ican3_fast_desc *desc,
807 struct can_frame *cf)
808{
809 if ((desc->command & ICAN3_CAN_TYPE_MASK) == ICAN3_CAN_TYPE_SFF) {
810 if (desc->data[1] & ICAN3_SFF_RTR)
811 cf->can_id |= CAN_RTR_FLAG;
812
813 cf->can_id |= desc->data[0] << 3;
814 cf->can_id |= (desc->data[1] & 0xe0) >> 5;
815 cf->can_dlc = desc->data[1] & ICAN3_CAN_DLC_MASK;
816 memcpy(cf->data, &desc->data[2], sizeof(cf->data));
817 } else {
818 cf->can_dlc = desc->data[0] & ICAN3_CAN_DLC_MASK;
819 if (desc->data[0] & ICAN3_EFF_RTR)
820 cf->can_id |= CAN_RTR_FLAG;
821
822 if (desc->data[0] & ICAN3_EFF) {
823 cf->can_id |= CAN_EFF_FLAG;
824 cf->can_id |= desc->data[2] << 21; /* 28-21 */
825 cf->can_id |= desc->data[3] << 13; /* 20-13 */
826 cf->can_id |= desc->data[4] << 5; /* 12-5 */
827 cf->can_id |= (desc->data[5] & 0xf8) >> 3;
828 } else {
829 cf->can_id |= desc->data[2] << 3; /* 10-3 */
830 cf->can_id |= desc->data[3] >> 5; /* 2-0 */
831 }
832
833 memcpy(cf->data, &desc->data[6], sizeof(cf->data));
834 }
835}
836
837static void can_frame_to_ican3(struct ican3_dev *mod,
838 struct can_frame *cf,
839 struct ican3_fast_desc *desc)
840{
841 /* clear out any stale data in the descriptor */
842 memset(desc->data, 0, sizeof(desc->data));
843
844 /* we always use the extended format, with the ECHO flag set */
845 desc->command = ICAN3_CAN_TYPE_EFF;
846 desc->data[0] |= cf->can_dlc;
847 desc->data[1] |= ICAN3_ECHO;
848
849 if (cf->can_id & CAN_RTR_FLAG)
850 desc->data[0] |= ICAN3_EFF_RTR;
851
852 /* pack the id into the correct places */
853 if (cf->can_id & CAN_EFF_FLAG) {
854 desc->data[0] |= ICAN3_EFF;
855 desc->data[2] = (cf->can_id & 0x1fe00000) >> 21; /* 28-21 */
856 desc->data[3] = (cf->can_id & 0x001fe000) >> 13; /* 20-13 */
857 desc->data[4] = (cf->can_id & 0x00001fe0) >> 5; /* 12-5 */
858 desc->data[5] = (cf->can_id & 0x0000001f) << 3; /* 4-0 */
859 } else {
860 desc->data[2] = (cf->can_id & 0x7F8) >> 3; /* bits 10-3 */
861 desc->data[3] = (cf->can_id & 0x007) << 5; /* bits 2-0 */
862 }
863
864 /* copy the data bits into the descriptor */
865 memcpy(&desc->data[6], cf->data, sizeof(cf->data));
866}
867
868/*
869 * Interrupt Handling
870 */
871
872/*
873 * Handle an ID + Version message response from the firmware. We never generate
874 * this message in production code, but it is very useful when debugging to be
875 * able to display this message.
876 */
877static void ican3_handle_idvers(struct ican3_dev *mod, struct ican3_msg *msg)
878{
879 dev_dbg(mod->dev, "IDVERS response: %s\n", msg->data);
880}
881
882static void ican3_handle_msglost(struct ican3_dev *mod, struct ican3_msg *msg)
883{
884 struct net_device *dev = mod->ndev;
885 struct net_device_stats *stats = &dev->stats;
886 struct can_frame *cf;
887 struct sk_buff *skb;
888
889 /*
890 * Report that communication messages with the microcontroller firmware
891 * are being lost. These are never CAN frames, so we do not generate an
892 * error frame for userspace
893 */
894 if (msg->spec == MSG_MSGLOST) {
895 dev_err(mod->dev, "lost %d control messages\n", msg->data[0]);
896 return;
897 }
898
899 /*
900 * Oops, this indicates that we have lost messages in the fast queue,
901 * which are exclusively CAN messages. Our driver isn't reading CAN
902 * frames fast enough.
903 *
904 * We'll pretend that the SJA1000 told us that it ran out of buffer
905 * space, because there is not a better message for this.
906 */
907 skb = alloc_can_err_skb(dev, &cf);
908 if (skb) {
909 cf->can_id |= CAN_ERR_CRTL;
910 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
911 stats->rx_errors++;
912 stats->rx_bytes += cf->can_dlc;
913 netif_rx(skb);
914 }
915}
916
917/*
918 * Handle CAN Event Indication Messages from the firmware
919 *
920 * The ICAN3 firmware provides the values of some SJA1000 registers when it
921 * generates this message. The code below is largely copied from the
922 * drivers/net/can/sja1000/sja1000.c file, and adapted as necessary
923 */
924static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
925{
926 struct net_device *dev = mod->ndev;
927 struct net_device_stats *stats = &dev->stats;
928 enum can_state state = mod->can.state;
929 u8 status, isrc, rxerr, txerr;
930 struct can_frame *cf;
931 struct sk_buff *skb;
932
933 /* we can only handle the SJA1000 part */
934 if (msg->data[1] != CEVTIND_CHIP_SJA1000) {
935 dev_err(mod->dev, "unable to handle errors on non-SJA1000\n");
936 return -ENODEV;
937 }
938
939 /* check the message length for sanity */
940 if (le16_to_cpu(msg->len) < 6) {
941 dev_err(mod->dev, "error message too short\n");
942 return -EINVAL;
943 }
944
945 skb = alloc_can_err_skb(dev, &cf);
946 if (skb == NULL)
947 return -ENOMEM;
948
949 isrc = msg->data[0];
950 status = msg->data[3];
951 rxerr = msg->data[4];
952 txerr = msg->data[5];
953
954 /* data overrun interrupt */
955 if (isrc == CEVTIND_DOI || isrc == CEVTIND_LOST) {
956 dev_dbg(mod->dev, "data overrun interrupt\n");
957 cf->can_id |= CAN_ERR_CRTL;
958 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
959 stats->rx_over_errors++;
960 stats->rx_errors++;
961 }
962
963 /* error warning + passive interrupt */
964 if (isrc == CEVTIND_EI) {
965 dev_dbg(mod->dev, "error warning + passive interrupt\n");
966 if (status & SR_BS) {
967 state = CAN_STATE_BUS_OFF;
968 cf->can_id |= CAN_ERR_BUSOFF;
969 can_bus_off(dev);
970 } else if (status & SR_ES) {
971 if (rxerr >= 128 || txerr >= 128)
972 state = CAN_STATE_ERROR_PASSIVE;
973 else
974 state = CAN_STATE_ERROR_WARNING;
975 } else {
976 state = CAN_STATE_ERROR_ACTIVE;
977 }
978 }
979
980 /* bus error interrupt */
981 if (isrc == CEVTIND_BEI) {
982 u8 ecc = msg->data[2];
983
984 dev_dbg(mod->dev, "bus error interrupt\n");
985 mod->can.can_stats.bus_error++;
986 stats->rx_errors++;
987 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
988
989 switch (ecc & ECC_MASK) {
990 case ECC_BIT:
991 cf->data[2] |= CAN_ERR_PROT_BIT;
992 break;
993 case ECC_FORM:
994 cf->data[2] |= CAN_ERR_PROT_FORM;
995 break;
996 case ECC_STUFF:
997 cf->data[2] |= CAN_ERR_PROT_STUFF;
998 break;
999 default:
1000 cf->data[2] |= CAN_ERR_PROT_UNSPEC;
1001 cf->data[3] = ecc & ECC_SEG;
1002 break;
1003 }
1004
1005 if ((ecc & ECC_DIR) == 0)
1006 cf->data[2] |= CAN_ERR_PROT_TX;
1007
1008 cf->data[6] = txerr;
1009 cf->data[7] = rxerr;
1010 }
1011
1012 if (state != mod->can.state && (state == CAN_STATE_ERROR_WARNING ||
1013 state == CAN_STATE_ERROR_PASSIVE)) {
1014 cf->can_id |= CAN_ERR_CRTL;
1015 if (state == CAN_STATE_ERROR_WARNING) {
1016 mod->can.can_stats.error_warning++;
1017 cf->data[1] = (txerr > rxerr) ?
1018 CAN_ERR_CRTL_TX_WARNING :
1019 CAN_ERR_CRTL_RX_WARNING;
1020 } else {
1021 mod->can.can_stats.error_passive++;
1022 cf->data[1] = (txerr > rxerr) ?
1023 CAN_ERR_CRTL_TX_PASSIVE :
1024 CAN_ERR_CRTL_RX_PASSIVE;
1025 }
1026
1027 cf->data[6] = txerr;
1028 cf->data[7] = rxerr;
1029 }
1030
1031 mod->can.state = state;
1032 stats->rx_errors++;
1033 stats->rx_bytes += cf->can_dlc;
1034 netif_rx(skb);
1035 return 0;
1036}
1037
1038static void ican3_handle_inquiry(struct ican3_dev *mod, struct ican3_msg *msg)
1039{
1040 switch (msg->data[0]) {
1041 case INQUIRY_STATUS:
1042 case INQUIRY_EXTENDED:
1043 mod->bec.rxerr = msg->data[5];
1044 mod->bec.txerr = msg->data[6];
1045 complete(&mod->buserror_comp);
1046 break;
1047 case INQUIRY_TERMINATION:
1048 mod->termination_enabled = msg->data[6] & HWCONF_TERMINATE_ON;
1049 complete(&mod->termination_comp);
1050 break;
1051 default:
1052 dev_err(mod->dev, "recieved an unknown inquiry response\n");
1053 break;
1054 }
1055}
1056
1057static void ican3_handle_unknown_message(struct ican3_dev *mod,
1058 struct ican3_msg *msg)
1059{
1060 dev_warn(mod->dev, "recieved unknown message: spec 0x%.2x length %d\n",
1061 msg->spec, le16_to_cpu(msg->len));
1062}
1063
1064/*
1065 * Handle a control message from the firmware
1066 */
1067static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg)
1068{
1069 dev_dbg(mod->dev, "%s: modno %d spec 0x%.2x len %d bytes\n", __func__,
1070 mod->num, msg->spec, le16_to_cpu(msg->len));
1071
1072 switch (msg->spec) {
1073 case MSG_IDVERS:
1074 ican3_handle_idvers(mod, msg);
1075 break;
1076 case MSG_MSGLOST:
1077 case MSG_FMSGLOST:
1078 ican3_handle_msglost(mod, msg);
1079 break;
1080 case MSG_CEVTIND:
1081 ican3_handle_cevtind(mod, msg);
1082 break;
1083 case MSG_INQUIRY:
1084 ican3_handle_inquiry(mod, msg);
1085 break;
1086 default:
1087 ican3_handle_unknown_message(mod, msg);
1088 break;
1089 }
1090}
1091
1092/*
1093 * Check that there is room in the TX ring to transmit another skb
1094 *
1095 * LOCKING: must hold mod->lock
1096 */
1097static bool ican3_txok(struct ican3_dev *mod)
1098{
1099 struct ican3_fast_desc __iomem *desc;
1100 u8 control;
1101
1102 /* copy the control bits of the descriptor */
1103 ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16));
1104 desc = mod->dpm + ((mod->fasttx_num % 16) * sizeof(*desc));
1105 control = ioread8(&desc->control);
1106
1107 /* if the control bits are not valid, then we have no more space */
1108 if (!(control & DESC_VALID))
1109 return false;
1110
1111 return true;
1112}
1113
1114/*
1115 * Recieve one CAN frame from the hardware
1116 *
1117 * This works like the core of a NAPI function, but is intended to be called
1118 * from workqueue context instead. This driver already needs a workqueue to
1119 * process control messages, so we use the workqueue instead of using NAPI.
1120 * This was done to simplify locking.
1121 *
1122 * CONTEXT: must be called from user context
1123 */
1124static int ican3_recv_skb(struct ican3_dev *mod)
1125{
1126 struct net_device *ndev = mod->ndev;
1127 struct net_device_stats *stats = &ndev->stats;
1128 struct ican3_fast_desc desc;
1129 void __iomem *desc_addr;
1130 struct can_frame *cf;
1131 struct sk_buff *skb;
1132 unsigned long flags;
1133
1134 spin_lock_irqsave(&mod->lock, flags);
1135
1136 /* copy the whole descriptor */
1137 ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16));
1138 desc_addr = mod->dpm + ((mod->fastrx_num % 16) * sizeof(desc));
1139 memcpy_fromio(&desc, desc_addr, sizeof(desc));
1140
1141 spin_unlock_irqrestore(&mod->lock, flags);
1142
1143 /* check that we actually have a CAN frame */
1144 if (!(desc.control & DESC_VALID))
1145 return -ENOBUFS;
1146
1147 /* allocate an skb */
1148 skb = alloc_can_skb(ndev, &cf);
1149 if (unlikely(skb == NULL)) {
1150 stats->rx_dropped++;
1151 goto err_noalloc;
1152 }
1153
1154 /* convert the ICAN3 frame into Linux CAN format */
1155 ican3_to_can_frame(mod, &desc, cf);
1156
1157 /* receive the skb, update statistics */
1158 netif_receive_skb(skb);
1159 stats->rx_packets++;
1160 stats->rx_bytes += cf->can_dlc;
1161
1162err_noalloc:
1163 /* toggle the valid bit and return the descriptor to the ring */
1164 desc.control ^= DESC_VALID;
1165
1166 spin_lock_irqsave(&mod->lock, flags);
1167
1168 ican3_set_page(mod, mod->fastrx_start + (mod->fastrx_num / 16));
1169 memcpy_toio(desc_addr, &desc, 1);
1170
1171 /* update the next buffer pointer */
1172 mod->fastrx_num = (desc.control & DESC_WRAP) ? 0
1173 : (mod->fastrx_num + 1);
1174
1175 /* there are still more buffers to process */
1176 spin_unlock_irqrestore(&mod->lock, flags);
1177 return 0;
1178}
1179
1180static int ican3_napi(struct napi_struct *napi, int budget)
1181{
1182 struct ican3_dev *mod = container_of(napi, struct ican3_dev, napi);
1183 struct ican3_msg msg;
1184 unsigned long flags;
1185 int received = 0;
1186 int ret;
1187
1188 /* process all communication messages */
1189 while (true) {
1190 ret = ican3_recv_msg(mod, &msg);
1191 if (ret)
1192 break;
1193
1194 ican3_handle_message(mod, &msg);
1195 }
1196
1197 /* process all CAN frames from the fast interface */
1198 while (received < budget) {
1199 ret = ican3_recv_skb(mod);
1200 if (ret)
1201 break;
1202
1203 received++;
1204 }
1205
1206 /* We have processed all packets that the adapter had, but it
1207 * was less than our budget, stop polling */
1208 if (received < budget)
1209 napi_complete(napi);
1210
1211 spin_lock_irqsave(&mod->lock, flags);
1212
1213 /* Wake up the transmit queue if necessary */
1214 if (netif_queue_stopped(mod->ndev) && ican3_txok(mod))
1215 netif_wake_queue(mod->ndev);
1216
1217 spin_unlock_irqrestore(&mod->lock, flags);
1218
1219 /* re-enable interrupt generation */
1220 iowrite8(1 << mod->num, &mod->ctrl->int_enable);
1221 return received;
1222}
1223
1224static irqreturn_t ican3_irq(int irq, void *dev_id)
1225{
1226 struct ican3_dev *mod = dev_id;
1227 u8 stat;
1228
1229 /*
1230 * The interrupt status register on this device reports interrupts
1231 * as zeroes instead of using ones like most other devices
1232 */
1233 stat = ioread8(&mod->ctrl->int_disable) & (1 << mod->num);
1234 if (stat == (1 << mod->num))
1235 return IRQ_NONE;
1236
1237 /* clear the MODULbus interrupt from the microcontroller */
1238 ioread8(&mod->dpmctrl->interrupt);
1239
1240 /* disable interrupt generation, schedule the NAPI poller */
1241 iowrite8(1 << mod->num, &mod->ctrl->int_disable);
1242 napi_schedule(&mod->napi);
1243 return IRQ_HANDLED;
1244}
1245
1246/*
1247 * Firmware reset, startup, and shutdown
1248 */
1249
1250/*
1251 * Reset an ICAN module to its power-on state
1252 *
1253 * CONTEXT: no network device registered
1254 * LOCKING: work function disabled
1255 */
1256static int ican3_reset_module(struct ican3_dev *mod)
1257{
1258 u8 val = 1 << mod->num;
1259 unsigned long start;
1260 u8 runold, runnew;
1261
1262 /* disable interrupts so no more work is scheduled */
1263 iowrite8(1 << mod->num, &mod->ctrl->int_disable);
1264
1265 /* flush any pending work */
1266 flush_scheduled_work();
1267
1268 /* the first unallocated page in the DPM is #9 */
1269 mod->free_page = DPM_FREE_START;
1270
1271 ican3_set_page(mod, QUEUE_OLD_CONTROL);
1272 runold = ioread8(mod->dpm + TARGET_RUNNING);
1273
1274 /* reset the module */
1275 iowrite8(val, &mod->ctrl->reset_assert);
1276 iowrite8(val, &mod->ctrl->reset_deassert);
1277
1278 /* wait until the module has finished resetting and is running */
1279 start = jiffies;
1280 do {
1281 ican3_set_page(mod, QUEUE_OLD_CONTROL);
1282 runnew = ioread8(mod->dpm + TARGET_RUNNING);
1283 if (runnew == (runold ^ 0xff))
1284 return 0;
1285
1286 msleep(10);
1287 } while (time_before(jiffies, start + HZ / 4));
1288
1289 dev_err(mod->dev, "failed to reset CAN module\n");
1290 return -ETIMEDOUT;
1291}
1292
1293static void __devexit ican3_shutdown_module(struct ican3_dev *mod)
1294{
1295 ican3_msg_disconnect(mod);
1296 ican3_reset_module(mod);
1297}
1298
1299/*
1300 * Startup an ICAN module, bringing it into fast mode
1301 */
1302static int __devinit ican3_startup_module(struct ican3_dev *mod)
1303{
1304 int ret;
1305
1306 ret = ican3_reset_module(mod);
1307 if (ret) {
1308 dev_err(mod->dev, "unable to reset module\n");
1309 return ret;
1310 }
1311
1312 /* re-enable interrupts so we can send messages */
1313 iowrite8(1 << mod->num, &mod->ctrl->int_enable);
1314
1315 ret = ican3_msg_connect(mod);
1316 if (ret) {
1317 dev_err(mod->dev, "unable to connect to module\n");
1318 return ret;
1319 }
1320
1321 ican3_init_new_host_interface(mod);
1322 ret = ican3_msg_newhostif(mod);
1323 if (ret) {
1324 dev_err(mod->dev, "unable to switch to new-style interface\n");
1325 return ret;
1326 }
1327
1328 /* default to "termination on" */
1329 ret = ican3_set_termination(mod, true);
1330 if (ret) {
1331 dev_err(mod->dev, "unable to enable termination\n");
1332 return ret;
1333 }
1334
1335 /* default to "bus errors enabled" */
1336 ret = ican3_set_buserror(mod, ICAN3_BUSERR_QUOTA_MAX);
1337 if (ret) {
1338 dev_err(mod->dev, "unable to set bus-error\n");
1339 return ret;
1340 }
1341
1342 ican3_init_fast_host_interface(mod);
1343 ret = ican3_msg_fasthostif(mod);
1344 if (ret) {
1345 dev_err(mod->dev, "unable to switch to fast host interface\n");
1346 return ret;
1347 }
1348
1349 ret = ican3_set_id_filter(mod, true);
1350 if (ret) {
1351 dev_err(mod->dev, "unable to set acceptance filter\n");
1352 return ret;
1353 }
1354
1355 return 0;
1356}
1357
1358/*
1359 * CAN Network Device
1360 */
1361
1362static int ican3_open(struct net_device *ndev)
1363{
1364 struct ican3_dev *mod = netdev_priv(ndev);
1365 u8 quota;
1366 int ret;
1367
1368 /* open the CAN layer */
1369 ret = open_candev(ndev);
1370 if (ret) {
1371 dev_err(mod->dev, "unable to start CAN layer\n");
1372 return ret;
1373 }
1374
1375 /* set the bus error generation state appropriately */
1376 if (mod->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
1377 quota = ICAN3_BUSERR_QUOTA_MAX;
1378 else
1379 quota = 0;
1380
1381 ret = ican3_set_buserror(mod, quota);
1382 if (ret) {
1383 dev_err(mod->dev, "unable to set bus-error\n");
1384 close_candev(ndev);
1385 return ret;
1386 }
1387
1388 /* bring the bus online */
1389 ret = ican3_set_bus_state(mod, true);
1390 if (ret) {
1391 dev_err(mod->dev, "unable to set bus-on\n");
1392 close_candev(ndev);
1393 return ret;
1394 }
1395
1396 /* start up the network device */
1397 mod->can.state = CAN_STATE_ERROR_ACTIVE;
1398 netif_start_queue(ndev);
1399
1400 return 0;
1401}
1402
1403static int ican3_stop(struct net_device *ndev)
1404{
1405 struct ican3_dev *mod = netdev_priv(ndev);
1406 int ret;
1407
1408 /* stop the network device xmit routine */
1409 netif_stop_queue(ndev);
1410 mod->can.state = CAN_STATE_STOPPED;
1411
1412 /* bring the bus offline, stop receiving packets */
1413 ret = ican3_set_bus_state(mod, false);
1414 if (ret) {
1415 dev_err(mod->dev, "unable to set bus-off\n");
1416 return ret;
1417 }
1418
1419 /* close the CAN layer */
1420 close_candev(ndev);
1421 return 0;
1422}
1423
1424static int ican3_xmit(struct sk_buff *skb, struct net_device *ndev)
1425{
1426 struct ican3_dev *mod = netdev_priv(ndev);
1427 struct net_device_stats *stats = &ndev->stats;
1428 struct can_frame *cf = (struct can_frame *)skb->data;
1429 struct ican3_fast_desc desc;
1430 void __iomem *desc_addr;
1431 unsigned long flags;
1432
1433 spin_lock_irqsave(&mod->lock, flags);
1434
1435 /* check that we can actually transmit */
1436 if (!ican3_txok(mod)) {
1437 dev_err(mod->dev, "no free descriptors, stopping queue\n");
1438 netif_stop_queue(ndev);
1439 spin_unlock_irqrestore(&mod->lock, flags);
1440 return NETDEV_TX_BUSY;
1441 }
1442
1443 /* copy the control bits of the descriptor */
1444 ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16));
1445 desc_addr = mod->dpm + ((mod->fasttx_num % 16) * sizeof(desc));
1446 memset(&desc, 0, sizeof(desc));
1447 memcpy_fromio(&desc, desc_addr, 1);
1448
1449 /* convert the Linux CAN frame into ICAN3 format */
1450 can_frame_to_ican3(mod, cf, &desc);
1451
1452 /*
1453 * the programming manual says that you must set the IVALID bit, then
1454 * interrupt, then set the valid bit. Quite weird, but it seems to be
1455 * required for this to work
1456 */
1457 desc.control |= DESC_IVALID;
1458 memcpy_toio(desc_addr, &desc, sizeof(desc));
1459
1460 /* generate a MODULbus interrupt to the microcontroller */
1461 iowrite8(0x01, &mod->dpmctrl->interrupt);
1462
1463 desc.control ^= DESC_VALID;
1464 memcpy_toio(desc_addr, &desc, sizeof(desc));
1465
1466 /* update the next buffer pointer */
1467 mod->fasttx_num = (desc.control & DESC_WRAP) ? 0
1468 : (mod->fasttx_num + 1);
1469
1470 /* update statistics */
1471 stats->tx_packets++;
1472 stats->tx_bytes += cf->can_dlc;
1473 kfree_skb(skb);
1474
1475 /*
1476 * This hardware doesn't have TX-done notifications, so we'll try and
1477 * emulate it the best we can using ECHO skbs. Get the next TX
1478 * descriptor, and see if we have room to send. If not, stop the queue.
1479 * It will be woken when the ECHO skb for the current packet is recv'd.
1480 */
1481
1482 /* copy the control bits of the descriptor */
1483 if (!ican3_txok(mod))
1484 netif_stop_queue(ndev);
1485
1486 spin_unlock_irqrestore(&mod->lock, flags);
1487 return NETDEV_TX_OK;
1488}
1489
1490static const struct net_device_ops ican3_netdev_ops = {
1491 .ndo_open = ican3_open,
1492 .ndo_stop = ican3_stop,
1493 .ndo_start_xmit = ican3_xmit,
1494};
1495
1496/*
1497 * Low-level CAN Device
1498 */
1499
1500/* This structure was stolen from drivers/net/can/sja1000/sja1000.c */
1501static struct can_bittiming_const ican3_bittiming_const = {
1502 .name = DRV_NAME,
1503 .tseg1_min = 1,
1504 .tseg1_max = 16,
1505 .tseg2_min = 1,
1506 .tseg2_max = 8,
1507 .sjw_max = 4,
1508 .brp_min = 1,
1509 .brp_max = 64,
1510 .brp_inc = 1,
1511};
1512
1513/*
1514 * This routine was stolen from drivers/net/can/sja1000/sja1000.c
1515 *
1516 * The bittiming register command for the ICAN3 just sets the bit timing
1517 * registers on the SJA1000 chip directly
1518 */
1519static int ican3_set_bittiming(struct net_device *ndev)
1520{
1521 struct ican3_dev *mod = netdev_priv(ndev);
1522 struct can_bittiming *bt = &mod->can.bittiming;
1523 struct ican3_msg msg;
1524 u8 btr0, btr1;
1525
1526 btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6);
1527 btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) |
1528 (((bt->phase_seg2 - 1) & 0x7) << 4);
1529 if (mod->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
1530 btr1 |= 0x80;
1531
1532 memset(&msg, 0, sizeof(msg));
1533 msg.spec = MSG_CBTRREQ;
1534 msg.len = cpu_to_le16(4);
1535 msg.data[0] = 0x00;
1536 msg.data[1] = 0x00;
1537 msg.data[2] = btr0;
1538 msg.data[3] = btr1;
1539
1540 return ican3_send_msg(mod, &msg);
1541}
1542
1543static int ican3_set_mode(struct net_device *ndev, enum can_mode mode)
1544{
1545 struct ican3_dev *mod = netdev_priv(ndev);
1546 int ret;
1547
1548 if (mode != CAN_MODE_START)
1549 return -ENOTSUPP;
1550
1551 /* bring the bus online */
1552 ret = ican3_set_bus_state(mod, true);
1553 if (ret) {
1554 dev_err(mod->dev, "unable to set bus-on\n");
1555 return ret;
1556 }
1557
1558 /* start up the network device */
1559 mod->can.state = CAN_STATE_ERROR_ACTIVE;
1560
1561 if (netif_queue_stopped(ndev))
1562 netif_wake_queue(ndev);
1563
1564 return 0;
1565}
1566
1567static int ican3_get_berr_counter(const struct net_device *ndev,
1568 struct can_berr_counter *bec)
1569{
1570 struct ican3_dev *mod = netdev_priv(ndev);
1571 int ret;
1572
1573 ret = ican3_send_inquiry(mod, INQUIRY_STATUS);
1574 if (ret)
1575 return ret;
1576
1577 ret = wait_for_completion_timeout(&mod->buserror_comp, HZ);
1578 if (ret <= 0) {
1579 dev_info(mod->dev, "%s timed out\n", __func__);
1580 return -ETIMEDOUT;
1581 }
1582
1583 bec->rxerr = mod->bec.rxerr;
1584 bec->txerr = mod->bec.txerr;
1585 return 0;
1586}
1587
1588/*
1589 * Sysfs Attributes
1590 */
1591
1592static ssize_t ican3_sysfs_show_term(struct device *dev,
1593 struct device_attribute *attr,
1594 char *buf)
1595{
1596 struct ican3_dev *mod = netdev_priv(to_net_dev(dev));
1597 int ret;
1598
1599 ret = ican3_send_inquiry(mod, INQUIRY_TERMINATION);
1600 if (ret)
1601 return ret;
1602
1603 ret = wait_for_completion_timeout(&mod->termination_comp, HZ);
1604 if (ret <= 0) {
1605 dev_info(mod->dev, "%s timed out\n", __func__);
1606 return -ETIMEDOUT;
1607 }
1608
1609 return snprintf(buf, PAGE_SIZE, "%u\n", mod->termination_enabled);
1610}
1611
1612static ssize_t ican3_sysfs_set_term(struct device *dev,
1613 struct device_attribute *attr,
1614 const char *buf, size_t count)
1615{
1616 struct ican3_dev *mod = netdev_priv(to_net_dev(dev));
1617 unsigned long enable;
1618 int ret;
1619
1620 if (strict_strtoul(buf, 0, &enable))
1621 return -EINVAL;
1622
1623 ret = ican3_set_termination(mod, enable);
1624 if (ret)
1625 return ret;
1626
1627 return count;
1628}
1629
1630static DEVICE_ATTR(termination, S_IWUGO | S_IRUGO, ican3_sysfs_show_term,
1631 ican3_sysfs_set_term);
1632
1633static struct attribute *ican3_sysfs_attrs[] = {
1634 &dev_attr_termination.attr,
1635 NULL,
1636};
1637
1638static struct attribute_group ican3_sysfs_attr_group = {
1639 .attrs = ican3_sysfs_attrs,
1640};
1641
1642/*
1643 * PCI Subsystem
1644 */
1645
1646static int __devinit ican3_probe(struct platform_device *pdev)
1647{
1648 struct janz_platform_data *pdata;
1649 struct net_device *ndev;
1650 struct ican3_dev *mod;
1651 struct resource *res;
1652 struct device *dev;
1653 int ret;
1654
1655 pdata = pdev->dev.platform_data;
1656 if (!pdata)
1657 return -ENXIO;
1658
1659 dev_dbg(&pdev->dev, "probe: module number %d\n", pdata->modno);
1660
1661 /* save the struct device for printing */
1662 dev = &pdev->dev;
1663
1664 /* allocate the CAN device and private data */
1665 ndev = alloc_candev(sizeof(*mod), 0);
1666 if (!ndev) {
1667 dev_err(dev, "unable to allocate CANdev\n");
1668 ret = -ENOMEM;
1669 goto out_return;
1670 }
1671
1672 platform_set_drvdata(pdev, ndev);
1673 mod = netdev_priv(ndev);
1674 mod->ndev = ndev;
1675 mod->dev = &pdev->dev;
1676 mod->num = pdata->modno;
1677 netif_napi_add(ndev, &mod->napi, ican3_napi, ICAN3_RX_BUFFERS);
1678 spin_lock_init(&mod->lock);
1679 init_completion(&mod->termination_comp);
1680 init_completion(&mod->buserror_comp);
1681
1682 /* setup device-specific sysfs attributes */
1683 ndev->sysfs_groups[0] = &ican3_sysfs_attr_group;
1684
1685 /* the first unallocated page in the DPM is 9 */
1686 mod->free_page = DPM_FREE_START;
1687
1688 ndev->netdev_ops = &ican3_netdev_ops;
1689 ndev->flags |= IFF_ECHO;
1690 SET_NETDEV_DEV(ndev, &pdev->dev);
1691
1692 mod->can.clock.freq = ICAN3_CAN_CLOCK;
1693 mod->can.bittiming_const = &ican3_bittiming_const;
1694 mod->can.do_set_bittiming = ican3_set_bittiming;
1695 mod->can.do_set_mode = ican3_set_mode;
1696 mod->can.do_get_berr_counter = ican3_get_berr_counter;
1697 mod->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES
1698 | CAN_CTRLMODE_BERR_REPORTING;
1699
1700 /* find our IRQ number */
1701 mod->irq = platform_get_irq(pdev, 0);
1702 if (mod->irq < 0) {
1703 dev_err(dev, "IRQ line not found\n");
1704 ret = -ENODEV;
1705 goto out_free_ndev;
1706 }
1707
1708 ndev->irq = mod->irq;
1709
1710 /* get access to the MODULbus registers for this module */
1711 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1712 if (!res) {
1713 dev_err(dev, "MODULbus registers not found\n");
1714 ret = -ENODEV;
1715 goto out_free_ndev;
1716 }
1717
1718 mod->dpm = ioremap(res->start, resource_size(res));
1719 if (!mod->dpm) {
1720 dev_err(dev, "MODULbus registers not ioremap\n");
1721 ret = -ENOMEM;
1722 goto out_free_ndev;
1723 }
1724
1725 mod->dpmctrl = mod->dpm + DPM_PAGE_SIZE;
1726
1727 /* get access to the control registers for this module */
1728 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1729 if (!res) {
1730 dev_err(dev, "CONTROL registers not found\n");
1731 ret = -ENODEV;
1732 goto out_iounmap_dpm;
1733 }
1734
1735 mod->ctrl = ioremap(res->start, resource_size(res));
1736 if (!mod->ctrl) {
1737 dev_err(dev, "CONTROL registers not ioremap\n");
1738 ret = -ENOMEM;
1739 goto out_iounmap_dpm;
1740 }
1741
1742 /* disable our IRQ, then hookup the IRQ handler */
1743 iowrite8(1 << mod->num, &mod->ctrl->int_disable);
1744 ret = request_irq(mod->irq, ican3_irq, IRQF_SHARED, DRV_NAME, mod);
1745 if (ret) {
1746 dev_err(dev, "unable to request IRQ\n");
1747 goto out_iounmap_ctrl;
1748 }
1749
1750 /* reset and initialize the CAN controller into fast mode */
1751 napi_enable(&mod->napi);
1752 ret = ican3_startup_module(mod);
1753 if (ret) {
1754 dev_err(dev, "%s: unable to start CANdev\n", __func__);
1755 goto out_free_irq;
1756 }
1757
1758 /* register with the Linux CAN layer */
1759 ret = register_candev(ndev);
1760 if (ret) {
1761 dev_err(dev, "%s: unable to register CANdev\n", __func__);
1762 goto out_free_irq;
1763 }
1764
1765 dev_info(dev, "module %d: registered CAN device\n", pdata->modno);
1766 return 0;
1767
1768out_free_irq:
1769 napi_disable(&mod->napi);
1770 iowrite8(1 << mod->num, &mod->ctrl->int_disable);
1771 free_irq(mod->irq, mod);
1772out_iounmap_ctrl:
1773 iounmap(mod->ctrl);
1774out_iounmap_dpm:
1775 iounmap(mod->dpm);
1776out_free_ndev:
1777 free_candev(ndev);
1778out_return:
1779 return ret;
1780}
1781
1782static int __devexit ican3_remove(struct platform_device *pdev)
1783{
1784 struct net_device *ndev = platform_get_drvdata(pdev);
1785 struct ican3_dev *mod = netdev_priv(ndev);
1786
1787 /* unregister the netdevice, stop interrupts */
1788 unregister_netdev(ndev);
1789 napi_disable(&mod->napi);
1790 iowrite8(1 << mod->num, &mod->ctrl->int_disable);
1791 free_irq(mod->irq, mod);
1792
1793 /* put the module into reset */
1794 ican3_shutdown_module(mod);
1795
1796 /* unmap all registers */
1797 iounmap(mod->ctrl);
1798 iounmap(mod->dpm);
1799
1800 free_candev(ndev);
1801
1802 return 0;
1803}
1804
1805static struct platform_driver ican3_driver = {
1806 .driver = {
1807 .name = DRV_NAME,
1808 .owner = THIS_MODULE,
1809 },
1810 .probe = ican3_probe,
1811 .remove = __devexit_p(ican3_remove),
1812};
1813
1814static int __init ican3_init(void)
1815{
1816 return platform_driver_register(&ican3_driver);
1817}
1818
1819static void __exit ican3_exit(void)
1820{
1821 platform_driver_unregister(&ican3_driver);
1822}
1823
1824MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>");
1825MODULE_DESCRIPTION("Janz MODULbus VMOD-ICAN3 Driver");
1826MODULE_LICENSE("GPL");
1827MODULE_ALIAS("platform:janz-ican3");
1828
1829module_init(ican3_init);
1830module_exit(ican3_exit);
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index 225fd147774a..af753936e835 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c
@@ -73,7 +73,7 @@ static u32 __devinit mpc52xx_can_get_clock(struct of_device *ofdev,
73 else 73 else
74 *mscan_clksrc = MSCAN_CLKSRC_XTAL; 74 *mscan_clksrc = MSCAN_CLKSRC_XTAL;
75 75
76 freq = mpc5xxx_get_bus_frequency(ofdev->node); 76 freq = mpc5xxx_get_bus_frequency(ofdev->dev.of_node);
77 if (!freq) 77 if (!freq)
78 return 0; 78 return 0;
79 79
@@ -152,7 +152,7 @@ static u32 __devinit mpc512x_can_get_clock(struct of_device *ofdev,
152 } 152 }
153 153
154 /* Determine the MSCAN device index from the physical address */ 154 /* Determine the MSCAN device index from the physical address */
155 pval = of_get_property(ofdev->node, "reg", &plen); 155 pval = of_get_property(ofdev->dev.of_node, "reg", &plen);
156 BUG_ON(!pval || plen < sizeof(*pval)); 156 BUG_ON(!pval || plen < sizeof(*pval));
157 clockidx = (*pval & 0x80) ? 1 : 0; 157 clockidx = (*pval & 0x80) ? 1 : 0;
158 if (*pval & 0x2000) 158 if (*pval & 0x2000)
@@ -168,11 +168,11 @@ static u32 __devinit mpc512x_can_get_clock(struct of_device *ofdev,
168 */ 168 */
169 if (clock_name && !strcmp(clock_name, "ip")) { 169 if (clock_name && !strcmp(clock_name, "ip")) {
170 *mscan_clksrc = MSCAN_CLKSRC_IPS; 170 *mscan_clksrc = MSCAN_CLKSRC_IPS;
171 freq = mpc5xxx_get_bus_frequency(ofdev->node); 171 freq = mpc5xxx_get_bus_frequency(ofdev->dev.of_node);
172 } else { 172 } else {
173 *mscan_clksrc = MSCAN_CLKSRC_BUS; 173 *mscan_clksrc = MSCAN_CLKSRC_BUS;
174 174
175 pval = of_get_property(ofdev->node, 175 pval = of_get_property(ofdev->dev.of_node,
176 "fsl,mscan-clock-divider", &plen); 176 "fsl,mscan-clock-divider", &plen);
177 if (pval && plen == sizeof(*pval)) 177 if (pval && plen == sizeof(*pval))
178 clockdiv = *pval; 178 clockdiv = *pval;
@@ -251,7 +251,7 @@ static int __devinit mpc5xxx_can_probe(struct of_device *ofdev,
251 const struct of_device_id *id) 251 const struct of_device_id *id)
252{ 252{
253 struct mpc5xxx_can_data *data = (struct mpc5xxx_can_data *)id->data; 253 struct mpc5xxx_can_data *data = (struct mpc5xxx_can_data *)id->data;
254 struct device_node *np = ofdev->node; 254 struct device_node *np = ofdev->dev.of_node;
255 struct net_device *dev; 255 struct net_device *dev;
256 struct mscan_priv *priv; 256 struct mscan_priv *priv;
257 void __iomem *base; 257 void __iomem *base;
@@ -392,15 +392,17 @@ static struct of_device_id __devinitdata mpc5xxx_can_table[] = {
392}; 392};
393 393
394static struct of_platform_driver mpc5xxx_can_driver = { 394static struct of_platform_driver mpc5xxx_can_driver = {
395 .owner = THIS_MODULE, 395 .driver = {
396 .name = "mpc5xxx_can", 396 .name = "mpc5xxx_can",
397 .owner = THIS_MODULE,
398 .of_match_table = mpc5xxx_can_table,
399 },
397 .probe = mpc5xxx_can_probe, 400 .probe = mpc5xxx_can_probe,
398 .remove = __devexit_p(mpc5xxx_can_remove), 401 .remove = __devexit_p(mpc5xxx_can_remove),
399#ifdef CONFIG_PM 402#ifdef CONFIG_PM
400 .suspend = mpc5xxx_can_suspend, 403 .suspend = mpc5xxx_can_suspend,
401 .resume = mpc5xxx_can_resume, 404 .resume = mpc5xxx_can_resume,
402#endif 405#endif
403 .match_table = mpc5xxx_can_table,
404}; 406};
405 407
406static int __init mpc5xxx_can_init(void) 408static int __init mpc5xxx_can_init(void)
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 85f7cbfe8e5f..0a8de01d52f7 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -599,6 +599,8 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
599 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | 599 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
600 CAN_CTRLMODE_BERR_REPORTING; 600 CAN_CTRLMODE_BERR_REPORTING;
601 601
602 spin_lock_init(&priv->cmdreg_lock);
603
602 if (sizeof_priv) 604 if (sizeof_priv)
603 priv->priv = (void *)priv + sizeof(struct sja1000_priv); 605 priv->priv = (void *)priv + sizeof(struct sja1000_priv);
604 606
diff --git a/drivers/net/can/sja1000/sja1000_of_platform.c b/drivers/net/can/sja1000/sja1000_of_platform.c
index 34e79efbd2fc..ac1a83d7c204 100644
--- a/drivers/net/can/sja1000/sja1000_of_platform.c
+++ b/drivers/net/can/sja1000/sja1000_of_platform.c
@@ -71,7 +71,7 @@ static int __devexit sja1000_ofp_remove(struct of_device *ofdev)
71{ 71{
72 struct net_device *dev = dev_get_drvdata(&ofdev->dev); 72 struct net_device *dev = dev_get_drvdata(&ofdev->dev);
73 struct sja1000_priv *priv = netdev_priv(dev); 73 struct sja1000_priv *priv = netdev_priv(dev);
74 struct device_node *np = ofdev->node; 74 struct device_node *np = ofdev->dev.of_node;
75 struct resource res; 75 struct resource res;
76 76
77 dev_set_drvdata(&ofdev->dev, NULL); 77 dev_set_drvdata(&ofdev->dev, NULL);
@@ -90,7 +90,7 @@ static int __devexit sja1000_ofp_remove(struct of_device *ofdev)
90static int __devinit sja1000_ofp_probe(struct of_device *ofdev, 90static int __devinit sja1000_ofp_probe(struct of_device *ofdev,
91 const struct of_device_id *id) 91 const struct of_device_id *id)
92{ 92{
93 struct device_node *np = ofdev->node; 93 struct device_node *np = ofdev->dev.of_node;
94 struct net_device *dev; 94 struct net_device *dev;
95 struct sja1000_priv *priv; 95 struct sja1000_priv *priv;
96 struct resource res; 96 struct resource res;
@@ -215,11 +215,13 @@ static struct of_device_id __devinitdata sja1000_ofp_table[] = {
215MODULE_DEVICE_TABLE(of, sja1000_ofp_table); 215MODULE_DEVICE_TABLE(of, sja1000_ofp_table);
216 216
217static struct of_platform_driver sja1000_ofp_driver = { 217static struct of_platform_driver sja1000_ofp_driver = {
218 .owner = THIS_MODULE, 218 .driver = {
219 .name = DRV_NAME, 219 .owner = THIS_MODULE,
220 .name = DRV_NAME,
221 .of_match_table = sja1000_ofp_table,
222 },
220 .probe = sja1000_ofp_probe, 223 .probe = sja1000_ofp_probe,
221 .remove = __devexit_p(sja1000_ofp_remove), 224 .remove = __devexit_p(sja1000_ofp_remove),
222 .match_table = sja1000_ofp_table,
223}; 225};
224 226
225static int __init sja1000_ofp_init(void) 227static int __init sja1000_ofp_init(void)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index be90d3598bca..fe925663d39a 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -3367,13 +3367,9 @@ static int cnic_cm_shutdown(struct cnic_dev *dev)
3367 3367
3368static void cnic_init_context(struct cnic_dev *dev, u32 cid) 3368static void cnic_init_context(struct cnic_dev *dev, u32 cid)
3369{ 3369{
3370 struct cnic_local *cp = dev->cnic_priv;
3371 u32 cid_addr; 3370 u32 cid_addr;
3372 int i; 3371 int i;
3373 3372
3374 if (CHIP_NUM(cp) == CHIP_NUM_5709)
3375 return;
3376
3377 cid_addr = GET_CID_ADDR(cid); 3373 cid_addr = GET_CID_ADDR(cid);
3378 3374
3379 for (i = 0; i < CTX_SIZE; i += 4) 3375 for (i = 0; i < CTX_SIZE; i += 4)
@@ -3530,14 +3526,11 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev)
3530 3526
3531 sb_id = cp->status_blk_num; 3527 sb_id = cp->status_blk_num;
3532 tx_cid = 20; 3528 tx_cid = 20;
3533 cnic_init_context(dev, tx_cid);
3534 cnic_init_context(dev, tx_cid + 1);
3535 cp->tx_cons_ptr = &s_blk->status_tx_quick_consumer_index2; 3529 cp->tx_cons_ptr = &s_blk->status_tx_quick_consumer_index2;
3536 if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) { 3530 if (ethdev->drv_state & CNIC_DRV_STATE_USING_MSIX) {
3537 struct status_block_msix *sblk = cp->status_blk.bnx2; 3531 struct status_block_msix *sblk = cp->status_blk.bnx2;
3538 3532
3539 tx_cid = TX_TSS_CID + sb_id - 1; 3533 tx_cid = TX_TSS_CID + sb_id - 1;
3540 cnic_init_context(dev, tx_cid);
3541 CNIC_WR(dev, BNX2_TSCH_TSS_CFG, (sb_id << 24) | 3534 CNIC_WR(dev, BNX2_TSCH_TSS_CFG, (sb_id << 24) |
3542 (TX_TSS_CID << 7)); 3535 (TX_TSS_CID << 7));
3543 cp->tx_cons_ptr = &sblk->status_tx_quick_consumer_index; 3536 cp->tx_cons_ptr = &sblk->status_tx_quick_consumer_index;
@@ -3556,6 +3549,9 @@ static void cnic_init_bnx2_tx_ring(struct cnic_dev *dev)
3556 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI_XI; 3549 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI_XI;
3557 offset3 = BNX2_L2CTX_TBDR_BHADDR_LO_XI; 3550 offset3 = BNX2_L2CTX_TBDR_BHADDR_LO_XI;
3558 } else { 3551 } else {
3552 cnic_init_context(dev, tx_cid);
3553 cnic_init_context(dev, tx_cid + 1);
3554
3559 offset0 = BNX2_L2CTX_TYPE; 3555 offset0 = BNX2_L2CTX_TYPE;
3560 offset1 = BNX2_L2CTX_CMD_TYPE; 3556 offset1 = BNX2_L2CTX_CMD_TYPE;
3561 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI; 3557 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI;
diff --git a/drivers/net/cnic_if.h b/drivers/net/cnic_if.h
index 110c62072e6f..0c55177db046 100644
--- a/drivers/net/cnic_if.h
+++ b/drivers/net/cnic_if.h
@@ -12,8 +12,8 @@
12#ifndef CNIC_IF_H 12#ifndef CNIC_IF_H
13#define CNIC_IF_H 13#define CNIC_IF_H
14 14
15#define CNIC_MODULE_VERSION "2.1.1" 15#define CNIC_MODULE_VERSION "2.1.2"
16#define CNIC_MODULE_RELDATE "Feb 22, 2010" 16#define CNIC_MODULE_RELDATE "May 26, 2010"
17 17
18#define CNIC_ULP_RDMA 0 18#define CNIC_ULP_RDMA 0
19#define CNIC_ULP_ISCSI 1 19#define CNIC_ULP_ISCSI 1
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 24507f3b8b17..57a7e41da69e 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2554,7 +2554,7 @@ static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
2554 mdef = er32(MDEF(i)); 2554 mdef = er32(MDEF(i));
2555 2555
2556 /* Ignore filters with anything other than IPMI ports */ 2556 /* Ignore filters with anything other than IPMI ports */
2557 if (mdef & !(E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664)) 2557 if (mdef & ~(E1000_MDEF_PORT_623 | E1000_MDEF_PORT_664))
2558 continue; 2558 continue;
2559 2559
2560 /* Enable this decision filter in MANC2H */ 2560 /* Enable this decision filter in MANC2H */
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 02698a1c80b0..f547894ff48f 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -122,8 +122,11 @@ static struct of_device_id ehea_device_table[] = {
122MODULE_DEVICE_TABLE(of, ehea_device_table); 122MODULE_DEVICE_TABLE(of, ehea_device_table);
123 123
124static struct of_platform_driver ehea_driver = { 124static struct of_platform_driver ehea_driver = {
125 .name = "ehea", 125 .driver = {
126 .match_table = ehea_device_table, 126 .name = "ehea",
127 .owner = THIS_MODULE,
128 .of_match_table = ehea_device_table,
129 },
127 .probe = ehea_probe_adapter, 130 .probe = ehea_probe_adapter,
128 .remove = ehea_remove, 131 .remove = ehea_remove,
129}; 132};
@@ -3050,7 +3053,7 @@ static DEVICE_ATTR(log_port_id, S_IRUSR | S_IRGRP | S_IROTH, ehea_show_port_id,
3050static void __devinit logical_port_release(struct device *dev) 3053static void __devinit logical_port_release(struct device *dev)
3051{ 3054{
3052 struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev); 3055 struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev);
3053 of_node_put(port->ofdev.node); 3056 of_node_put(port->ofdev.dev.of_node);
3054} 3057}
3055 3058
3056static struct device *ehea_register_port(struct ehea_port *port, 3059static struct device *ehea_register_port(struct ehea_port *port,
@@ -3058,7 +3061,7 @@ static struct device *ehea_register_port(struct ehea_port *port,
3058{ 3061{
3059 int ret; 3062 int ret;
3060 3063
3061 port->ofdev.node = of_node_get(dn); 3064 port->ofdev.dev.of_node = of_node_get(dn);
3062 port->ofdev.dev.parent = &port->adapter->ofdev->dev; 3065 port->ofdev.dev.parent = &port->adapter->ofdev->dev;
3063 port->ofdev.dev.bus = &ibmebus_bus_type; 3066 port->ofdev.dev.bus = &ibmebus_bus_type;
3064 3067
@@ -3225,7 +3228,7 @@ static int ehea_setup_ports(struct ehea_adapter *adapter)
3225 const u32 *dn_log_port_id; 3228 const u32 *dn_log_port_id;
3226 int i = 0; 3229 int i = 0;
3227 3230
3228 lhea_dn = adapter->ofdev->node; 3231 lhea_dn = adapter->ofdev->dev.of_node;
3229 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { 3232 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) {
3230 3233
3231 dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", 3234 dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no",
@@ -3264,7 +3267,7 @@ static struct device_node *ehea_get_eth_dn(struct ehea_adapter *adapter,
3264 struct device_node *eth_dn = NULL; 3267 struct device_node *eth_dn = NULL;
3265 const u32 *dn_log_port_id; 3268 const u32 *dn_log_port_id;
3266 3269
3267 lhea_dn = adapter->ofdev->node; 3270 lhea_dn = adapter->ofdev->dev.of_node;
3268 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) { 3271 while ((eth_dn = of_get_next_child(lhea_dn, eth_dn))) {
3269 3272
3270 dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no", 3273 dn_log_port_id = of_get_property(eth_dn, "ibm,hea-port-no",
@@ -3394,7 +3397,7 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
3394 const u64 *adapter_handle; 3397 const u64 *adapter_handle;
3395 int ret; 3398 int ret;
3396 3399
3397 if (!dev || !dev->node) { 3400 if (!dev || !dev->dev.of_node) {
3398 ehea_error("Invalid ibmebus device probed"); 3401 ehea_error("Invalid ibmebus device probed");
3399 return -EINVAL; 3402 return -EINVAL;
3400 } 3403 }
@@ -3410,14 +3413,14 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
3410 3413
3411 adapter->ofdev = dev; 3414 adapter->ofdev = dev;
3412 3415
3413 adapter_handle = of_get_property(dev->node, "ibm,hea-handle", 3416 adapter_handle = of_get_property(dev->dev.of_node, "ibm,hea-handle",
3414 NULL); 3417 NULL);
3415 if (adapter_handle) 3418 if (adapter_handle)
3416 adapter->handle = *adapter_handle; 3419 adapter->handle = *adapter_handle;
3417 3420
3418 if (!adapter->handle) { 3421 if (!adapter->handle) {
3419 dev_err(&dev->dev, "failed getting handle for adapter" 3422 dev_err(&dev->dev, "failed getting handle for adapter"
3420 " '%s'\n", dev->node->full_name); 3423 " '%s'\n", dev->dev.of_node->full_name);
3421 ret = -ENODEV; 3424 ret = -ENODEV;
3422 goto out_free_ad; 3425 goto out_free_ad;
3423 } 3426 }
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 85f2a2e7030a..45e86d1e5b1b 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -74,7 +74,14 @@ struct enic_msix_entry {
74 void *devid; 74 void *devid;
75}; 75};
76 76
77#define ENIC_SET_APPLIED (1 << 0)
78#define ENIC_SET_REQUEST (1 << 1)
79#define ENIC_SET_NAME (1 << 2)
80#define ENIC_SET_INSTANCE (1 << 3)
81#define ENIC_SET_HOST (1 << 4)
82
77struct enic_port_profile { 83struct enic_port_profile {
84 u32 set;
78 u8 request; 85 u8 request;
79 char name[PORT_PROFILE_MAX]; 86 char name[PORT_PROFILE_MAX];
80 u8 instance_uuid[PORT_UUID_MAX]; 87 u8 instance_uuid[PORT_UUID_MAX];
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index e125113759a5..bc7d6b96de3d 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1029,127 +1029,133 @@ static int enic_dev_init_done(struct enic *enic, int *done, int *error)
1029 return err; 1029 return err;
1030} 1030}
1031 1031
1032static int enic_set_port_profile(struct enic *enic, u8 request, u8 *mac, 1032static int enic_set_port_profile(struct enic *enic, u8 *mac)
1033 char *name, u8 *instance_uuid, u8 *host_uuid)
1034{ 1033{
1035 struct vic_provinfo *vp; 1034 struct vic_provinfo *vp;
1036 u8 oui[3] = VIC_PROVINFO_CISCO_OUI; 1035 u8 oui[3] = VIC_PROVINFO_CISCO_OUI;
1037 unsigned short *uuid; 1036 u8 *uuid;
1038 char uuid_str[38]; 1037 char uuid_str[38];
1039 static char *uuid_fmt = "%04X%04X-%04X-%04X-%04X-%04X%04X%04X"; 1038 static char *uuid_fmt = "%02X%02X%02X%02X-%02X%02X-%02X%02X-"
1039 "%02X%02X-%02X%02X%02X%02X%0X%02X";
1040 int err; 1040 int err;
1041 1041
1042 if (!name) 1042 err = enic_vnic_dev_deinit(enic);
1043 return -EINVAL; 1043 if (err)
1044 return err;
1044 1045
1045 if (!is_valid_ether_addr(mac)) 1046 switch (enic->pp.request) {
1046 return -EADDRNOTAVAIL;
1047 1047
1048 vp = vic_provinfo_alloc(GFP_KERNEL, oui, VIC_PROVINFO_LINUX_TYPE); 1048 case PORT_REQUEST_ASSOCIATE:
1049 if (!vp)
1050 return -ENOMEM;
1051 1049
1052 vic_provinfo_add_tlv(vp, 1050 if (!(enic->pp.set & ENIC_SET_NAME) || !strlen(enic->pp.name))
1053 VIC_LINUX_PROV_TLV_PORT_PROFILE_NAME_STR, 1051 return -EINVAL;
1054 strlen(name) + 1, name);
1055 1052
1056 vic_provinfo_add_tlv(vp, 1053 if (!is_valid_ether_addr(mac))
1057 VIC_LINUX_PROV_TLV_CLIENT_MAC_ADDR, 1054 return -EADDRNOTAVAIL;
1058 ETH_ALEN, mac);
1059 1055
1060 if (instance_uuid) { 1056 vp = vic_provinfo_alloc(GFP_KERNEL, oui,
1061 uuid = (unsigned short *)instance_uuid; 1057 VIC_PROVINFO_LINUX_TYPE);
1062 sprintf(uuid_str, uuid_fmt, 1058 if (!vp)
1063 uuid[0], uuid[1], uuid[2], uuid[3], 1059 return -ENOMEM;
1064 uuid[4], uuid[5], uuid[6], uuid[7]);
1065 vic_provinfo_add_tlv(vp,
1066 VIC_LINUX_PROV_TLV_CLIENT_UUID_STR,
1067 sizeof(uuid_str), uuid_str);
1068 }
1069 1060
1070 if (host_uuid) {
1071 uuid = (unsigned short *)host_uuid;
1072 sprintf(uuid_str, uuid_fmt,
1073 uuid[0], uuid[1], uuid[2], uuid[3],
1074 uuid[4], uuid[5], uuid[6], uuid[7]);
1075 vic_provinfo_add_tlv(vp, 1061 vic_provinfo_add_tlv(vp,
1076 VIC_LINUX_PROV_TLV_HOST_UUID_STR, 1062 VIC_LINUX_PROV_TLV_PORT_PROFILE_NAME_STR,
1077 sizeof(uuid_str), uuid_str); 1063 strlen(enic->pp.name) + 1, enic->pp.name);
1078 }
1079 1064
1080 err = enic_vnic_dev_deinit(enic); 1065 vic_provinfo_add_tlv(vp,
1081 if (err) 1066 VIC_LINUX_PROV_TLV_CLIENT_MAC_ADDR,
1082 goto err_out; 1067 ETH_ALEN, mac);
1083 1068
1084 memset(&enic->pp, 0, sizeof(enic->pp)); 1069 if (enic->pp.set & ENIC_SET_INSTANCE) {
1070 uuid = enic->pp.instance_uuid;
1071 sprintf(uuid_str, uuid_fmt,
1072 uuid[0], uuid[1], uuid[2], uuid[3],
1073 uuid[4], uuid[5], uuid[6], uuid[7],
1074 uuid[8], uuid[9], uuid[10], uuid[11],
1075 uuid[12], uuid[13], uuid[14], uuid[15]);
1076 vic_provinfo_add_tlv(vp,
1077 VIC_LINUX_PROV_TLV_CLIENT_UUID_STR,
1078 sizeof(uuid_str), uuid_str);
1079 }
1085 1080
1086 err = enic_dev_init_prov(enic, vp); 1081 if (enic->pp.set & ENIC_SET_HOST) {
1087 if (err) 1082 uuid = enic->pp.host_uuid;
1088 goto err_out; 1083 sprintf(uuid_str, uuid_fmt,
1084 uuid[0], uuid[1], uuid[2], uuid[3],
1085 uuid[4], uuid[5], uuid[6], uuid[7],
1086 uuid[8], uuid[9], uuid[10], uuid[11],
1087 uuid[12], uuid[13], uuid[14], uuid[15]);
1088 vic_provinfo_add_tlv(vp,
1089 VIC_LINUX_PROV_TLV_HOST_UUID_STR,
1090 sizeof(uuid_str), uuid_str);
1091 }
1089 1092
1090 enic->pp.request = request; 1093 err = enic_dev_init_prov(enic, vp);
1091 memcpy(enic->pp.name, name, PORT_PROFILE_MAX); 1094 vic_provinfo_free(vp);
1092 if (instance_uuid) 1095 if (err)
1093 memcpy(enic->pp.instance_uuid, 1096 return err;
1094 instance_uuid, PORT_UUID_MAX); 1097 break;
1095 if (host_uuid)
1096 memcpy(enic->pp.host_uuid,
1097 host_uuid, PORT_UUID_MAX);
1098 1098
1099err_out: 1099 case PORT_REQUEST_DISASSOCIATE:
1100 vic_provinfo_free(vp); 1100 break;
1101 1101
1102 return err; 1102 default:
1103} 1103 return -EINVAL;
1104 }
1104 1105
1105static int enic_unset_port_profile(struct enic *enic) 1106 enic->pp.set |= ENIC_SET_APPLIED;
1106{ 1107 return 0;
1107 memset(&enic->pp, 0, sizeof(enic->pp));
1108 return enic_vnic_dev_deinit(enic);
1109} 1108}
1110 1109
1111static int enic_set_vf_port(struct net_device *netdev, int vf, 1110static int enic_set_vf_port(struct net_device *netdev, int vf,
1112 struct nlattr *port[]) 1111 struct nlattr *port[])
1113{ 1112{
1114 struct enic *enic = netdev_priv(netdev); 1113 struct enic *enic = netdev_priv(netdev);
1115 char *name = NULL;
1116 u8 *instance_uuid = NULL;
1117 u8 *host_uuid = NULL;
1118 u8 request = PORT_REQUEST_DISASSOCIATE;
1119 1114
1120 /* don't support VFs, yet */ 1115 memset(&enic->pp, 0, sizeof(enic->pp));
1121 if (vf != PORT_SELF_VF)
1122 return -EOPNOTSUPP;
1123 1116
1124 if (port[IFLA_PORT_REQUEST]) 1117 if (port[IFLA_PORT_REQUEST]) {
1125 request = nla_get_u8(port[IFLA_PORT_REQUEST]); 1118 enic->pp.set |= ENIC_SET_REQUEST;
1119 enic->pp.request = nla_get_u8(port[IFLA_PORT_REQUEST]);
1120 }
1126 1121
1127 switch (request) { 1122 if (port[IFLA_PORT_PROFILE]) {
1128 case PORT_REQUEST_ASSOCIATE: 1123 enic->pp.set |= ENIC_SET_NAME;
1124 memcpy(enic->pp.name, nla_data(port[IFLA_PORT_PROFILE]),
1125 PORT_PROFILE_MAX);
1126 }
1129 1127
1130 if (port[IFLA_PORT_PROFILE]) 1128 if (port[IFLA_PORT_INSTANCE_UUID]) {
1131 name = nla_data(port[IFLA_PORT_PROFILE]); 1129 enic->pp.set |= ENIC_SET_INSTANCE;
1130 memcpy(enic->pp.instance_uuid,
1131 nla_data(port[IFLA_PORT_INSTANCE_UUID]), PORT_UUID_MAX);
1132 }
1132 1133
1133 if (port[IFLA_PORT_INSTANCE_UUID]) 1134 if (port[IFLA_PORT_HOST_UUID]) {
1134 instance_uuid = 1135 enic->pp.set |= ENIC_SET_HOST;
1135 nla_data(port[IFLA_PORT_INSTANCE_UUID]); 1136 memcpy(enic->pp.host_uuid,
1137 nla_data(port[IFLA_PORT_HOST_UUID]), PORT_UUID_MAX);
1138 }
1136 1139
1137 if (port[IFLA_PORT_HOST_UUID]) 1140 /* don't support VFs, yet */
1138 host_uuid = nla_data(port[IFLA_PORT_HOST_UUID]); 1141 if (vf != PORT_SELF_VF)
1142 return -EOPNOTSUPP;
1139 1143
1140 return enic_set_port_profile(enic, request, 1144 if (!(enic->pp.set & ENIC_SET_REQUEST))
1141 netdev->dev_addr, name, 1145 return -EOPNOTSUPP;
1142 instance_uuid, host_uuid);
1143 1146
1144 case PORT_REQUEST_DISASSOCIATE: 1147 if (enic->pp.request == PORT_REQUEST_ASSOCIATE) {
1145 1148
1146 return enic_unset_port_profile(enic); 1149 /* If the interface mac addr hasn't been assigned,
1150 * assign a random mac addr before setting port-
1151 * profile.
1152 */
1147 1153
1148 default: 1154 if (is_zero_ether_addr(netdev->dev_addr))
1149 break; 1155 random_ether_addr(netdev->dev_addr);
1150 } 1156 }
1151 1157
1152 return -EOPNOTSUPP; 1158 return enic_set_port_profile(enic, netdev->dev_addr);
1153} 1159}
1154 1160
1155static int enic_get_vf_port(struct net_device *netdev, int vf, 1161static int enic_get_vf_port(struct net_device *netdev, int vf,
@@ -1159,14 +1165,12 @@ static int enic_get_vf_port(struct net_device *netdev, int vf,
1159 int err, error, done; 1165 int err, error, done;
1160 u16 response = PORT_PROFILE_RESPONSE_SUCCESS; 1166 u16 response = PORT_PROFILE_RESPONSE_SUCCESS;
1161 1167
1162 /* don't support VFs, yet */ 1168 if (!(enic->pp.set & ENIC_SET_APPLIED))
1163 if (vf != PORT_SELF_VF) 1169 return -ENODATA;
1164 return -EOPNOTSUPP;
1165 1170
1166 err = enic_dev_init_done(enic, &done, &error); 1171 err = enic_dev_init_done(enic, &done, &error);
1167
1168 if (err) 1172 if (err)
1169 return err; 1173 error = err;
1170 1174
1171 switch (error) { 1175 switch (error) {
1172 case ERR_SUCCESS: 1176 case ERR_SUCCESS:
@@ -1189,12 +1193,15 @@ static int enic_get_vf_port(struct net_device *netdev, int vf,
1189 1193
1190 NLA_PUT_U16(skb, IFLA_PORT_REQUEST, enic->pp.request); 1194 NLA_PUT_U16(skb, IFLA_PORT_REQUEST, enic->pp.request);
1191 NLA_PUT_U16(skb, IFLA_PORT_RESPONSE, response); 1195 NLA_PUT_U16(skb, IFLA_PORT_RESPONSE, response);
1192 NLA_PUT(skb, IFLA_PORT_PROFILE, PORT_PROFILE_MAX, 1196 if (enic->pp.set & ENIC_SET_NAME)
1193 enic->pp.name); 1197 NLA_PUT(skb, IFLA_PORT_PROFILE, PORT_PROFILE_MAX,
1194 NLA_PUT(skb, IFLA_PORT_INSTANCE_UUID, PORT_UUID_MAX, 1198 enic->pp.name);
1195 enic->pp.instance_uuid); 1199 if (enic->pp.set & ENIC_SET_INSTANCE)
1196 NLA_PUT(skb, IFLA_PORT_HOST_UUID, PORT_UUID_MAX, 1200 NLA_PUT(skb, IFLA_PORT_INSTANCE_UUID, PORT_UUID_MAX,
1197 enic->pp.host_uuid); 1201 enic->pp.instance_uuid);
1202 if (enic->pp.set & ENIC_SET_HOST)
1203 NLA_PUT(skb, IFLA_PORT_HOST_UUID, PORT_UUID_MAX,
1204 enic->pp.host_uuid);
1198 1205
1199 return 0; 1206 return 0;
1200 1207
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 6838dfc9ef23..4c274657283c 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -87,6 +87,7 @@ static int rx_copybreak;
87#include <linux/bitops.h> 87#include <linux/bitops.h>
88#include <asm/io.h> 88#include <asm/io.h>
89#include <asm/uaccess.h> 89#include <asm/uaccess.h>
90#include <asm/byteorder.h>
90 91
91/* These identify the driver base version and may not be removed. */ 92/* These identify the driver base version and may not be removed. */
92static char version[] __devinitdata = 93static char version[] __devinitdata =
@@ -230,7 +231,7 @@ static const u16 media2miictl[16] = {
230 * The EPIC100 Rx and Tx buffer descriptors. Note that these 231 * The EPIC100 Rx and Tx buffer descriptors. Note that these
231 * really ARE host-endian; it's not a misannotation. We tell 232 * really ARE host-endian; it's not a misannotation. We tell
232 * the card to byteswap them internally on big-endian hosts - 233 * the card to byteswap them internally on big-endian hosts -
233 * look for #ifdef CONFIG_BIG_ENDIAN in epic_open(). 234 * look for #ifdef __BIG_ENDIAN in epic_open().
234 */ 235 */
235 236
236struct epic_tx_desc { 237struct epic_tx_desc {
@@ -690,7 +691,7 @@ static int epic_open(struct net_device *dev)
690 outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL); 691 outl((inl(ioaddr + NVCTL) & ~0x003C) | 0x4800, ioaddr + NVCTL);
691 692
692 /* Tell the chip to byteswap descriptors on big-endian hosts */ 693 /* Tell the chip to byteswap descriptors on big-endian hosts */
693#ifdef CONFIG_BIG_ENDIAN 694#ifdef __BIG_ENDIAN
694 outl(0x4432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); 695 outl(0x4432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL);
695 inl(ioaddr + GENCTL); 696 inl(ioaddr + GENCTL);
696 outl(0x0432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); 697 outl(0x0432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL);
@@ -806,7 +807,7 @@ static void epic_restart(struct net_device *dev)
806 for (i = 16; i > 0; i--) 807 for (i = 16; i > 0; i--)
807 outl(0x0008, ioaddr + TEST1); 808 outl(0x0008, ioaddr + TEST1);
808 809
809#ifdef CONFIG_BIG_ENDIAN 810#ifdef __BIG_ENDIAN
810 outl(0x0432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); 811 outl(0x0432 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL);
811#else 812#else
812 outl(0x0412 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL); 813 outl(0x0412 | (RX_FIFO_THRESH<<8), ioaddr + GENCTL);
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 14cbde5cf68e..6ed2df14ec84 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -174,6 +174,7 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
174 * @iobase: pointer to I/O memory region 174 * @iobase: pointer to I/O memory region
175 * @membase: pointer to buffer memory region 175 * @membase: pointer to buffer memory region
176 * @dma_alloc: dma allocated buffer size 176 * @dma_alloc: dma allocated buffer size
177 * @io_region_size: I/O memory region size
177 * @num_tx: number of send buffers 178 * @num_tx: number of send buffers
178 * @cur_tx: last send buffer written 179 * @cur_tx: last send buffer written
179 * @dty_tx: last buffer actually sent 180 * @dty_tx: last buffer actually sent
@@ -193,6 +194,7 @@ struct ethoc {
193 void __iomem *iobase; 194 void __iomem *iobase;
194 void __iomem *membase; 195 void __iomem *membase;
195 int dma_alloc; 196 int dma_alloc;
197 resource_size_t io_region_size;
196 198
197 unsigned int num_tx; 199 unsigned int num_tx;
198 unsigned int cur_tx; 200 unsigned int cur_tx;
@@ -943,6 +945,7 @@ static int ethoc_probe(struct platform_device *pdev)
943 priv = netdev_priv(netdev); 945 priv = netdev_priv(netdev);
944 priv->netdev = netdev; 946 priv->netdev = netdev;
945 priv->dma_alloc = 0; 947 priv->dma_alloc = 0;
948 priv->io_region_size = mmio->end - mmio->start + 1;
946 949
947 priv->iobase = devm_ioremap_nocache(&pdev->dev, netdev->base_addr, 950 priv->iobase = devm_ioremap_nocache(&pdev->dev, netdev->base_addr,
948 resource_size(mmio)); 951 resource_size(mmio));
@@ -1047,20 +1050,34 @@ static int ethoc_probe(struct platform_device *pdev)
1047 ret = register_netdev(netdev); 1050 ret = register_netdev(netdev);
1048 if (ret < 0) { 1051 if (ret < 0) {
1049 dev_err(&netdev->dev, "failed to register interface\n"); 1052 dev_err(&netdev->dev, "failed to register interface\n");
1050 goto error; 1053 goto error2;
1051 } 1054 }
1052 1055
1053 goto out; 1056 goto out;
1054 1057
1058error2:
1059 netif_napi_del(&priv->napi);
1055error: 1060error:
1056 mdiobus_unregister(priv->mdio); 1061 mdiobus_unregister(priv->mdio);
1057free_mdio: 1062free_mdio:
1058 kfree(priv->mdio->irq); 1063 kfree(priv->mdio->irq);
1059 mdiobus_free(priv->mdio); 1064 mdiobus_free(priv->mdio);
1060free: 1065free:
1061 if (priv->dma_alloc) 1066 if (priv) {
1062 dma_free_coherent(NULL, priv->dma_alloc, priv->membase, 1067 if (priv->dma_alloc)
1063 netdev->mem_start); 1068 dma_free_coherent(NULL, priv->dma_alloc, priv->membase,
1069 netdev->mem_start);
1070 else if (priv->membase)
1071 devm_iounmap(&pdev->dev, priv->membase);
1072 if (priv->iobase)
1073 devm_iounmap(&pdev->dev, priv->iobase);
1074 }
1075 if (mem)
1076 devm_release_mem_region(&pdev->dev, mem->start,
1077 mem->end - mem->start + 1);
1078 if (mmio)
1079 devm_release_mem_region(&pdev->dev, mmio->start,
1080 mmio->end - mmio->start + 1);
1064 free_netdev(netdev); 1081 free_netdev(netdev);
1065out: 1082out:
1066 return ret; 1083 return ret;
@@ -1078,6 +1095,7 @@ static int ethoc_remove(struct platform_device *pdev)
1078 platform_set_drvdata(pdev, NULL); 1095 platform_set_drvdata(pdev, NULL);
1079 1096
1080 if (netdev) { 1097 if (netdev) {
1098 netif_napi_del(&priv->napi);
1081 phy_disconnect(priv->phy); 1099 phy_disconnect(priv->phy);
1082 priv->phy = NULL; 1100 priv->phy = NULL;
1083 1101
@@ -1089,6 +1107,14 @@ static int ethoc_remove(struct platform_device *pdev)
1089 if (priv->dma_alloc) 1107 if (priv->dma_alloc)
1090 dma_free_coherent(NULL, priv->dma_alloc, priv->membase, 1108 dma_free_coherent(NULL, priv->dma_alloc, priv->membase,
1091 netdev->mem_start); 1109 netdev->mem_start);
1110 else {
1111 devm_iounmap(&pdev->dev, priv->membase);
1112 devm_release_mem_region(&pdev->dev, netdev->mem_start,
1113 netdev->mem_end - netdev->mem_start + 1);
1114 }
1115 devm_iounmap(&pdev->dev, priv->iobase);
1116 devm_release_mem_region(&pdev->dev, netdev->base_addr,
1117 priv->io_region_size);
1092 unregister_netdev(netdev); 1118 unregister_netdev(netdev);
1093 free_netdev(netdev); 1119 free_netdev(netdev);
1094 } 1120 }
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 42d9ac9ba395..edfff92a6d8e 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -41,6 +41,7 @@
41#include <linux/clk.h> 41#include <linux/clk.h>
42#include <linux/platform_device.h> 42#include <linux/platform_device.h>
43#include <linux/phy.h> 43#include <linux/phy.h>
44#include <linux/fec.h>
44 45
45#include <asm/cacheflush.h> 46#include <asm/cacheflush.h>
46 47
@@ -182,6 +183,7 @@ struct fec_enet_private {
182 struct phy_device *phy_dev; 183 struct phy_device *phy_dev;
183 int mii_timeout; 184 int mii_timeout;
184 uint phy_speed; 185 uint phy_speed;
186 phy_interface_t phy_interface;
185 int index; 187 int index;
186 int link; 188 int link;
187 int full_duplex; 189 int full_duplex;
@@ -679,6 +681,8 @@ static int fec_enet_mii_probe(struct net_device *dev)
679 struct phy_device *phy_dev = NULL; 681 struct phy_device *phy_dev = NULL;
680 int phy_addr; 682 int phy_addr;
681 683
684 fep->phy_dev = NULL;
685
682 /* find the first phy */ 686 /* find the first phy */
683 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { 687 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
684 if (fep->mii_bus->phy_map[phy_addr]) { 688 if (fep->mii_bus->phy_map[phy_addr]) {
@@ -709,6 +713,11 @@ static int fec_enet_mii_probe(struct net_device *dev)
709 fep->link = 0; 713 fep->link = 0;
710 fep->full_duplex = 0; 714 fep->full_duplex = 0;
711 715
716 printk(KERN_INFO "%s: Freescale FEC PHY driver [%s] "
717 "(mii_bus:phy_addr=%s, irq=%d)\n", dev->name,
718 fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev),
719 fep->phy_dev->irq);
720
712 return 0; 721 return 0;
713} 722}
714 723
@@ -754,13 +763,8 @@ static int fec_enet_mii_init(struct platform_device *pdev)
754 if (mdiobus_register(fep->mii_bus)) 763 if (mdiobus_register(fep->mii_bus))
755 goto err_out_free_mdio_irq; 764 goto err_out_free_mdio_irq;
756 765
757 if (fec_enet_mii_probe(dev) != 0)
758 goto err_out_unregister_bus;
759
760 return 0; 766 return 0;
761 767
762err_out_unregister_bus:
763 mdiobus_unregister(fep->mii_bus);
764err_out_free_mdio_irq: 768err_out_free_mdio_irq:
765 kfree(fep->mii_bus->irq); 769 kfree(fep->mii_bus->irq);
766err_out_free_mdiobus: 770err_out_free_mdiobus:
@@ -913,7 +917,12 @@ fec_enet_open(struct net_device *dev)
913 if (ret) 917 if (ret)
914 return ret; 918 return ret;
915 919
916 /* schedule a link state check */ 920 /* Probe and connect to PHY when open the interface */
921 ret = fec_enet_mii_probe(dev);
922 if (ret) {
923 fec_enet_free_buffers(dev);
924 return ret;
925 }
917 phy_start(fep->phy_dev); 926 phy_start(fep->phy_dev);
918 netif_start_queue(dev); 927 netif_start_queue(dev);
919 fep->opened = 1; 928 fep->opened = 1;
@@ -927,10 +936,12 @@ fec_enet_close(struct net_device *dev)
927 936
928 /* Don't know what to do yet. */ 937 /* Don't know what to do yet. */
929 fep->opened = 0; 938 fep->opened = 0;
930 phy_stop(fep->phy_dev);
931 netif_stop_queue(dev); 939 netif_stop_queue(dev);
932 fec_stop(dev); 940 fec_stop(dev);
933 941
942 if (fep->phy_dev)
943 phy_disconnect(fep->phy_dev);
944
934 fec_enet_free_buffers(dev); 945 fec_enet_free_buffers(dev);
935 946
936 return 0; 947 return 0;
@@ -1191,6 +1202,21 @@ fec_restart(struct net_device *dev, int duplex)
1191 /* Set MII speed */ 1202 /* Set MII speed */
1192 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); 1203 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
1193 1204
1205#ifdef FEC_MIIGSK_ENR
1206 if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) {
1207 /* disable the gasket and wait */
1208 writel(0, fep->hwp + FEC_MIIGSK_ENR);
1209 while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
1210 udelay(1);
1211
1212 /* configure the gasket: RMII, 50 MHz, no loopback, no echo */
1213 writel(1, fep->hwp + FEC_MIIGSK_CFGR);
1214
1215 /* re-enable the gasket */
1216 writel(2, fep->hwp + FEC_MIIGSK_ENR);
1217 }
1218#endif
1219
1194 /* And last, enable the transmit and receive processing */ 1220 /* And last, enable the transmit and receive processing */
1195 writel(2, fep->hwp + FEC_ECNTRL); 1221 writel(2, fep->hwp + FEC_ECNTRL);
1196 writel(0, fep->hwp + FEC_R_DES_ACTIVE); 1222 writel(0, fep->hwp + FEC_R_DES_ACTIVE);
@@ -1226,6 +1252,7 @@ static int __devinit
1226fec_probe(struct platform_device *pdev) 1252fec_probe(struct platform_device *pdev)
1227{ 1253{
1228 struct fec_enet_private *fep; 1254 struct fec_enet_private *fep;
1255 struct fec_platform_data *pdata;
1229 struct net_device *ndev; 1256 struct net_device *ndev;
1230 int i, irq, ret = 0; 1257 int i, irq, ret = 0;
1231 struct resource *r; 1258 struct resource *r;
@@ -1259,6 +1286,10 @@ fec_probe(struct platform_device *pdev)
1259 1286
1260 platform_set_drvdata(pdev, ndev); 1287 platform_set_drvdata(pdev, ndev);
1261 1288
1289 pdata = pdev->dev.platform_data;
1290 if (pdata)
1291 fep->phy_interface = pdata->phy;
1292
1262 /* This device has up to three irqs on some platforms */ 1293 /* This device has up to three irqs on some platforms */
1263 for (i = 0; i < 3; i++) { 1294 for (i = 0; i < 3; i++) {
1264 irq = platform_get_irq(pdev, i); 1295 irq = platform_get_irq(pdev, i);
@@ -1294,11 +1325,6 @@ fec_probe(struct platform_device *pdev)
1294 if (ret) 1325 if (ret)
1295 goto failed_register; 1326 goto failed_register;
1296 1327
1297 printk(KERN_INFO "%s: Freescale FEC PHY driver [%s] "
1298 "(mii_bus:phy_addr=%s, irq=%d)\n", ndev->name,
1299 fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev),
1300 fep->phy_dev->irq);
1301
1302 return 0; 1328 return 0;
1303 1329
1304failed_register: 1330failed_register:
@@ -1347,10 +1373,9 @@ fec_suspend(struct platform_device *dev, pm_message_t state)
1347 1373
1348 if (ndev) { 1374 if (ndev) {
1349 fep = netdev_priv(ndev); 1375 fep = netdev_priv(ndev);
1350 if (netif_running(ndev)) { 1376 if (netif_running(ndev))
1351 netif_device_detach(ndev); 1377 fec_enet_close(ndev);
1352 fec_stop(ndev); 1378 clk_disable(fep->clk);
1353 }
1354 } 1379 }
1355 return 0; 1380 return 0;
1356} 1381}
@@ -1359,12 +1384,13 @@ static int
1359fec_resume(struct platform_device *dev) 1384fec_resume(struct platform_device *dev)
1360{ 1385{
1361 struct net_device *ndev = platform_get_drvdata(dev); 1386 struct net_device *ndev = platform_get_drvdata(dev);
1387 struct fec_enet_private *fep;
1362 1388
1363 if (ndev) { 1389 if (ndev) {
1364 if (netif_running(ndev)) { 1390 fep = netdev_priv(ndev);
1365 fec_enet_init(ndev, 0); 1391 clk_enable(fep->clk);
1366 netif_device_attach(ndev); 1392 if (netif_running(ndev))
1367 } 1393 fec_enet_open(ndev);
1368 } 1394 }
1369 return 0; 1395 return 0;
1370} 1396}
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index cc47f3f057c7..2c48b25668d5 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -43,6 +43,8 @@
43#define FEC_R_DES_START 0x180 /* Receive descriptor ring */ 43#define FEC_R_DES_START 0x180 /* Receive descriptor ring */
44#define FEC_X_DES_START 0x184 /* Transmit descriptor ring */ 44#define FEC_X_DES_START 0x184 /* Transmit descriptor ring */
45#define FEC_R_BUFF_SIZE 0x188 /* Maximum receive buff size */ 45#define FEC_R_BUFF_SIZE 0x188 /* Maximum receive buff size */
46#define FEC_MIIGSK_CFGR 0x300 /* MIIGSK Configuration reg */
47#define FEC_MIIGSK_ENR 0x308 /* MIIGSK Enable reg */
46 48
47#else 49#else
48 50
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 221f440c10f4..25e6cc6840b1 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -871,7 +871,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
871 priv->ndev = ndev; 871 priv->ndev = ndev;
872 872
873 /* Reserve FEC control zone */ 873 /* Reserve FEC control zone */
874 rv = of_address_to_resource(op->node, 0, &mem); 874 rv = of_address_to_resource(op->dev.of_node, 0, &mem);
875 if (rv) { 875 if (rv) {
876 printk(KERN_ERR DRIVER_NAME ": " 876 printk(KERN_ERR DRIVER_NAME ": "
877 "Error while parsing device node resource\n" ); 877 "Error while parsing device node resource\n" );
@@ -919,7 +919,7 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
919 919
920 /* Get the IRQ we need one by one */ 920 /* Get the IRQ we need one by one */
921 /* Control */ 921 /* Control */
922 ndev->irq = irq_of_parse_and_map(op->node, 0); 922 ndev->irq = irq_of_parse_and_map(op->dev.of_node, 0);
923 923
924 /* RX */ 924 /* RX */
925 priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk); 925 priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk);
@@ -942,20 +942,20 @@ mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
942 /* Start with safe defaults for link connection */ 942 /* Start with safe defaults for link connection */
943 priv->speed = 100; 943 priv->speed = 100;
944 priv->duplex = DUPLEX_HALF; 944 priv->duplex = DUPLEX_HALF;
945 priv->mdio_speed = ((mpc5xxx_get_bus_frequency(op->node) >> 20) / 5) << 1; 945 priv->mdio_speed = ((mpc5xxx_get_bus_frequency(op->dev.of_node) >> 20) / 5) << 1;
946 946
947 /* The current speed preconfigures the speed of the MII link */ 947 /* The current speed preconfigures the speed of the MII link */
948 prop = of_get_property(op->node, "current-speed", &prop_size); 948 prop = of_get_property(op->dev.of_node, "current-speed", &prop_size);
949 if (prop && (prop_size >= sizeof(u32) * 2)) { 949 if (prop && (prop_size >= sizeof(u32) * 2)) {
950 priv->speed = prop[0]; 950 priv->speed = prop[0];
951 priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF; 951 priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF;
952 } 952 }
953 953
954 /* If there is a phy handle, then get the PHY node */ 954 /* If there is a phy handle, then get the PHY node */
955 priv->phy_node = of_parse_phandle(op->node, "phy-handle", 0); 955 priv->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0);
956 956
957 /* the 7-wire property means don't use MII mode */ 957 /* the 7-wire property means don't use MII mode */
958 if (of_find_property(op->node, "fsl,7-wire-mode", NULL)) { 958 if (of_find_property(op->dev.of_node, "fsl,7-wire-mode", NULL)) {
959 priv->seven_wire_mode = 1; 959 priv->seven_wire_mode = 1;
960 dev_info(&ndev->dev, "using 7-wire PHY mode\n"); 960 dev_info(&ndev->dev, "using 7-wire PHY mode\n");
961 } 961 }
@@ -1063,9 +1063,11 @@ static struct of_device_id mpc52xx_fec_match[] = {
1063MODULE_DEVICE_TABLE(of, mpc52xx_fec_match); 1063MODULE_DEVICE_TABLE(of, mpc52xx_fec_match);
1064 1064
1065static struct of_platform_driver mpc52xx_fec_driver = { 1065static struct of_platform_driver mpc52xx_fec_driver = {
1066 .owner = THIS_MODULE, 1066 .driver = {
1067 .name = DRIVER_NAME, 1067 .name = DRIVER_NAME,
1068 .match_table = mpc52xx_fec_match, 1068 .owner = THIS_MODULE,
1069 .of_match_table = mpc52xx_fec_match,
1070 },
1069 .probe = mpc52xx_fec_probe, 1071 .probe = mpc52xx_fec_probe,
1070 .remove = mpc52xx_fec_remove, 1072 .remove = mpc52xx_fec_remove,
1071#ifdef CONFIG_PM 1073#ifdef CONFIG_PM
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c
index 7658a082e390..006f64d9f96a 100644
--- a/drivers/net/fec_mpc52xx_phy.c
+++ b/drivers/net/fec_mpc52xx_phy.c
@@ -66,7 +66,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
66 const struct of_device_id *match) 66 const struct of_device_id *match)
67{ 67{
68 struct device *dev = &of->dev; 68 struct device *dev = &of->dev;
69 struct device_node *np = of->node; 69 struct device_node *np = of->dev.of_node;
70 struct mii_bus *bus; 70 struct mii_bus *bus;
71 struct mpc52xx_fec_mdio_priv *priv; 71 struct mpc52xx_fec_mdio_priv *priv;
72 struct resource res = {}; 72 struct resource res = {};
@@ -107,7 +107,7 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of,
107 107
108 /* set MII speed */ 108 /* set MII speed */
109 out_be32(&priv->regs->mii_speed, 109 out_be32(&priv->regs->mii_speed,
110 ((mpc5xxx_get_bus_frequency(of->node) >> 20) / 5) << 1); 110 ((mpc5xxx_get_bus_frequency(of->dev.of_node) >> 20) / 5) << 1);
111 111
112 err = of_mdiobus_register(bus, np); 112 err = of_mdiobus_register(bus, np);
113 if (err) 113 if (err)
@@ -159,10 +159,13 @@ static struct of_device_id mpc52xx_fec_mdio_match[] = {
159MODULE_DEVICE_TABLE(of, mpc52xx_fec_mdio_match); 159MODULE_DEVICE_TABLE(of, mpc52xx_fec_mdio_match);
160 160
161struct of_platform_driver mpc52xx_fec_mdio_driver = { 161struct of_platform_driver mpc52xx_fec_mdio_driver = {
162 .name = "mpc5200b-fec-phy", 162 .driver = {
163 .name = "mpc5200b-fec-phy",
164 .owner = THIS_MODULE,
165 .of_match_table = mpc52xx_fec_mdio_match,
166 },
163 .probe = mpc52xx_fec_mdio_probe, 167 .probe = mpc52xx_fec_mdio_probe,
164 .remove = mpc52xx_fec_mdio_remove, 168 .remove = mpc52xx_fec_mdio_remove,
165 .match_table = mpc52xx_fec_mdio_match,
166}; 169};
167 170
168/* let fec driver call it, since this has to be registered before it */ 171/* let fec driver call it, since this has to be registered before it */
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 0fb0fefcb787..309a0eaddd81 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -1013,7 +1013,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1013 return -ENOMEM; 1013 return -ENOMEM;
1014 1014
1015 if (!IS_FEC(match)) { 1015 if (!IS_FEC(match)) {
1016 data = of_get_property(ofdev->node, "fsl,cpm-command", &len); 1016 data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len);
1017 if (!data || len != 4) 1017 if (!data || len != 4)
1018 goto out_free_fpi; 1018 goto out_free_fpi;
1019 1019
@@ -1025,8 +1025,8 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1025 fpi->rx_copybreak = 240; 1025 fpi->rx_copybreak = 240;
1026 fpi->use_napi = 1; 1026 fpi->use_napi = 1;
1027 fpi->napi_weight = 17; 1027 fpi->napi_weight = 17;
1028 fpi->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0); 1028 fpi->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0);
1029 if ((!fpi->phy_node) && (!of_get_property(ofdev->node, "fixed-link", 1029 if ((!fpi->phy_node) && (!of_get_property(ofdev->dev.of_node, "fixed-link",
1030 NULL))) 1030 NULL)))
1031 goto out_free_fpi; 1031 goto out_free_fpi;
1032 1032
@@ -1059,7 +1059,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1059 spin_lock_init(&fep->lock); 1059 spin_lock_init(&fep->lock);
1060 spin_lock_init(&fep->tx_lock); 1060 spin_lock_init(&fep->tx_lock);
1061 1061
1062 mac_addr = of_get_mac_address(ofdev->node); 1062 mac_addr = of_get_mac_address(ofdev->dev.of_node);
1063 if (mac_addr) 1063 if (mac_addr)
1064 memcpy(ndev->dev_addr, mac_addr, 6); 1064 memcpy(ndev->dev_addr, mac_addr, 6);
1065 1065
@@ -1156,8 +1156,11 @@ static struct of_device_id fs_enet_match[] = {
1156MODULE_DEVICE_TABLE(of, fs_enet_match); 1156MODULE_DEVICE_TABLE(of, fs_enet_match);
1157 1157
1158static struct of_platform_driver fs_enet_driver = { 1158static struct of_platform_driver fs_enet_driver = {
1159 .name = "fs_enet", 1159 .driver = {
1160 .match_table = fs_enet_match, 1160 .owner = THIS_MODULE,
1161 .name = "fs_enet",
1162 .of_match_table = fs_enet_match,
1163 },
1161 .probe = fs_enet_probe, 1164 .probe = fs_enet_probe,
1162 .remove = fs_enet_remove, 1165 .remove = fs_enet_remove,
1163}; 1166};
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index 714da967fa19..48e91b6242ce 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -88,19 +88,19 @@ static int do_pd_setup(struct fs_enet_private *fep)
88 struct fs_platform_info *fpi = fep->fpi; 88 struct fs_platform_info *fpi = fep->fpi;
89 int ret = -EINVAL; 89 int ret = -EINVAL;
90 90
91 fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); 91 fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL);
92 if (fep->interrupt == NO_IRQ) 92 if (fep->interrupt == NO_IRQ)
93 goto out; 93 goto out;
94 94
95 fep->fcc.fccp = of_iomap(ofdev->node, 0); 95 fep->fcc.fccp = of_iomap(ofdev->dev.of_node, 0);
96 if (!fep->fcc.fccp) 96 if (!fep->fcc.fccp)
97 goto out; 97 goto out;
98 98
99 fep->fcc.ep = of_iomap(ofdev->node, 1); 99 fep->fcc.ep = of_iomap(ofdev->dev.of_node, 1);
100 if (!fep->fcc.ep) 100 if (!fep->fcc.ep)
101 goto out_fccp; 101 goto out_fccp;
102 102
103 fep->fcc.fcccp = of_iomap(ofdev->node, 2); 103 fep->fcc.fcccp = of_iomap(ofdev->dev.of_node, 2);
104 if (!fep->fcc.fcccp) 104 if (!fep->fcc.fcccp)
105 goto out_ep; 105 goto out_ep;
106 106
@@ -504,17 +504,54 @@ static int get_regs_len(struct net_device *dev)
504} 504}
505 505
506/* Some transmit errors cause the transmitter to shut 506/* Some transmit errors cause the transmitter to shut
507 * down. We now issue a restart transmit. Since the 507 * down. We now issue a restart transmit.
508 * errors close the BD and update the pointers, the restart 508 * Also, to workaround 8260 device erratum CPM37, we must
509 * _should_ pick up without having to reset any of our 509 * disable and then re-enable the transmitterfollowing a
510 * pointers either. Also, To workaround 8260 device erratum 510 * Late Collision, Underrun, or Retry Limit error.
511 * CPM37, we must disable and then re-enable the transmitter 511 * In addition, tbptr may point beyond BDs beyond still marked
512 * following a Late Collision, Underrun, or Retry Limit error. 512 * as ready due to internal pipelining, so we need to look back
513 * through the BDs and adjust tbptr to point to the last BD
514 * marked as ready. This may result in some buffers being
515 * retransmitted.
513 */ 516 */
514static void tx_restart(struct net_device *dev) 517static void tx_restart(struct net_device *dev)
515{ 518{
516 struct fs_enet_private *fep = netdev_priv(dev); 519 struct fs_enet_private *fep = netdev_priv(dev);
517 fcc_t __iomem *fccp = fep->fcc.fccp; 520 fcc_t __iomem *fccp = fep->fcc.fccp;
521 const struct fs_platform_info *fpi = fep->fpi;
522 fcc_enet_t __iomem *ep = fep->fcc.ep;
523 cbd_t __iomem *curr_tbptr;
524 cbd_t __iomem *recheck_bd;
525 cbd_t __iomem *prev_bd;
526 cbd_t __iomem *last_tx_bd;
527
528 last_tx_bd = fep->tx_bd_base + (fpi->tx_ring * sizeof(cbd_t));
529
530 /* get the current bd held in TBPTR and scan back from this point */
531 recheck_bd = curr_tbptr = (cbd_t __iomem *)
532 ((R32(ep, fen_genfcc.fcc_tbptr) - fep->ring_mem_addr) +
533 fep->ring_base);
534
535 prev_bd = (recheck_bd == fep->tx_bd_base) ? last_tx_bd : recheck_bd - 1;
536
537 /* Move through the bds in reverse, look for the earliest buffer
538 * that is not ready. Adjust TBPTR to the following buffer */
539 while ((CBDR_SC(prev_bd) & BD_ENET_TX_READY) != 0) {
540 /* Go back one buffer */
541 recheck_bd = prev_bd;
542
543 /* update the previous buffer */
544 prev_bd = (prev_bd == fep->tx_bd_base) ? last_tx_bd : prev_bd - 1;
545
546 /* We should never see all bds marked as ready, check anyway */
547 if (recheck_bd == curr_tbptr)
548 break;
549 }
550 /* Now update the TBPTR and dirty flag to the current buffer */
551 W32(ep, fen_genfcc.fcc_tbptr,
552 (uint) (((void *)recheck_bd - fep->ring_base) +
553 fep->ring_mem_addr));
554 fep->dirty_tx = recheck_bd;
518 555
519 C32(fccp, fcc_gfmr, FCC_GFMR_ENT); 556 C32(fccp, fcc_gfmr, FCC_GFMR_ENT);
520 udelay(10); 557 udelay(10);
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index 7eff92ef01da..7ca1642276d0 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -98,11 +98,11 @@ static int do_pd_setup(struct fs_enet_private *fep)
98{ 98{
99 struct of_device *ofdev = to_of_device(fep->dev); 99 struct of_device *ofdev = to_of_device(fep->dev);
100 100
101 fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); 101 fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL);
102 if (fep->interrupt == NO_IRQ) 102 if (fep->interrupt == NO_IRQ)
103 return -EINVAL; 103 return -EINVAL;
104 104
105 fep->fec.fecp = of_iomap(ofdev->node, 0); 105 fep->fec.fecp = of_iomap(ofdev->dev.of_node, 0);
106 if (!fep->fcc.fccp) 106 if (!fep->fcc.fccp)
107 return -EINVAL; 107 return -EINVAL;
108 108
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index 7f0591e43cd9..a3c44544846d 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -98,15 +98,15 @@ static int do_pd_setup(struct fs_enet_private *fep)
98{ 98{
99 struct of_device *ofdev = to_of_device(fep->dev); 99 struct of_device *ofdev = to_of_device(fep->dev);
100 100
101 fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); 101 fep->interrupt = of_irq_to_resource(ofdev->dev.of_node, 0, NULL);
102 if (fep->interrupt == NO_IRQ) 102 if (fep->interrupt == NO_IRQ)
103 return -EINVAL; 103 return -EINVAL;
104 104
105 fep->scc.sccp = of_iomap(ofdev->node, 0); 105 fep->scc.sccp = of_iomap(ofdev->dev.of_node, 0);
106 if (!fep->scc.sccp) 106 if (!fep->scc.sccp)
107 return -EINVAL; 107 return -EINVAL;
108 108
109 fep->scc.ep = of_iomap(ofdev->node, 1); 109 fep->scc.ep = of_iomap(ofdev->dev.of_node, 1);
110 if (!fep->scc.ep) { 110 if (!fep->scc.ep) {
111 iounmap(fep->scc.sccp); 111 iounmap(fep->scc.sccp);
112 return -EINVAL; 112 return -EINVAL;
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c
index 24ff9f43a62b..3607340f3da7 100644
--- a/drivers/net/fs_enet/mii-bitbang.c
+++ b/drivers/net/fs_enet/mii-bitbang.c
@@ -169,7 +169,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
169 169
170 new_bus->name = "CPM2 Bitbanged MII", 170 new_bus->name = "CPM2 Bitbanged MII",
171 171
172 ret = fs_mii_bitbang_init(new_bus, ofdev->node); 172 ret = fs_mii_bitbang_init(new_bus, ofdev->dev.of_node);
173 if (ret) 173 if (ret)
174 goto out_free_bus; 174 goto out_free_bus;
175 175
@@ -181,7 +181,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
181 new_bus->parent = &ofdev->dev; 181 new_bus->parent = &ofdev->dev;
182 dev_set_drvdata(&ofdev->dev, new_bus); 182 dev_set_drvdata(&ofdev->dev, new_bus);
183 183
184 ret = of_mdiobus_register(new_bus, ofdev->node); 184 ret = of_mdiobus_register(new_bus, ofdev->dev.of_node);
185 if (ret) 185 if (ret)
186 goto out_free_irqs; 186 goto out_free_irqs;
187 187
@@ -224,8 +224,11 @@ static struct of_device_id fs_enet_mdio_bb_match[] = {
224MODULE_DEVICE_TABLE(of, fs_enet_mdio_bb_match); 224MODULE_DEVICE_TABLE(of, fs_enet_mdio_bb_match);
225 225
226static struct of_platform_driver fs_enet_bb_mdio_driver = { 226static struct of_platform_driver fs_enet_bb_mdio_driver = {
227 .name = "fsl-bb-mdio", 227 .driver = {
228 .match_table = fs_enet_mdio_bb_match, 228 .name = "fsl-bb-mdio",
229 .owner = THIS_MODULE,
230 .of_match_table = fs_enet_mdio_bb_match,
231 },
229 .probe = fs_enet_mdio_probe, 232 .probe = fs_enet_mdio_probe,
230 .remove = fs_enet_mdio_remove, 233 .remove = fs_enet_mdio_remove,
231}; 234};
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index 5944b65082cb..bddffd169b93 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -124,7 +124,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
124 new_bus->write = &fs_enet_fec_mii_write; 124 new_bus->write = &fs_enet_fec_mii_write;
125 new_bus->reset = &fs_enet_fec_mii_reset; 125 new_bus->reset = &fs_enet_fec_mii_reset;
126 126
127 ret = of_address_to_resource(ofdev->node, 0, &res); 127 ret = of_address_to_resource(ofdev->dev.of_node, 0, &res);
128 if (ret) 128 if (ret)
129 goto out_res; 129 goto out_res;
130 130
@@ -135,7 +135,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
135 goto out_fec; 135 goto out_fec;
136 136
137 if (get_bus_freq) { 137 if (get_bus_freq) {
138 clock = get_bus_freq(ofdev->node); 138 clock = get_bus_freq(ofdev->dev.of_node);
139 if (!clock) { 139 if (!clock) {
140 /* Use maximum divider if clock is unknown */ 140 /* Use maximum divider if clock is unknown */
141 dev_warn(&ofdev->dev, "could not determine IPS clock\n"); 141 dev_warn(&ofdev->dev, "could not determine IPS clock\n");
@@ -172,7 +172,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
172 new_bus->parent = &ofdev->dev; 172 new_bus->parent = &ofdev->dev;
173 dev_set_drvdata(&ofdev->dev, new_bus); 173 dev_set_drvdata(&ofdev->dev, new_bus);
174 174
175 ret = of_mdiobus_register(new_bus, ofdev->node); 175 ret = of_mdiobus_register(new_bus, ofdev->dev.of_node);
176 if (ret) 176 if (ret)
177 goto out_free_irqs; 177 goto out_free_irqs;
178 178
@@ -222,8 +222,11 @@ static struct of_device_id fs_enet_mdio_fec_match[] = {
222MODULE_DEVICE_TABLE(of, fs_enet_mdio_fec_match); 222MODULE_DEVICE_TABLE(of, fs_enet_mdio_fec_match);
223 223
224static struct of_platform_driver fs_enet_fec_mdio_driver = { 224static struct of_platform_driver fs_enet_fec_mdio_driver = {
225 .name = "fsl-fec-mdio", 225 .driver = {
226 .match_table = fs_enet_mdio_fec_match, 226 .name = "fsl-fec-mdio",
227 .owner = THIS_MODULE,
228 .of_match_table = fs_enet_mdio_fec_match,
229 },
227 .probe = fs_enet_mdio_probe, 230 .probe = fs_enet_mdio_probe,
228 .remove = fs_enet_mdio_remove, 231 .remove = fs_enet_mdio_remove,
229}; 232};
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index ff028f59b930..b4c41d72c423 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -267,7 +267,7 @@ static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id)
267static int fsl_pq_mdio_probe(struct of_device *ofdev, 267static int fsl_pq_mdio_probe(struct of_device *ofdev,
268 const struct of_device_id *match) 268 const struct of_device_id *match)
269{ 269{
270 struct device_node *np = ofdev->node; 270 struct device_node *np = ofdev->dev.of_node;
271 struct device_node *tbi; 271 struct device_node *tbi;
272 struct fsl_pq_mdio_priv *priv; 272 struct fsl_pq_mdio_priv *priv;
273 struct fsl_pq_mdio __iomem *regs = NULL; 273 struct fsl_pq_mdio __iomem *regs = NULL;
@@ -471,10 +471,13 @@ static struct of_device_id fsl_pq_mdio_match[] = {
471MODULE_DEVICE_TABLE(of, fsl_pq_mdio_match); 471MODULE_DEVICE_TABLE(of, fsl_pq_mdio_match);
472 472
473static struct of_platform_driver fsl_pq_mdio_driver = { 473static struct of_platform_driver fsl_pq_mdio_driver = {
474 .name = "fsl-pq_mdio", 474 .driver = {
475 .name = "fsl-pq_mdio",
476 .owner = THIS_MODULE,
477 .of_match_table = fsl_pq_mdio_match,
478 },
475 .probe = fsl_pq_mdio_probe, 479 .probe = fsl_pq_mdio_probe,
476 .remove = fsl_pq_mdio_remove, 480 .remove = fsl_pq_mdio_remove,
477 .match_table = fsl_pq_mdio_match,
478}; 481};
479 482
480int __init fsl_pq_mdio_init(void) 483int __init fsl_pq_mdio_init(void)
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b3ca36270ce7..ba190376e030 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -608,7 +608,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
608 int err = 0, i; 608 int err = 0, i;
609 struct net_device *dev = NULL; 609 struct net_device *dev = NULL;
610 struct gfar_private *priv = NULL; 610 struct gfar_private *priv = NULL;
611 struct device_node *np = ofdev->node; 611 struct device_node *np = ofdev->dev.of_node;
612 struct device_node *child = NULL; 612 struct device_node *child = NULL;
613 const u32 *stash; 613 const u32 *stash;
614 const u32 *stash_len; 614 const u32 *stash_len;
@@ -646,7 +646,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
646 return -ENOMEM; 646 return -ENOMEM;
647 647
648 priv = netdev_priv(dev); 648 priv = netdev_priv(dev);
649 priv->node = ofdev->node; 649 priv->node = ofdev->dev.of_node;
650 priv->ndev = dev; 650 priv->ndev = dev;
651 651
652 dev->num_tx_queues = num_tx_qs; 652 dev->num_tx_queues = num_tx_qs;
@@ -747,8 +747,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
747 FSL_GIANFAR_DEV_HAS_CSUM | 747 FSL_GIANFAR_DEV_HAS_CSUM |
748 FSL_GIANFAR_DEV_HAS_VLAN | 748 FSL_GIANFAR_DEV_HAS_VLAN |
749 FSL_GIANFAR_DEV_HAS_MAGIC_PACKET | 749 FSL_GIANFAR_DEV_HAS_MAGIC_PACKET |
750 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH | 750 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
751 FSL_GIANFAR_DEV_HAS_TIMER;
752 751
753 ctype = of_get_property(np, "phy-connection-type", NULL); 752 ctype = of_get_property(np, "phy-connection-type", NULL);
754 753
@@ -939,7 +938,7 @@ static int gfar_probe(struct of_device *ofdev,
939 priv = netdev_priv(dev); 938 priv = netdev_priv(dev);
940 priv->ndev = dev; 939 priv->ndev = dev;
941 priv->ofdev = ofdev; 940 priv->ofdev = ofdev;
942 priv->node = ofdev->node; 941 priv->node = ofdev->dev.of_node;
943 SET_NETDEV_DEV(dev, &ofdev->dev); 942 SET_NETDEV_DEV(dev, &ofdev->dev);
944 943
945 spin_lock_init(&priv->bflock); 944 spin_lock_init(&priv->bflock);
@@ -3167,12 +3166,14 @@ MODULE_DEVICE_TABLE(of, gfar_match);
3167 3166
3168/* Structure for a device driver */ 3167/* Structure for a device driver */
3169static struct of_platform_driver gfar_driver = { 3168static struct of_platform_driver gfar_driver = {
3170 .name = "fsl-gianfar", 3169 .driver = {
3171 .match_table = gfar_match, 3170 .name = "fsl-gianfar",
3172 3171 .owner = THIS_MODULE,
3172 .pm = GFAR_PM_OPS,
3173 .of_match_table = gfar_match,
3174 },
3173 .probe = gfar_probe, 3175 .probe = gfar_probe,
3174 .remove = gfar_remove, 3176 .remove = gfar_remove,
3175 .driver.pm = GFAR_PM_OPS,
3176}; 3177};
3177 3178
3178static int __init gfar_init(void) 3179static int __init gfar_init(void)
diff --git a/drivers/net/greth.c b/drivers/net/greth.c
index fd491e409488..3a029d02c2b4 100644
--- a/drivers/net/greth.c
+++ b/drivers/net/greth.c
@@ -1499,7 +1499,8 @@ static int __devinit greth_of_probe(struct of_device *ofdev, const struct of_dev
1499 if (i == 6) { 1499 if (i == 6) {
1500 const unsigned char *addr; 1500 const unsigned char *addr;
1501 int len; 1501 int len;
1502 addr = of_get_property(ofdev->node, "local-mac-address", &len); 1502 addr = of_get_property(ofdev->dev.of_node, "local-mac-address",
1503 &len);
1503 if (addr != NULL && len == 6) { 1504 if (addr != NULL && len == 6) {
1504 for (i = 0; i < 6; i++) 1505 for (i = 0; i < 6; i++)
1505 macaddr[i] = (unsigned int) addr[i]; 1506 macaddr[i] = (unsigned int) addr[i];
@@ -1606,14 +1607,13 @@ static struct of_device_id greth_of_match[] = {
1606MODULE_DEVICE_TABLE(of, greth_of_match); 1607MODULE_DEVICE_TABLE(of, greth_of_match);
1607 1608
1608static struct of_platform_driver greth_of_driver = { 1609static struct of_platform_driver greth_of_driver = {
1609 .name = "grlib-greth", 1610 .driver = {
1610 .match_table = greth_of_match, 1611 .name = "grlib-greth",
1612 .owner = THIS_MODULE,
1613 .of_match_table = greth_of_match,
1614 },
1611 .probe = greth_of_probe, 1615 .probe = greth_of_probe,
1612 .remove = __devexit_p(greth_of_remove), 1616 .remove = __devexit_p(greth_of_remove),
1613 .driver = {
1614 .owner = THIS_MODULE,
1615 .name = "grlib-greth",
1616 },
1617}; 1617};
1618 1618
1619static int __init greth_init(void) 1619static int __init greth_init(void)
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 694132e04af6..4e7d1d0a2340 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -1151,8 +1151,7 @@ static int __init yam_init_driver(void)
1151 dev = alloc_netdev(sizeof(struct yam_port), name, 1151 dev = alloc_netdev(sizeof(struct yam_port), name,
1152 yam_setup); 1152 yam_setup);
1153 if (!dev) { 1153 if (!dev) {
1154 printk(KERN_ERR "yam: cannot allocate net device %s\n", 1154 pr_err("yam: cannot allocate net device\n");
1155 dev->name);
1156 err = -ENOMEM; 1155 err = -ENOMEM;
1157 goto error; 1156 goto error;
1158 } 1157 }
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 6a45f8f3a0c7..0f1d4e96cf89 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -136,7 +136,8 @@ static inline void emac_report_timeout_error(struct emac_instance *dev,
136 EMAC_FTR_440EP_PHY_CLK_FIX)) 136 EMAC_FTR_440EP_PHY_CLK_FIX))
137 DBG(dev, "%s" NL, error); 137 DBG(dev, "%s" NL, error);
138 else if (net_ratelimit()) 138 else if (net_ratelimit())
139 printk(KERN_ERR "%s: %s\n", dev->ofdev->node->full_name, error); 139 printk(KERN_ERR "%s: %s\n", dev->ofdev->dev.of_node->full_name,
140 error);
140} 141}
141 142
142/* EMAC PHY clock workaround: 143/* EMAC PHY clock workaround:
@@ -2185,7 +2186,7 @@ static void emac_ethtool_get_drvinfo(struct net_device *ndev,
2185 strcpy(info->version, DRV_VERSION); 2186 strcpy(info->version, DRV_VERSION);
2186 info->fw_version[0] = '\0'; 2187 info->fw_version[0] = '\0';
2187 sprintf(info->bus_info, "PPC 4xx EMAC-%d %s", 2188 sprintf(info->bus_info, "PPC 4xx EMAC-%d %s",
2188 dev->cell_index, dev->ofdev->node->full_name); 2189 dev->cell_index, dev->ofdev->dev.of_node->full_name);
2189 info->regdump_len = emac_ethtool_get_regs_len(ndev); 2190 info->regdump_len = emac_ethtool_get_regs_len(ndev);
2190} 2191}
2191 2192
@@ -2379,7 +2380,7 @@ static int __devinit emac_read_uint_prop(struct device_node *np, const char *nam
2379 2380
2380static int __devinit emac_init_phy(struct emac_instance *dev) 2381static int __devinit emac_init_phy(struct emac_instance *dev)
2381{ 2382{
2382 struct device_node *np = dev->ofdev->node; 2383 struct device_node *np = dev->ofdev->dev.of_node;
2383 struct net_device *ndev = dev->ndev; 2384 struct net_device *ndev = dev->ndev;
2384 u32 phy_map, adv; 2385 u32 phy_map, adv;
2385 int i; 2386 int i;
@@ -2514,7 +2515,7 @@ static int __devinit emac_init_phy(struct emac_instance *dev)
2514 2515
2515static int __devinit emac_init_config(struct emac_instance *dev) 2516static int __devinit emac_init_config(struct emac_instance *dev)
2516{ 2517{
2517 struct device_node *np = dev->ofdev->node; 2518 struct device_node *np = dev->ofdev->dev.of_node;
2518 const void *p; 2519 const void *p;
2519 unsigned int plen; 2520 unsigned int plen;
2520 const char *pm, *phy_modes[] = { 2521 const char *pm, *phy_modes[] = {
@@ -2723,7 +2724,7 @@ static int __devinit emac_probe(struct of_device *ofdev,
2723{ 2724{
2724 struct net_device *ndev; 2725 struct net_device *ndev;
2725 struct emac_instance *dev; 2726 struct emac_instance *dev;
2726 struct device_node *np = ofdev->node; 2727 struct device_node *np = ofdev->dev.of_node;
2727 struct device_node **blist = NULL; 2728 struct device_node **blist = NULL;
2728 int err, i; 2729 int err, i;
2729 2730
@@ -2810,7 +2811,7 @@ static int __devinit emac_probe(struct of_device *ofdev,
2810 err = mal_register_commac(dev->mal, &dev->commac); 2811 err = mal_register_commac(dev->mal, &dev->commac);
2811 if (err) { 2812 if (err) {
2812 printk(KERN_ERR "%s: failed to register with mal %s!\n", 2813 printk(KERN_ERR "%s: failed to register with mal %s!\n",
2813 np->full_name, dev->mal_dev->node->full_name); 2814 np->full_name, dev->mal_dev->dev.of_node->full_name);
2814 goto err_rel_deps; 2815 goto err_rel_deps;
2815 } 2816 }
2816 dev->rx_skb_size = emac_rx_skb_size(ndev->mtu); 2817 dev->rx_skb_size = emac_rx_skb_size(ndev->mtu);
@@ -2995,9 +2996,11 @@ static struct of_device_id emac_match[] =
2995MODULE_DEVICE_TABLE(of, emac_match); 2996MODULE_DEVICE_TABLE(of, emac_match);
2996 2997
2997static struct of_platform_driver emac_driver = { 2998static struct of_platform_driver emac_driver = {
2998 .name = "emac", 2999 .driver = {
2999 .match_table = emac_match, 3000 .name = "emac",
3000 3001 .owner = THIS_MODULE,
3002 .of_match_table = emac_match,
3003 },
3001 .probe = emac_probe, 3004 .probe = emac_probe,
3002 .remove = emac_remove, 3005 .remove = emac_remove,
3003}; 3006};
diff --git a/drivers/net/ibm_newemac/debug.c b/drivers/net/ibm_newemac/debug.c
index 775c850a425a..3995fafc1e08 100644
--- a/drivers/net/ibm_newemac/debug.c
+++ b/drivers/net/ibm_newemac/debug.c
@@ -33,7 +33,7 @@ static void emac_desc_dump(struct emac_instance *p)
33 int i; 33 int i;
34 printk("** EMAC %s TX BDs **\n" 34 printk("** EMAC %s TX BDs **\n"
35 " tx_cnt = %d tx_slot = %d ack_slot = %d\n", 35 " tx_cnt = %d tx_slot = %d ack_slot = %d\n",
36 p->ofdev->node->full_name, 36 p->ofdev->dev.of_node->full_name,
37 p->tx_cnt, p->tx_slot, p->ack_slot); 37 p->tx_cnt, p->tx_slot, p->ack_slot);
38 for (i = 0; i < NUM_TX_BUFF / 2; ++i) 38 for (i = 0; i < NUM_TX_BUFF / 2; ++i)
39 printk 39 printk
@@ -49,7 +49,7 @@ static void emac_desc_dump(struct emac_instance *p)
49 printk("** EMAC %s RX BDs **\n" 49 printk("** EMAC %s RX BDs **\n"
50 " rx_slot = %d flags = 0x%lx rx_skb_size = %d rx_sync_size = %d\n" 50 " rx_slot = %d flags = 0x%lx rx_skb_size = %d rx_sync_size = %d\n"
51 " rx_sg_skb = 0x%p\n", 51 " rx_sg_skb = 0x%p\n",
52 p->ofdev->node->full_name, 52 p->ofdev->dev.of_node->full_name,
53 p->rx_slot, p->commac.flags, p->rx_skb_size, 53 p->rx_slot, p->commac.flags, p->rx_skb_size,
54 p->rx_sync_size, p->rx_sg_skb); 54 p->rx_sync_size, p->rx_sg_skb);
55 for (i = 0; i < NUM_RX_BUFF / 2; ++i) 55 for (i = 0; i < NUM_RX_BUFF / 2; ++i)
@@ -77,7 +77,8 @@ static void emac_mac_dump(struct emac_instance *dev)
77 "MR0 = 0x%08x MR1 = 0x%08x TMR0 = 0x%08x TMR1 = 0x%08x\n" 77 "MR0 = 0x%08x MR1 = 0x%08x TMR0 = 0x%08x TMR1 = 0x%08x\n"
78 "RMR = 0x%08x ISR = 0x%08x ISER = 0x%08x\n" 78 "RMR = 0x%08x ISR = 0x%08x ISER = 0x%08x\n"
79 "IAR = %04x%08x VTPID = 0x%04x VTCI = 0x%04x\n", 79 "IAR = %04x%08x VTPID = 0x%04x VTCI = 0x%04x\n",
80 dev->ofdev->node->full_name, in_be32(&p->mr0), in_be32(&p->mr1), 80 dev->ofdev->dev.of_node->full_name,
81 in_be32(&p->mr0), in_be32(&p->mr1),
81 in_be32(&p->tmr0), in_be32(&p->tmr1), 82 in_be32(&p->tmr0), in_be32(&p->tmr1),
82 in_be32(&p->rmr), in_be32(&p->isr), in_be32(&p->iser), 83 in_be32(&p->rmr), in_be32(&p->isr), in_be32(&p->iser),
83 in_be32(&p->iahr), in_be32(&p->ialr), in_be32(&p->vtpid), 84 in_be32(&p->iahr), in_be32(&p->ialr), in_be32(&p->vtpid),
@@ -128,7 +129,7 @@ static void emac_mal_dump(struct mal_instance *mal)
128 "CFG = 0x%08x ESR = 0x%08x IER = 0x%08x\n" 129 "CFG = 0x%08x ESR = 0x%08x IER = 0x%08x\n"
129 "TX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n" 130 "TX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n"
130 "RX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n", 131 "RX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n",
131 mal->ofdev->node->full_name, 132 mal->ofdev->dev.of_node->full_name,
132 get_mal_dcrn(mal, MAL_CFG), get_mal_dcrn(mal, MAL_ESR), 133 get_mal_dcrn(mal, MAL_CFG), get_mal_dcrn(mal, MAL_ESR),
133 get_mal_dcrn(mal, MAL_IER), 134 get_mal_dcrn(mal, MAL_IER),
134 get_mal_dcrn(mal, MAL_TXCASR), get_mal_dcrn(mal, MAL_TXCARR), 135 get_mal_dcrn(mal, MAL_TXCASR), get_mal_dcrn(mal, MAL_TXCARR),
diff --git a/drivers/net/ibm_newemac/debug.h b/drivers/net/ibm_newemac/debug.h
index b631842ec8d0..e596c77ccdf7 100644
--- a/drivers/net/ibm_newemac/debug.h
+++ b/drivers/net/ibm_newemac/debug.h
@@ -53,8 +53,8 @@ extern void emac_dbg_dump_all(void);
53 53
54#endif 54#endif
55 55
56#define EMAC_DBG(dev, name, fmt, arg...) \ 56#define EMAC_DBG(d, name, fmt, arg...) \
57 printk(KERN_DEBUG #name "%s: " fmt, dev->ofdev->node->full_name, ## arg) 57 printk(KERN_DEBUG #name "%s: " fmt, d->ofdev->dev.of_node->full_name, ## arg)
58 58
59#if DBG_LEVEL > 0 59#if DBG_LEVEL > 0
60# define DBG(d,f,x...) EMAC_DBG(d, emac, f, ##x) 60# define DBG(d,f,x...) EMAC_DBG(d, emac, f, ##x)
diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c
index 5b3d94419fe6..fcff9e0bd382 100644
--- a/drivers/net/ibm_newemac/mal.c
+++ b/drivers/net/ibm_newemac/mal.c
@@ -538,11 +538,11 @@ static int __devinit mal_probe(struct of_device *ofdev,
538 } 538 }
539 mal->index = index; 539 mal->index = index;
540 mal->ofdev = ofdev; 540 mal->ofdev = ofdev;
541 mal->version = of_device_is_compatible(ofdev->node, "ibm,mcmal2") ? 2 : 1; 541 mal->version = of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal2") ? 2 : 1;
542 542
543 MAL_DBG(mal, "probe" NL); 543 MAL_DBG(mal, "probe" NL);
544 544
545 prop = of_get_property(ofdev->node, "num-tx-chans", NULL); 545 prop = of_get_property(ofdev->dev.of_node, "num-tx-chans", NULL);
546 if (prop == NULL) { 546 if (prop == NULL) {
547 printk(KERN_ERR 547 printk(KERN_ERR
548 "mal%d: can't find MAL num-tx-chans property!\n", 548 "mal%d: can't find MAL num-tx-chans property!\n",
@@ -552,7 +552,7 @@ static int __devinit mal_probe(struct of_device *ofdev,
552 } 552 }
553 mal->num_tx_chans = prop[0]; 553 mal->num_tx_chans = prop[0];
554 554
555 prop = of_get_property(ofdev->node, "num-rx-chans", NULL); 555 prop = of_get_property(ofdev->dev.of_node, "num-rx-chans", NULL);
556 if (prop == NULL) { 556 if (prop == NULL) {
557 printk(KERN_ERR 557 printk(KERN_ERR
558 "mal%d: can't find MAL num-rx-chans property!\n", 558 "mal%d: can't find MAL num-rx-chans property!\n",
@@ -562,14 +562,14 @@ static int __devinit mal_probe(struct of_device *ofdev,
562 } 562 }
563 mal->num_rx_chans = prop[0]; 563 mal->num_rx_chans = prop[0];
564 564
565 dcr_base = dcr_resource_start(ofdev->node, 0); 565 dcr_base = dcr_resource_start(ofdev->dev.of_node, 0);
566 if (dcr_base == 0) { 566 if (dcr_base == 0) {
567 printk(KERN_ERR 567 printk(KERN_ERR
568 "mal%d: can't find DCR resource!\n", index); 568 "mal%d: can't find DCR resource!\n", index);
569 err = -ENODEV; 569 err = -ENODEV;
570 goto fail; 570 goto fail;
571 } 571 }
572 mal->dcr_host = dcr_map(ofdev->node, dcr_base, 0x100); 572 mal->dcr_host = dcr_map(ofdev->dev.of_node, dcr_base, 0x100);
573 if (!DCR_MAP_OK(mal->dcr_host)) { 573 if (!DCR_MAP_OK(mal->dcr_host)) {
574 printk(KERN_ERR 574 printk(KERN_ERR
575 "mal%d: failed to map DCRs !\n", index); 575 "mal%d: failed to map DCRs !\n", index);
@@ -577,28 +577,28 @@ static int __devinit mal_probe(struct of_device *ofdev,
577 goto fail; 577 goto fail;
578 } 578 }
579 579
580 if (of_device_is_compatible(ofdev->node, "ibm,mcmal-405ez")) { 580 if (of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal-405ez")) {
581#if defined(CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT) && \ 581#if defined(CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT) && \
582 defined(CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR) 582 defined(CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR)
583 mal->features |= (MAL_FTR_CLEAR_ICINTSTAT | 583 mal->features |= (MAL_FTR_CLEAR_ICINTSTAT |
584 MAL_FTR_COMMON_ERR_INT); 584 MAL_FTR_COMMON_ERR_INT);
585#else 585#else
586 printk(KERN_ERR "%s: Support for 405EZ not enabled!\n", 586 printk(KERN_ERR "%s: Support for 405EZ not enabled!\n",
587 ofdev->node->full_name); 587 ofdev->dev.of_node->full_name);
588 err = -ENODEV; 588 err = -ENODEV;
589 goto fail; 589 goto fail;
590#endif 590#endif
591 } 591 }
592 592
593 mal->txeob_irq = irq_of_parse_and_map(ofdev->node, 0); 593 mal->txeob_irq = irq_of_parse_and_map(ofdev->dev.of_node, 0);
594 mal->rxeob_irq = irq_of_parse_and_map(ofdev->node, 1); 594 mal->rxeob_irq = irq_of_parse_and_map(ofdev->dev.of_node, 1);
595 mal->serr_irq = irq_of_parse_and_map(ofdev->node, 2); 595 mal->serr_irq = irq_of_parse_and_map(ofdev->dev.of_node, 2);
596 596
597 if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) { 597 if (mal_has_feature(mal, MAL_FTR_COMMON_ERR_INT)) {
598 mal->txde_irq = mal->rxde_irq = mal->serr_irq; 598 mal->txde_irq = mal->rxde_irq = mal->serr_irq;
599 } else { 599 } else {
600 mal->txde_irq = irq_of_parse_and_map(ofdev->node, 3); 600 mal->txde_irq = irq_of_parse_and_map(ofdev->dev.of_node, 3);
601 mal->rxde_irq = irq_of_parse_and_map(ofdev->node, 4); 601 mal->rxde_irq = irq_of_parse_and_map(ofdev->dev.of_node, 4);
602 } 602 }
603 603
604 if (mal->txeob_irq == NO_IRQ || mal->rxeob_irq == NO_IRQ || 604 if (mal->txeob_irq == NO_IRQ || mal->rxeob_irq == NO_IRQ ||
@@ -629,7 +629,7 @@ static int __devinit mal_probe(struct of_device *ofdev,
629 /* Current Axon is not happy with priority being non-0, it can 629 /* Current Axon is not happy with priority being non-0, it can
630 * deadlock, fix it up here 630 * deadlock, fix it up here
631 */ 631 */
632 if (of_device_is_compatible(ofdev->node, "ibm,mcmal-axon")) 632 if (of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal-axon"))
633 cfg &= ~(MAL2_CFG_RPP_10 | MAL2_CFG_WPP_10); 633 cfg &= ~(MAL2_CFG_RPP_10 | MAL2_CFG_WPP_10);
634 634
635 /* Apply configuration */ 635 /* Apply configuration */
@@ -701,7 +701,7 @@ static int __devinit mal_probe(struct of_device *ofdev,
701 701
702 printk(KERN_INFO 702 printk(KERN_INFO
703 "MAL v%d %s, %d TX channels, %d RX channels\n", 703 "MAL v%d %s, %d TX channels, %d RX channels\n",
704 mal->version, ofdev->node->full_name, 704 mal->version, ofdev->dev.of_node->full_name,
705 mal->num_tx_chans, mal->num_rx_chans); 705 mal->num_tx_chans, mal->num_rx_chans);
706 706
707 /* Advertise this instance to the rest of the world */ 707 /* Advertise this instance to the rest of the world */
@@ -790,9 +790,11 @@ static struct of_device_id mal_platform_match[] =
790}; 790};
791 791
792static struct of_platform_driver mal_of_driver = { 792static struct of_platform_driver mal_of_driver = {
793 .name = "mcmal", 793 .driver = {
794 .match_table = mal_platform_match, 794 .name = "mcmal",
795 795 .owner = THIS_MODULE,
796 .of_match_table = mal_platform_match,
797 },
796 .probe = mal_probe, 798 .probe = mal_probe,
797 .remove = mal_remove, 799 .remove = mal_remove,
798}; 800};
diff --git a/drivers/net/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c
index 5b90d34c8455..108919bcdf13 100644
--- a/drivers/net/ibm_newemac/rgmii.c
+++ b/drivers/net/ibm_newemac/rgmii.c
@@ -103,7 +103,7 @@ int __devinit rgmii_attach(struct of_device *ofdev, int input, int mode)
103 /* Check if we need to attach to a RGMII */ 103 /* Check if we need to attach to a RGMII */
104 if (input < 0 || !rgmii_valid_mode(mode)) { 104 if (input < 0 || !rgmii_valid_mode(mode)) {
105 printk(KERN_ERR "%s: unsupported settings !\n", 105 printk(KERN_ERR "%s: unsupported settings !\n",
106 ofdev->node->full_name); 106 ofdev->dev.of_node->full_name);
107 return -ENODEV; 107 return -ENODEV;
108 } 108 }
109 109
@@ -113,7 +113,7 @@ int __devinit rgmii_attach(struct of_device *ofdev, int input, int mode)
113 out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input)); 113 out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input));
114 114
115 printk(KERN_NOTICE "%s: input %d in %s mode\n", 115 printk(KERN_NOTICE "%s: input %d in %s mode\n",
116 ofdev->node->full_name, input, rgmii_mode_name(mode)); 116 ofdev->dev.of_node->full_name, input, rgmii_mode_name(mode));
117 117
118 ++dev->users; 118 ++dev->users;
119 119
@@ -231,7 +231,7 @@ void *rgmii_dump_regs(struct of_device *ofdev, void *buf)
231static int __devinit rgmii_probe(struct of_device *ofdev, 231static int __devinit rgmii_probe(struct of_device *ofdev,
232 const struct of_device_id *match) 232 const struct of_device_id *match)
233{ 233{
234 struct device_node *np = ofdev->node; 234 struct device_node *np = ofdev->dev.of_node;
235 struct rgmii_instance *dev; 235 struct rgmii_instance *dev;
236 struct resource regs; 236 struct resource regs;
237 int rc; 237 int rc;
@@ -264,11 +264,11 @@ static int __devinit rgmii_probe(struct of_device *ofdev,
264 } 264 }
265 265
266 /* Check for RGMII flags */ 266 /* Check for RGMII flags */
267 if (of_get_property(ofdev->node, "has-mdio", NULL)) 267 if (of_get_property(ofdev->dev.of_node, "has-mdio", NULL))
268 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; 268 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO;
269 269
270 /* CAB lacks the right properties, fix this up */ 270 /* CAB lacks the right properties, fix this up */
271 if (of_device_is_compatible(ofdev->node, "ibm,rgmii-axon")) 271 if (of_device_is_compatible(ofdev->dev.of_node, "ibm,rgmii-axon"))
272 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; 272 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO;
273 273
274 DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n", 274 DBG2(dev, " Boot FER = 0x%08x, SSR = 0x%08x\n",
@@ -279,7 +279,7 @@ static int __devinit rgmii_probe(struct of_device *ofdev,
279 279
280 printk(KERN_INFO 280 printk(KERN_INFO
281 "RGMII %s initialized with%s MDIO support\n", 281 "RGMII %s initialized with%s MDIO support\n",
282 ofdev->node->full_name, 282 ofdev->dev.of_node->full_name,
283 (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); 283 (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out");
284 284
285 wmb(); 285 wmb();
@@ -319,9 +319,11 @@ static struct of_device_id rgmii_match[] =
319}; 319};
320 320
321static struct of_platform_driver rgmii_driver = { 321static struct of_platform_driver rgmii_driver = {
322 .name = "emac-rgmii", 322 .driver = {
323 .match_table = rgmii_match, 323 .name = "emac-rgmii",
324 324 .owner = THIS_MODULE,
325 .of_match_table = rgmii_match,
326 },
325 .probe = rgmii_probe, 327 .probe = rgmii_probe,
326 .remove = rgmii_remove, 328 .remove = rgmii_remove,
327}; 329};
diff --git a/drivers/net/ibm_newemac/tah.c b/drivers/net/ibm_newemac/tah.c
index 30173a9fb557..044637144c43 100644
--- a/drivers/net/ibm_newemac/tah.c
+++ b/drivers/net/ibm_newemac/tah.c
@@ -57,7 +57,8 @@ void tah_reset(struct of_device *ofdev)
57 --n; 57 --n;
58 58
59 if (unlikely(!n)) 59 if (unlikely(!n))
60 printk(KERN_ERR "%s: reset timeout\n", ofdev->node->full_name); 60 printk(KERN_ERR "%s: reset timeout\n",
61 ofdev->dev.of_node->full_name);
61 62
62 /* 10KB TAH TX FIFO accomodates the max MTU of 9000 */ 63 /* 10KB TAH TX FIFO accomodates the max MTU of 9000 */
63 out_be32(&p->mr, 64 out_be32(&p->mr,
@@ -89,7 +90,7 @@ void *tah_dump_regs(struct of_device *ofdev, void *buf)
89static int __devinit tah_probe(struct of_device *ofdev, 90static int __devinit tah_probe(struct of_device *ofdev,
90 const struct of_device_id *match) 91 const struct of_device_id *match)
91{ 92{
92 struct device_node *np = ofdev->node; 93 struct device_node *np = ofdev->dev.of_node;
93 struct tah_instance *dev; 94 struct tah_instance *dev;
94 struct resource regs; 95 struct resource regs;
95 int rc; 96 int rc;
@@ -127,7 +128,7 @@ static int __devinit tah_probe(struct of_device *ofdev,
127 tah_reset(ofdev); 128 tah_reset(ofdev);
128 129
129 printk(KERN_INFO 130 printk(KERN_INFO
130 "TAH %s initialized\n", ofdev->node->full_name); 131 "TAH %s initialized\n", ofdev->dev.of_node->full_name);
131 wmb(); 132 wmb();
132 133
133 return 0; 134 return 0;
@@ -165,9 +166,11 @@ static struct of_device_id tah_match[] =
165}; 166};
166 167
167static struct of_platform_driver tah_driver = { 168static struct of_platform_driver tah_driver = {
168 .name = "emac-tah", 169 .driver = {
169 .match_table = tah_match, 170 .name = "emac-tah",
170 171 .owner = THIS_MODULE,
172 .of_match_table = tah_match,
173 },
171 .probe = tah_probe, 174 .probe = tah_probe,
172 .remove = tah_remove, 175 .remove = tah_remove,
173}; 176};
diff --git a/drivers/net/ibm_newemac/zmii.c b/drivers/net/ibm_newemac/zmii.c
index 1f038f808ab3..046dcd069c45 100644
--- a/drivers/net/ibm_newemac/zmii.c
+++ b/drivers/net/ibm_newemac/zmii.c
@@ -121,13 +121,14 @@ int __devinit zmii_attach(struct of_device *ofdev, int input, int *mode)
121 dev->mode = *mode; 121 dev->mode = *mode;
122 122
123 printk(KERN_NOTICE "%s: bridge in %s mode\n", 123 printk(KERN_NOTICE "%s: bridge in %s mode\n",
124 ofdev->node->full_name, zmii_mode_name(dev->mode)); 124 ofdev->dev.of_node->full_name,
125 zmii_mode_name(dev->mode));
125 } else { 126 } else {
126 /* All inputs must use the same mode */ 127 /* All inputs must use the same mode */
127 if (*mode != PHY_MODE_NA && *mode != dev->mode) { 128 if (*mode != PHY_MODE_NA && *mode != dev->mode) {
128 printk(KERN_ERR 129 printk(KERN_ERR
129 "%s: invalid mode %d specified for input %d\n", 130 "%s: invalid mode %d specified for input %d\n",
130 ofdev->node->full_name, *mode, input); 131 ofdev->dev.of_node->full_name, *mode, input);
131 mutex_unlock(&dev->lock); 132 mutex_unlock(&dev->lock);
132 return -EINVAL; 133 return -EINVAL;
133 } 134 }
@@ -233,7 +234,7 @@ void *zmii_dump_regs(struct of_device *ofdev, void *buf)
233static int __devinit zmii_probe(struct of_device *ofdev, 234static int __devinit zmii_probe(struct of_device *ofdev,
234 const struct of_device_id *match) 235 const struct of_device_id *match)
235{ 236{
236 struct device_node *np = ofdev->node; 237 struct device_node *np = ofdev->dev.of_node;
237 struct zmii_instance *dev; 238 struct zmii_instance *dev;
238 struct resource regs; 239 struct resource regs;
239 int rc; 240 int rc;
@@ -273,7 +274,7 @@ static int __devinit zmii_probe(struct of_device *ofdev,
273 out_be32(&dev->base->fer, 0); 274 out_be32(&dev->base->fer, 0);
274 275
275 printk(KERN_INFO 276 printk(KERN_INFO
276 "ZMII %s initialized\n", ofdev->node->full_name); 277 "ZMII %s initialized\n", ofdev->dev.of_node->full_name);
277 wmb(); 278 wmb();
278 dev_set_drvdata(&ofdev->dev, dev); 279 dev_set_drvdata(&ofdev->dev, dev);
279 280
@@ -312,9 +313,11 @@ static struct of_device_id zmii_match[] =
312}; 313};
313 314
314static struct of_platform_driver zmii_driver = { 315static struct of_platform_driver zmii_driver = {
315 .name = "emac-zmii", 316 .driver = {
316 .match_table = zmii_match, 317 .name = "emac-zmii",
317 318 .owner = THIS_MODULE,
319 .of_match_table = zmii_match,
320 },
318 .probe = zmii_probe, 321 .probe = zmii_probe,
319 .remove = zmii_remove, 322 .remove = zmii_remove,
320}; 323};
diff --git a/drivers/net/irda/bfin_sir.c b/drivers/net/irda/bfin_sir.c
index 911c082cee5a..f940dfa1f7f8 100644
--- a/drivers/net/irda/bfin_sir.c
+++ b/drivers/net/irda/bfin_sir.c
@@ -107,8 +107,12 @@ static int bfin_sir_set_speed(struct bfin_sir_port *port, int speed)
107 case 57600: 107 case 57600:
108 case 115200: 108 case 115200:
109 109
110 quot = (port->clk + (8 * speed)) / (16 * speed)\ 110 /*
111 - ANOMALY_05000230; 111 * IRDA is not affected by anomaly 05000230, so there is no
112 * need to tweak the divisor like he UART driver (which will
113 * slightly speed up the baud rate on us).
114 */
115 quot = (port->clk + (8 * speed)) / (16 * speed);
112 116
113 do { 117 do {
114 udelay(utime); 118 udelay(utime);
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index d0ea3d6dea95..ffae480587ae 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -360,6 +360,7 @@ struct ixgbe_adapter {
360 u32 flags2; 360 u32 flags2;
361#define IXGBE_FLAG2_RSC_CAPABLE (u32)(1) 361#define IXGBE_FLAG2_RSC_CAPABLE (u32)(1)
362#define IXGBE_FLAG2_RSC_ENABLED (u32)(1 << 1) 362#define IXGBE_FLAG2_RSC_ENABLED (u32)(1 << 1)
363#define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE (u32)(1 << 2)
363/* default to trying for four seconds */ 364/* default to trying for four seconds */
364#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ) 365#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
365 366
@@ -407,6 +408,8 @@ struct ixgbe_adapter {
407 u16 eeprom_version; 408 u16 eeprom_version;
408 409
409 int node; 410 int node;
411 struct work_struct check_overtemp_task;
412 u32 interrupt_event;
410 413
411 /* SR-IOV */ 414 /* SR-IOV */
412 DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS); 415 DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index f2b7ff44215b..9c02d6014cc4 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -1236,6 +1236,7 @@ static struct ixgbe_phy_operations phy_ops_82598 = {
1236 .setup_link = &ixgbe_setup_phy_link_generic, 1236 .setup_link = &ixgbe_setup_phy_link_generic,
1237 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, 1237 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,
1238 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_82598, 1238 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_82598,
1239 .check_overtemp = &ixgbe_tn_check_overtemp,
1239}; 1240};
1240 1241
1241struct ixgbe_info ixgbe_82598_info = { 1242struct ixgbe_info ixgbe_82598_info = {
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index e9706eb8e4ff..a4e2901f2f08 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -2395,6 +2395,7 @@ static struct ixgbe_phy_operations phy_ops_82599 = {
2395 .write_i2c_byte = &ixgbe_write_i2c_byte_generic, 2395 .write_i2c_byte = &ixgbe_write_i2c_byte_generic,
2396 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, 2396 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic,
2397 .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, 2397 .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic,
2398 .check_overtemp = &ixgbe_tn_check_overtemp,
2398}; 2399};
2399 2400
2400struct ixgbe_info ixgbe_82599_info = { 2401struct ixgbe_info ixgbe_82599_info = {
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c
index 1159d9138f05..9595b1bfb8dd 100644
--- a/drivers/net/ixgbe/ixgbe_common.c
+++ b/drivers/net/ixgbe/ixgbe_common.c
@@ -1188,6 +1188,7 @@ s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
1188 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high); 1188 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1189 } else { 1189 } else {
1190 hw_dbg(hw, "RAR index %d is out of range.\n", index); 1190 hw_dbg(hw, "RAR index %d is out of range.\n", index);
1191 return IXGBE_ERR_RAR_INDEX;
1191 } 1192 }
1192 1193
1193 return 0; 1194 return 0;
@@ -1219,6 +1220,7 @@ s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
1219 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high); 1220 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1220 } else { 1221 } else {
1221 hw_dbg(hw, "RAR index %d is out of range.\n", index); 1222 hw_dbg(hw, "RAR index %d is out of range.\n", index);
1223 return IXGBE_ERR_RAR_INDEX;
1222 } 1224 }
1223 1225
1224 /* clear VMDq pool/queue selection for this RAR */ 1226 /* clear VMDq pool/queue selection for this RAR */
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 9551cbb7bf01..b2af2f67f604 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -108,6 +108,8 @@ static DEFINE_PCI_DEVICE_TABLE(ixgbe_pci_tbl) = {
108 board_82599 }, 108 board_82599 },
109 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_CX4), 109 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_CX4),
110 board_82599 }, 110 board_82599 },
111 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_T3_LOM),
112 board_82599 },
111 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_COMBO_BACKPLANE), 113 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_COMBO_BACKPLANE),
112 board_82599 }, 114 board_82599 },
113 115
@@ -640,7 +642,7 @@ static inline bool ixgbe_tx_xon_state(struct ixgbe_adapter *adapter,
640 u32 txoff = IXGBE_TFCS_TXOFF; 642 u32 txoff = IXGBE_TFCS_TXOFF;
641 643
642#ifdef CONFIG_IXGBE_DCB 644#ifdef CONFIG_IXGBE_DCB
643 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { 645 if (adapter->dcb_cfg.pfc_mode_enable) {
644 int tc; 646 int tc;
645 int reg_idx = tx_ring->reg_idx; 647 int reg_idx = tx_ring->reg_idx;
646 int dcb_i = adapter->ring_feature[RING_F_DCB].indices; 648 int dcb_i = adapter->ring_feature[RING_F_DCB].indices;
@@ -1618,6 +1620,48 @@ static void ixgbe_set_itr_msix(struct ixgbe_q_vector *q_vector)
1618 } 1620 }
1619} 1621}
1620 1622
1623/**
1624 * ixgbe_check_overtemp_task - worker thread to check over tempurature
1625 * @work: pointer to work_struct containing our data
1626 **/
1627static void ixgbe_check_overtemp_task(struct work_struct *work)
1628{
1629 struct ixgbe_adapter *adapter = container_of(work,
1630 struct ixgbe_adapter,
1631 check_overtemp_task);
1632 struct ixgbe_hw *hw = &adapter->hw;
1633 u32 eicr = adapter->interrupt_event;
1634
1635 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) {
1636 switch (hw->device_id) {
1637 case IXGBE_DEV_ID_82599_T3_LOM: {
1638 u32 autoneg;
1639 bool link_up = false;
1640
1641 if (hw->mac.ops.check_link)
1642 hw->mac.ops.check_link(hw, &autoneg, &link_up, false);
1643
1644 if (((eicr & IXGBE_EICR_GPI_SDP0) && (!link_up)) ||
1645 (eicr & IXGBE_EICR_LSC))
1646 /* Check if this is due to overtemp */
1647 if (hw->phy.ops.check_overtemp(hw) == IXGBE_ERR_OVERTEMP)
1648 break;
1649 }
1650 return;
1651 default:
1652 if (!(eicr & IXGBE_EICR_GPI_SDP0))
1653 return;
1654 break;
1655 }
1656 DPRINTK(DRV, ERR, "Network adapter has been stopped because it "
1657 "has over heated. Restart the computer. If the problem "
1658 "persists, power off the system and replace the "
1659 "adapter\n");
1660 /* write to clear the interrupt */
1661 IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP0);
1662 }
1663}
1664
1621static void ixgbe_check_fan_failure(struct ixgbe_adapter *adapter, u32 eicr) 1665static void ixgbe_check_fan_failure(struct ixgbe_adapter *adapter, u32 eicr)
1622{ 1666{
1623 struct ixgbe_hw *hw = &adapter->hw; 1667 struct ixgbe_hw *hw = &adapter->hw;
@@ -1689,6 +1733,10 @@ static irqreturn_t ixgbe_msix_lsc(int irq, void *data)
1689 1733
1690 if (hw->mac.type == ixgbe_mac_82599EB) { 1734 if (hw->mac.type == ixgbe_mac_82599EB) {
1691 ixgbe_check_sfp_event(adapter, eicr); 1735 ixgbe_check_sfp_event(adapter, eicr);
1736 adapter->interrupt_event = eicr;
1737 if ((adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) &&
1738 ((eicr & IXGBE_EICR_GPI_SDP0) || (eicr & IXGBE_EICR_LSC)))
1739 schedule_work(&adapter->check_overtemp_task);
1692 1740
1693 /* Handle Flow Director Full threshold interrupt */ 1741 /* Handle Flow Director Full threshold interrupt */
1694 if (eicr & IXGBE_EICR_FLOW_DIR) { 1742 if (eicr & IXGBE_EICR_FLOW_DIR) {
@@ -2190,6 +2238,8 @@ static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter)
2190 u32 mask; 2238 u32 mask;
2191 2239
2192 mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE); 2240 mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE);
2241 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)
2242 mask |= IXGBE_EIMS_GPI_SDP0;
2193 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) 2243 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE)
2194 mask |= IXGBE_EIMS_GPI_SDP1; 2244 mask |= IXGBE_EIMS_GPI_SDP1;
2195 if (adapter->hw.mac.type == ixgbe_mac_82599EB) { 2245 if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
@@ -2250,6 +2300,9 @@ static irqreturn_t ixgbe_intr(int irq, void *data)
2250 ixgbe_check_sfp_event(adapter, eicr); 2300 ixgbe_check_sfp_event(adapter, eicr);
2251 2301
2252 ixgbe_check_fan_failure(adapter, eicr); 2302 ixgbe_check_fan_failure(adapter, eicr);
2303 if ((adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) &&
2304 ((eicr & IXGBE_EICR_GPI_SDP0) || (eicr & IXGBE_EICR_LSC)))
2305 schedule_work(&adapter->check_overtemp_task);
2253 2306
2254 if (napi_schedule_prep(&(q_vector->napi))) { 2307 if (napi_schedule_prep(&(q_vector->napi))) {
2255 adapter->tx_ring[0]->total_packets = 0; 2308 adapter->tx_ring[0]->total_packets = 0;
@@ -3265,6 +3318,13 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
3265 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE); 3318 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
3266 } 3319 }
3267 3320
3321 /* Enable Thermal over heat sensor interrupt */
3322 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) {
3323 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
3324 gpie |= IXGBE_SDP0_GPIEN;
3325 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
3326 }
3327
3268 /* Enable fan failure interrupt if media type is copper */ 3328 /* Enable fan failure interrupt if media type is copper */
3269 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { 3329 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) {
3270 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE); 3330 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
@@ -3666,6 +3726,9 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3666 adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) 3726 adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)
3667 cancel_work_sync(&adapter->fdir_reinit_task); 3727 cancel_work_sync(&adapter->fdir_reinit_task);
3668 3728
3729 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)
3730 cancel_work_sync(&adapter->check_overtemp_task);
3731
3669 /* disable transmits in the hardware now that interrupts are off */ 3732 /* disable transmits in the hardware now that interrupts are off */
3670 for (i = 0; i < adapter->num_tx_queues; i++) { 3733 for (i = 0; i < adapter->num_tx_queues; i++) {
3671 j = adapter->tx_ring[i]->reg_idx; 3734 j = adapter->tx_ring[i]->reg_idx;
@@ -4645,6 +4708,8 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
4645 adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82599; 4708 adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82599;
4646 adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE; 4709 adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE;
4647 adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; 4710 adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED;
4711 if (hw->device_id == IXGBE_DEV_ID_82599_T3_LOM)
4712 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE;
4648 if (dev->features & NETIF_F_NTUPLE) { 4713 if (dev->features & NETIF_F_NTUPLE) {
4649 /* Flow Director perfect filter enabled */ 4714 /* Flow Director perfect filter enabled */
4650 adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE; 4715 adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
@@ -6561,7 +6626,9 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6561 } 6626 }
6562 6627
6563 /* reset_hw fills in the perm_addr as well */ 6628 /* reset_hw fills in the perm_addr as well */
6629 hw->phy.reset_if_overtemp = true;
6564 err = hw->mac.ops.reset_hw(hw); 6630 err = hw->mac.ops.reset_hw(hw);
6631 hw->phy.reset_if_overtemp = false;
6565 if (err == IXGBE_ERR_SFP_NOT_PRESENT && 6632 if (err == IXGBE_ERR_SFP_NOT_PRESENT &&
6566 hw->mac.type == ixgbe_mac_82598EB) { 6633 hw->mac.type == ixgbe_mac_82598EB) {
6567 /* 6634 /*
@@ -6730,6 +6797,8 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6730 adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) 6797 adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)
6731 INIT_WORK(&adapter->fdir_reinit_task, ixgbe_fdir_reinit_task); 6798 INIT_WORK(&adapter->fdir_reinit_task, ixgbe_fdir_reinit_task);
6732 6799
6800 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)
6801 INIT_WORK(&adapter->check_overtemp_task, ixgbe_check_overtemp_task);
6733#ifdef CONFIG_IXGBE_DCA 6802#ifdef CONFIG_IXGBE_DCA
6734 if (dca_add_requester(&pdev->dev) == 0) { 6803 if (dca_add_requester(&pdev->dev) == 0) {
6735 adapter->flags |= IXGBE_FLAG_DCA_ENABLED; 6804 adapter->flags |= IXGBE_FLAG_DCA_ENABLED;
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 22d21af14783..09e1911ff510 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -135,6 +135,11 @@ static enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
135 **/ 135 **/
136s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw) 136s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
137{ 137{
138 /* Don't reset PHY if it's shut down due to overtemp. */
139 if (!hw->phy.reset_if_overtemp &&
140 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
141 return 0;
142
138 /* 143 /*
139 * Perform soft PHY reset to the PHY_XS. 144 * Perform soft PHY reset to the PHY_XS.
140 * This will cause a soft reset to the PHY 145 * This will cause a soft reset to the PHY
@@ -1345,3 +1350,28 @@ s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
1345 return status; 1350 return status;
1346} 1351}
1347 1352
1353/**
1354 * ixgbe_tn_check_overtemp - Checks if an overtemp occured.
1355 * @hw: pointer to hardware structure
1356 *
1357 * Checks if the LASI temp alarm status was triggered due to overtemp
1358 **/
1359s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
1360{
1361 s32 status = 0;
1362 u16 phy_data = 0;
1363
1364 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
1365 goto out;
1366
1367 /* Check that the LASI temp alarm status was triggered */
1368 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
1369 MDIO_MMD_PMAPMD, &phy_data);
1370
1371 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
1372 goto out;
1373
1374 status = IXGBE_ERR_OVERTEMP;
1375out:
1376 return status;
1377}
diff --git a/drivers/net/ixgbe/ixgbe_phy.h b/drivers/net/ixgbe/ixgbe_phy.h
index c9c545941407..ef4ba834c593 100644
--- a/drivers/net/ixgbe/ixgbe_phy.h
+++ b/drivers/net/ixgbe/ixgbe_phy.h
@@ -80,6 +80,8 @@
80#define IXGBE_I2C_T_SU_STO 4 80#define IXGBE_I2C_T_SU_STO 4
81#define IXGBE_I2C_T_BUF 5 81#define IXGBE_I2C_T_BUF 5
82 82
83#define IXGBE_TN_LASI_STATUS_REG 0x9005
84#define IXGBE_TN_LASI_STATUS_TEMP_ALARM 0x0008
83 85
84s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw); 86s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw);
85s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw); 87s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw);
@@ -106,6 +108,7 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw);
106s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw, 108s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
107 u16 *list_offset, 109 u16 *list_offset,
108 u16 *data_offset); 110 u16 *data_offset);
111s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw);
109s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, 112s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
110 u8 dev_addr, u8 *data); 113 u8 dev_addr, u8 *data);
111s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset, 114s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 39b9be897439..cdd1998f18c7 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -51,6 +51,7 @@
51#define IXGBE_DEV_ID_82599_KX4 0x10F7 51#define IXGBE_DEV_ID_82599_KX4 0x10F7
52#define IXGBE_DEV_ID_82599_KX4_MEZZ 0x1514 52#define IXGBE_DEV_ID_82599_KX4_MEZZ 0x1514
53#define IXGBE_DEV_ID_82599_KR 0x1517 53#define IXGBE_DEV_ID_82599_KR 0x1517
54#define IXGBE_DEV_ID_82599_T3_LOM 0x151C
54#define IXGBE_DEV_ID_82599_CX4 0x10F9 55#define IXGBE_DEV_ID_82599_CX4 0x10F9
55#define IXGBE_DEV_ID_82599_SFP 0x10FB 56#define IXGBE_DEV_ID_82599_SFP 0x10FB
56#define IXGBE_DEV_ID_82599_SFP_EM 0x1507 57#define IXGBE_DEV_ID_82599_SFP_EM 0x1507
@@ -2470,6 +2471,7 @@ struct ixgbe_phy_operations {
2470 s32 (*write_i2c_byte)(struct ixgbe_hw *, u8, u8, u8); 2471 s32 (*write_i2c_byte)(struct ixgbe_hw *, u8, u8, u8);
2471 s32 (*read_i2c_eeprom)(struct ixgbe_hw *, u8 , u8 *); 2472 s32 (*read_i2c_eeprom)(struct ixgbe_hw *, u8 , u8 *);
2472 s32 (*write_i2c_eeprom)(struct ixgbe_hw *, u8, u8); 2473 s32 (*write_i2c_eeprom)(struct ixgbe_hw *, u8, u8);
2474 s32 (*check_overtemp)(struct ixgbe_hw *);
2473}; 2475};
2474 2476
2475struct ixgbe_eeprom_info { 2477struct ixgbe_eeprom_info {
@@ -2518,6 +2520,7 @@ struct ixgbe_phy_info {
2518 enum ixgbe_smart_speed smart_speed; 2520 enum ixgbe_smart_speed smart_speed;
2519 bool smart_speed_active; 2521 bool smart_speed_active;
2520 bool multispeed_fiber; 2522 bool multispeed_fiber;
2523 bool reset_if_overtemp;
2521}; 2524};
2522 2525
2523#include "ixgbe_mbx.h" 2526#include "ixgbe_mbx.h"
@@ -2605,6 +2608,8 @@ struct ixgbe_info {
2605#define IXGBE_ERR_FDIR_REINIT_FAILED -23 2608#define IXGBE_ERR_FDIR_REINIT_FAILED -23
2606#define IXGBE_ERR_EEPROM_VERSION -24 2609#define IXGBE_ERR_EEPROM_VERSION -24
2607#define IXGBE_ERR_NO_SPACE -25 2610#define IXGBE_ERR_NO_SPACE -25
2611#define IXGBE_ERR_OVERTEMP -26
2612#define IXGBE_ERR_RAR_INDEX -27
2608#define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF 2613#define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF
2609 2614
2610#endif /* _IXGBE_TYPE_H_ */ 2615#endif /* _IXGBE_TYPE_H_ */
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index 26bf1b76b997..c7a9bef4dfb0 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -135,6 +135,7 @@ struct korina_private {
135 struct napi_struct napi; 135 struct napi_struct napi;
136 struct timer_list media_check_timer; 136 struct timer_list media_check_timer;
137 struct mii_if_info mii_if; 137 struct mii_if_info mii_if;
138 struct work_struct restart_task;
138 struct net_device *dev; 139 struct net_device *dev;
139 int phy_addr; 140 int phy_addr;
140}; 141};
@@ -375,7 +376,7 @@ static int korina_rx(struct net_device *dev, int limit)
375 if (devcs & ETH_RX_LE) 376 if (devcs & ETH_RX_LE)
376 dev->stats.rx_length_errors++; 377 dev->stats.rx_length_errors++;
377 if (devcs & ETH_RX_OVR) 378 if (devcs & ETH_RX_OVR)
378 dev->stats.rx_over_errors++; 379 dev->stats.rx_fifo_errors++;
379 if (devcs & ETH_RX_CV) 380 if (devcs & ETH_RX_CV)
380 dev->stats.rx_frame_errors++; 381 dev->stats.rx_frame_errors++;
381 if (devcs & ETH_RX_CES) 382 if (devcs & ETH_RX_CES)
@@ -764,10 +765,9 @@ static int korina_alloc_ring(struct net_device *dev)
764 765
765 /* Initialize the receive descriptors */ 766 /* Initialize the receive descriptors */
766 for (i = 0; i < KORINA_NUM_RDS; i++) { 767 for (i = 0; i < KORINA_NUM_RDS; i++) {
767 skb = dev_alloc_skb(KORINA_RBSIZE + 2); 768 skb = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
768 if (!skb) 769 if (!skb)
769 return -ENOMEM; 770 return -ENOMEM;
770 skb_reserve(skb, 2);
771 lp->rx_skb[i] = skb; 771 lp->rx_skb[i] = skb;
772 lp->rd_ring[i].control = DMA_DESC_IOD | 772 lp->rd_ring[i].control = DMA_DESC_IOD |
773 DMA_COUNT(KORINA_RBSIZE); 773 DMA_COUNT(KORINA_RBSIZE);
@@ -890,12 +890,12 @@ static int korina_init(struct net_device *dev)
890 890
891/* 891/*
892 * Restart the RC32434 ethernet controller. 892 * Restart the RC32434 ethernet controller.
893 * FIXME: check the return status where we call it
894 */ 893 */
895static int korina_restart(struct net_device *dev) 894static void korina_restart_task(struct work_struct *work)
896{ 895{
897 struct korina_private *lp = netdev_priv(dev); 896 struct korina_private *lp = container_of(work,
898 int ret; 897 struct korina_private, restart_task);
898 struct net_device *dev = lp->dev;
899 899
900 /* 900 /*
901 * Disable interrupts 901 * Disable interrupts
@@ -916,10 +916,9 @@ static int korina_restart(struct net_device *dev)
916 916
917 napi_disable(&lp->napi); 917 napi_disable(&lp->napi);
918 918
919 ret = korina_init(dev); 919 if (korina_init(dev) < 0) {
920 if (ret < 0) {
921 printk(KERN_ERR "%s: cannot restart device\n", dev->name); 920 printk(KERN_ERR "%s: cannot restart device\n", dev->name);
922 return ret; 921 return;
923 } 922 }
924 korina_multicast_list(dev); 923 korina_multicast_list(dev);
925 924
@@ -927,8 +926,6 @@ static int korina_restart(struct net_device *dev)
927 enable_irq(lp->ovr_irq); 926 enable_irq(lp->ovr_irq);
928 enable_irq(lp->tx_irq); 927 enable_irq(lp->tx_irq);
929 enable_irq(lp->rx_irq); 928 enable_irq(lp->rx_irq);
930
931 return ret;
932} 929}
933 930
934static void korina_clear_and_restart(struct net_device *dev, u32 value) 931static void korina_clear_and_restart(struct net_device *dev, u32 value)
@@ -937,7 +934,7 @@ static void korina_clear_and_restart(struct net_device *dev, u32 value)
937 934
938 netif_stop_queue(dev); 935 netif_stop_queue(dev);
939 writel(value, &lp->eth_regs->ethintfc); 936 writel(value, &lp->eth_regs->ethintfc);
940 korina_restart(dev); 937 schedule_work(&lp->restart_task);
941} 938}
942 939
943/* Ethernet Tx Underflow interrupt */ 940/* Ethernet Tx Underflow interrupt */
@@ -962,11 +959,8 @@ static irqreturn_t korina_und_interrupt(int irq, void *dev_id)
962static void korina_tx_timeout(struct net_device *dev) 959static void korina_tx_timeout(struct net_device *dev)
963{ 960{
964 struct korina_private *lp = netdev_priv(dev); 961 struct korina_private *lp = netdev_priv(dev);
965 unsigned long flags;
966 962
967 spin_lock_irqsave(&lp->lock, flags); 963 schedule_work(&lp->restart_task);
968 korina_restart(dev);
969 spin_unlock_irqrestore(&lp->lock, flags);
970} 964}
971 965
972/* Ethernet Rx Overflow interrupt */ 966/* Ethernet Rx Overflow interrupt */
@@ -1086,6 +1080,8 @@ static int korina_close(struct net_device *dev)
1086 1080
1087 napi_disable(&lp->napi); 1081 napi_disable(&lp->napi);
1088 1082
1083 cancel_work_sync(&lp->restart_task);
1084
1089 free_irq(lp->rx_irq, dev); 1085 free_irq(lp->rx_irq, dev);
1090 free_irq(lp->tx_irq, dev); 1086 free_irq(lp->tx_irq, dev);
1091 free_irq(lp->ovr_irq, dev); 1087 free_irq(lp->ovr_irq, dev);
@@ -1198,6 +1194,8 @@ static int korina_probe(struct platform_device *pdev)
1198 } 1194 }
1199 setup_timer(&lp->media_check_timer, korina_poll_media, (unsigned long) dev); 1195 setup_timer(&lp->media_check_timer, korina_poll_media, (unsigned long) dev);
1200 1196
1197 INIT_WORK(&lp->restart_task, korina_restart_task);
1198
1201 printk(KERN_INFO "%s: " DRV_NAME "-" DRV_VERSION " " DRV_RELDATE "\n", 1199 printk(KERN_INFO "%s: " DRV_NAME "-" DRV_VERSION " " DRV_RELDATE "\n",
1202 dev->name); 1200 dev->name);
1203out: 1201out:
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c
index c02ce1ab6571..aa50ee1b0247 100644
--- a/drivers/net/ksz884x.c
+++ b/drivers/net/ksz884x.c
@@ -4854,7 +4854,7 @@ static inline void copy_old_skb(struct sk_buff *old, struct sk_buff *skb)
4854 * 4854 *
4855 * Return 0 if successful; otherwise an error code indicating failure. 4855 * Return 0 if successful; otherwise an error code indicating failure.
4856 */ 4856 */
4857static int netdev_tx(struct sk_buff *skb, struct net_device *dev) 4857static netdev_tx_t netdev_tx(struct sk_buff *skb, struct net_device *dev)
4858{ 4858{
4859 struct dev_priv *priv = netdev_priv(dev); 4859 struct dev_priv *priv = netdev_priv(dev);
4860 struct dev_info *hw_priv = priv->adapter; 4860 struct dev_info *hw_priv = priv->adapter;
@@ -6863,6 +6863,7 @@ static const struct net_device_ops netdev_ops = {
6863 .ndo_tx_timeout = netdev_tx_timeout, 6863 .ndo_tx_timeout = netdev_tx_timeout,
6864 .ndo_change_mtu = netdev_change_mtu, 6864 .ndo_change_mtu = netdev_change_mtu,
6865 .ndo_set_mac_address = netdev_set_mac_address, 6865 .ndo_set_mac_address = netdev_set_mac_address,
6866 .ndo_validate_addr = eth_validate_addr,
6866 .ndo_do_ioctl = netdev_ioctl, 6867 .ndo_do_ioctl = netdev_ioctl,
6867 .ndo_set_rx_mode = netdev_set_rx_mode, 6868 .ndo_set_rx_mode = netdev_set_rx_mode,
6868#ifdef CONFIG_NET_POLL_CONTROLLER 6869#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/ll_temac.h b/drivers/net/ll_temac.h
index c03358434acb..522abe2ff25a 100644
--- a/drivers/net/ll_temac.h
+++ b/drivers/net/ll_temac.h
@@ -295,6 +295,10 @@ This option defaults to enabled (set) */
295 295
296#define MULTICAST_CAM_TABLE_NUM 4 296#define MULTICAST_CAM_TABLE_NUM 4
297 297
298/* TEMAC Synthesis features */
299#define TEMAC_FEATURE_RX_CSUM (1 << 0)
300#define TEMAC_FEATURE_TX_CSUM (1 << 1)
301
298/* TX/RX CURDESC_PTR points to first descriptor */ 302/* TX/RX CURDESC_PTR points to first descriptor */
299/* TX/RX TAILDESC_PTR points to last descriptor in linked list */ 303/* TX/RX TAILDESC_PTR points to last descriptor in linked list */
300 304
@@ -353,6 +357,7 @@ struct temac_local {
353 struct mutex indirect_mutex; 357 struct mutex indirect_mutex;
354 u32 options; /* Current options word */ 358 u32 options; /* Current options word */
355 int last_link; 359 int last_link;
360 unsigned int temac_features;
356 361
357 /* Buffer descriptors */ 362 /* Buffer descriptors */
358 struct cdmac_bd *tx_bd_v; 363 struct cdmac_bd *tx_bd_v;
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index 0ace2a46d31c..315eb4cdb58e 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -245,7 +245,7 @@ static int temac_dma_bd_init(struct net_device *ndev)
245 CHNL_CTRL_IRQ_COAL_EN); 245 CHNL_CTRL_IRQ_COAL_EN);
246 /* 0x10220483 */ 246 /* 0x10220483 */
247 /* 0x00100483 */ 247 /* 0x00100483 */
248 lp->dma_out(lp, RX_CHNL_CTRL, 0xff010000 | 248 lp->dma_out(lp, RX_CHNL_CTRL, 0xff070000 |
249 CHNL_CTRL_IRQ_EN | 249 CHNL_CTRL_IRQ_EN |
250 CHNL_CTRL_IRQ_DLY_EN | 250 CHNL_CTRL_IRQ_DLY_EN |
251 CHNL_CTRL_IRQ_COAL_EN | 251 CHNL_CTRL_IRQ_COAL_EN |
@@ -574,6 +574,10 @@ static void temac_start_xmit_done(struct net_device *ndev)
574 if (cur_p->app4) 574 if (cur_p->app4)
575 dev_kfree_skb_irq((struct sk_buff *)cur_p->app4); 575 dev_kfree_skb_irq((struct sk_buff *)cur_p->app4);
576 cur_p->app0 = 0; 576 cur_p->app0 = 0;
577 cur_p->app1 = 0;
578 cur_p->app2 = 0;
579 cur_p->app3 = 0;
580 cur_p->app4 = 0;
577 581
578 ndev->stats.tx_packets++; 582 ndev->stats.tx_packets++;
579 ndev->stats.tx_bytes += cur_p->len; 583 ndev->stats.tx_bytes += cur_p->len;
@@ -589,6 +593,29 @@ static void temac_start_xmit_done(struct net_device *ndev)
589 netif_wake_queue(ndev); 593 netif_wake_queue(ndev);
590} 594}
591 595
596static inline int temac_check_tx_bd_space(struct temac_local *lp, int num_frag)
597{
598 struct cdmac_bd *cur_p;
599 int tail;
600
601 tail = lp->tx_bd_tail;
602 cur_p = &lp->tx_bd_v[tail];
603
604 do {
605 if (cur_p->app0)
606 return NETDEV_TX_BUSY;
607
608 tail++;
609 if (tail >= TX_BD_NUM)
610 tail = 0;
611
612 cur_p = &lp->tx_bd_v[tail];
613 num_frag--;
614 } while (num_frag >= 0);
615
616 return 0;
617}
618
592static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) 619static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
593{ 620{
594 struct temac_local *lp = netdev_priv(ndev); 621 struct temac_local *lp = netdev_priv(ndev);
@@ -603,7 +630,7 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
603 start_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; 630 start_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail;
604 cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; 631 cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
605 632
606 if (cur_p->app0 & STS_CTRL_APP0_CMPLT) { 633 if (temac_check_tx_bd_space(lp, num_frag)) {
607 if (!netif_queue_stopped(ndev)) { 634 if (!netif_queue_stopped(ndev)) {
608 netif_stop_queue(ndev); 635 netif_stop_queue(ndev);
609 return NETDEV_TX_BUSY; 636 return NETDEV_TX_BUSY;
@@ -613,29 +640,14 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
613 640
614 cur_p->app0 = 0; 641 cur_p->app0 = 0;
615 if (skb->ip_summed == CHECKSUM_PARTIAL) { 642 if (skb->ip_summed == CHECKSUM_PARTIAL) {
616 const struct iphdr *ip = ip_hdr(skb); 643 unsigned int csum_start_off = skb_transport_offset(skb);
617 int length = 0, start = 0, insert = 0; 644 unsigned int csum_index_off = csum_start_off + skb->csum_offset;
618 645
619 switch (ip->protocol) { 646 cur_p->app0 |= 1; /* TX Checksum Enabled */
620 case IPPROTO_TCP: 647 cur_p->app1 = (csum_start_off << 16) | csum_index_off;
621 start = sizeof(struct iphdr) + ETH_HLEN; 648 cur_p->app2 = 0; /* initial checksum seed */
622 insert = sizeof(struct iphdr) + ETH_HLEN + 16;
623 length = ip->tot_len - sizeof(struct iphdr);
624 break;
625 case IPPROTO_UDP:
626 start = sizeof(struct iphdr) + ETH_HLEN;
627 insert = sizeof(struct iphdr) + ETH_HLEN + 6;
628 length = ip->tot_len - sizeof(struct iphdr);
629 break;
630 default:
631 break;
632 }
633 cur_p->app1 = ((start << 16) | insert);
634 cur_p->app2 = csum_tcpudp_magic(ip->saddr, ip->daddr,
635 length, ip->protocol, 0);
636 skb->data[insert] = 0;
637 skb->data[insert + 1] = 0;
638 } 649 }
650
639 cur_p->app0 |= STS_CTRL_APP0_SOP; 651 cur_p->app0 |= STS_CTRL_APP0_SOP;
640 cur_p->len = skb_headlen(skb); 652 cur_p->len = skb_headlen(skb);
641 cur_p->phys = dma_map_single(ndev->dev.parent, skb->data, skb->len, 653 cur_p->phys = dma_map_single(ndev->dev.parent, skb->data, skb->len,
@@ -699,6 +711,15 @@ static void ll_temac_recv(struct net_device *ndev)
699 skb->protocol = eth_type_trans(skb, ndev); 711 skb->protocol = eth_type_trans(skb, ndev);
700 skb->ip_summed = CHECKSUM_NONE; 712 skb->ip_summed = CHECKSUM_NONE;
701 713
714 /* if we're doing rx csum offload, set it up */
715 if (((lp->temac_features & TEMAC_FEATURE_RX_CSUM) != 0) &&
716 (skb->protocol == __constant_htons(ETH_P_IP)) &&
717 (skb->len > 64)) {
718
719 skb->csum = cur_p->app3 & 0xFFFF;
720 skb->ip_summed = CHECKSUM_COMPLETE;
721 }
722
702 netif_rx(skb); 723 netif_rx(skb);
703 724
704 ndev->stats.rx_packets++; 725 ndev->stats.rx_packets++;
@@ -883,6 +904,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
883 struct temac_local *lp; 904 struct temac_local *lp;
884 struct net_device *ndev; 905 struct net_device *ndev;
885 const void *addr; 906 const void *addr;
907 __be32 *p;
886 int size, rc = 0; 908 int size, rc = 0;
887 909
888 /* Init network device structure */ 910 /* Init network device structure */
@@ -920,14 +942,26 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
920 mutex_init(&lp->indirect_mutex); 942 mutex_init(&lp->indirect_mutex);
921 943
922 /* map device registers */ 944 /* map device registers */
923 lp->regs = of_iomap(op->node, 0); 945 lp->regs = of_iomap(op->dev.of_node, 0);
924 if (!lp->regs) { 946 if (!lp->regs) {
925 dev_err(&op->dev, "could not map temac regs.\n"); 947 dev_err(&op->dev, "could not map temac regs.\n");
926 goto nodev; 948 goto nodev;
927 } 949 }
928 950
951 /* Setup checksum offload, but default to off if not specified */
952 lp->temac_features = 0;
953 p = (__be32 *)of_get_property(op->dev.of_node, "xlnx,txcsum", NULL);
954 if (p && be32_to_cpu(*p)) {
955 lp->temac_features |= TEMAC_FEATURE_TX_CSUM;
956 /* Can checksum TCP/UDP over IPv4. */
957 ndev->features |= NETIF_F_IP_CSUM;
958 }
959 p = (__be32 *)of_get_property(op->dev.of_node, "xlnx,rxcsum", NULL);
960 if (p && be32_to_cpu(*p))
961 lp->temac_features |= TEMAC_FEATURE_RX_CSUM;
962
929 /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ 963 /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
930 np = of_parse_phandle(op->node, "llink-connected", 0); 964 np = of_parse_phandle(op->dev.of_node, "llink-connected", 0);
931 if (!np) { 965 if (!np) {
932 dev_err(&op->dev, "could not find DMA node\n"); 966 dev_err(&op->dev, "could not find DMA node\n");
933 goto nodev; 967 goto nodev;
@@ -950,7 +984,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
950 984
951 lp->rx_irq = irq_of_parse_and_map(np, 0); 985 lp->rx_irq = irq_of_parse_and_map(np, 0);
952 lp->tx_irq = irq_of_parse_and_map(np, 1); 986 lp->tx_irq = irq_of_parse_and_map(np, 1);
953 if (!lp->rx_irq || !lp->tx_irq) { 987 if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) {
954 dev_err(&op->dev, "could not determine irqs\n"); 988 dev_err(&op->dev, "could not determine irqs\n");
955 rc = -ENOMEM; 989 rc = -ENOMEM;
956 goto nodev; 990 goto nodev;
@@ -959,7 +993,7 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
959 of_node_put(np); /* Finished with the DMA node; drop the reference */ 993 of_node_put(np); /* Finished with the DMA node; drop the reference */
960 994
961 /* Retrieve the MAC address */ 995 /* Retrieve the MAC address */
962 addr = of_get_property(op->node, "local-mac-address", &size); 996 addr = of_get_property(op->dev.of_node, "local-mac-address", &size);
963 if ((!addr) || (size != 6)) { 997 if ((!addr) || (size != 6)) {
964 dev_err(&op->dev, "could not find MAC address\n"); 998 dev_err(&op->dev, "could not find MAC address\n");
965 rc = -ENODEV; 999 rc = -ENODEV;
@@ -967,11 +1001,11 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
967 } 1001 }
968 temac_set_mac_address(ndev, (void *)addr); 1002 temac_set_mac_address(ndev, (void *)addr);
969 1003
970 rc = temac_mdio_setup(lp, op->node); 1004 rc = temac_mdio_setup(lp, op->dev.of_node);
971 if (rc) 1005 if (rc)
972 dev_warn(&op->dev, "error registering MDIO bus\n"); 1006 dev_warn(&op->dev, "error registering MDIO bus\n");
973 1007
974 lp->phy_node = of_parse_phandle(op->node, "phy-handle", 0); 1008 lp->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0);
975 if (lp->phy_node) 1009 if (lp->phy_node)
976 dev_dbg(lp->dev, "using PHY node %s (%p)\n", np->full_name, np); 1010 dev_dbg(lp->dev, "using PHY node %s (%p)\n", np->full_name, np);
977 1011
@@ -1024,12 +1058,12 @@ static struct of_device_id temac_of_match[] __devinitdata = {
1024MODULE_DEVICE_TABLE(of, temac_of_match); 1058MODULE_DEVICE_TABLE(of, temac_of_match);
1025 1059
1026static struct of_platform_driver temac_of_driver = { 1060static struct of_platform_driver temac_of_driver = {
1027 .match_table = temac_of_match,
1028 .probe = temac_of_probe, 1061 .probe = temac_of_probe,
1029 .remove = __devexit_p(temac_of_remove), 1062 .remove = __devexit_p(temac_of_remove),
1030 .driver = { 1063 .driver = {
1031 .owner = THIS_MODULE, 1064 .owner = THIS_MODULE,
1032 .name = "xilinx_temac", 1065 .name = "xilinx_temac",
1066 .of_match_table = temac_of_match,
1033 }, 1067 },
1034}; 1068};
1035 1069
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index b6855a6476f8..1c5221f79d6f 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -997,8 +997,11 @@ MODULE_DEVICE_TABLE (of, mace_match);
997 997
998static struct macio_driver mace_driver = 998static struct macio_driver mace_driver =
999{ 999{
1000 .name = "mace", 1000 .driver = {
1001 .match_table = mace_match, 1001 .name = "mace",
1002 .owner = THIS_MODULE,
1003 .of_match_table = mace_match,
1004 },
1002 .probe = mace_probe, 1005 .probe = mace_probe,
1003 .remove = mace_remove, 1006 .remove = mace_remove,
1004}; 1007};
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 4e238afab4a3..87e8d4cb4057 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -634,11 +634,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
634 634
635 err = register_netdevice(dev); 635 err = register_netdevice(dev);
636 if (err < 0) 636 if (err < 0)
637 return err; 637 goto destroy_port;
638 638
639 list_add_tail(&vlan->list, &port->vlans); 639 list_add_tail(&vlan->list, &port->vlans);
640 netif_stacked_transfer_operstate(lowerdev, dev); 640 netif_stacked_transfer_operstate(lowerdev, dev);
641
641 return 0; 642 return 0;
643
644destroy_port:
645 if (list_empty(&port->vlans))
646 macvlan_port_destroy(lowerdev);
647
648 return err;
642} 649}
643EXPORT_SYMBOL_GPL(macvlan_common_newlink); 650EXPORT_SYMBOL_GPL(macvlan_common_newlink);
644 651
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c
index 57288ca1395f..b07e4dee80aa 100644
--- a/drivers/net/mlx4/icm.c
+++ b/drivers/net/mlx4/icm.c
@@ -163,28 +163,30 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages,
163 ret = mlx4_alloc_icm_pages(&chunk->mem[chunk->npages], 163 ret = mlx4_alloc_icm_pages(&chunk->mem[chunk->npages],
164 cur_order, gfp_mask); 164 cur_order, gfp_mask);
165 165
166 if (!ret) { 166 if (ret) {
167 ++chunk->npages; 167 if (--cur_order < 0)
168 168 goto fail;
169 if (coherent) 169 else
170 ++chunk->nsg; 170 continue;
171 else if (chunk->npages == MLX4_ICM_CHUNK_LEN) { 171 }
172 chunk->nsg = pci_map_sg(dev->pdev, chunk->mem,
173 chunk->npages,
174 PCI_DMA_BIDIRECTIONAL);
175 172
176 if (chunk->nsg <= 0) 173 ++chunk->npages;
177 goto fail;
178 174
179 chunk = NULL; 175 if (coherent)
180 } 176 ++chunk->nsg;
177 else if (chunk->npages == MLX4_ICM_CHUNK_LEN) {
178 chunk->nsg = pci_map_sg(dev->pdev, chunk->mem,
179 chunk->npages,
180 PCI_DMA_BIDIRECTIONAL);
181 181
182 npages -= 1 << cur_order; 182 if (chunk->nsg <= 0)
183 } else {
184 --cur_order;
185 if (cur_order < 0)
186 goto fail; 183 goto fail;
187 } 184 }
185
186 if (chunk->npages == MLX4_ICM_CHUNK_LEN)
187 chunk = NULL;
188
189 npages -= 1 << cur_order;
188 } 190 }
189 191
190 if (!coherent && chunk) { 192 if (!coherent && chunk) {
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 3898108f98ce..1a57c3da1f49 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -928,7 +928,7 @@ static const struct net_device_ops myri_ops = {
928 928
929static int __devinit myri_sbus_probe(struct of_device *op, const struct of_device_id *match) 929static int __devinit myri_sbus_probe(struct of_device *op, const struct of_device_id *match)
930{ 930{
931 struct device_node *dp = op->node; 931 struct device_node *dp = op->dev.of_node;
932 static unsigned version_printed; 932 static unsigned version_printed;
933 struct net_device *dev; 933 struct net_device *dev;
934 struct myri_eth *mp; 934 struct myri_eth *mp;
@@ -1161,8 +1161,11 @@ static const struct of_device_id myri_sbus_match[] = {
1161MODULE_DEVICE_TABLE(of, myri_sbus_match); 1161MODULE_DEVICE_TABLE(of, myri_sbus_match);
1162 1162
1163static struct of_platform_driver myri_sbus_driver = { 1163static struct of_platform_driver myri_sbus_driver = {
1164 .name = "myri", 1164 .driver = {
1165 .match_table = myri_sbus_match, 1165 .name = "myri",
1166 .owner = THIS_MODULE,
1167 .of_match_table = myri_sbus_match,
1168 },
1166 .probe = myri_sbus_probe, 1169 .probe = myri_sbus_probe,
1167 .remove = __devexit_p(myri_sbus_remove), 1170 .remove = __devexit_p(myri_sbus_remove),
1168}; 1171};
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 30abb4e436f1..63e8e3893bd6 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -9115,7 +9115,7 @@ static int __devinit niu_n2_irq_init(struct niu *np, u8 *ldg_num_map)
9115 const u32 *int_prop; 9115 const u32 *int_prop;
9116 int i; 9116 int i;
9117 9117
9118 int_prop = of_get_property(op->node, "interrupts", NULL); 9118 int_prop = of_get_property(op->dev.of_node, "interrupts", NULL);
9119 if (!int_prop) 9119 if (!int_prop)
9120 return -ENODEV; 9120 return -ENODEV;
9121 9121
@@ -9266,7 +9266,7 @@ static int __devinit niu_get_of_props(struct niu *np)
9266 int prop_len; 9266 int prop_len;
9267 9267
9268 if (np->parent->plat_type == PLAT_TYPE_NIU) 9268 if (np->parent->plat_type == PLAT_TYPE_NIU)
9269 dp = np->op->node; 9269 dp = np->op->dev.of_node;
9270 else 9270 else
9271 dp = pci_device_to_OF_node(np->pdev); 9271 dp = pci_device_to_OF_node(np->pdev);
9272 9272
@@ -10083,10 +10083,10 @@ static int __devinit niu_of_probe(struct of_device *op,
10083 10083
10084 niu_driver_version(); 10084 niu_driver_version();
10085 10085
10086 reg = of_get_property(op->node, "reg", NULL); 10086 reg = of_get_property(op->dev.of_node, "reg", NULL);
10087 if (!reg) { 10087 if (!reg) {
10088 dev_err(&op->dev, "%s: No 'reg' property, aborting\n", 10088 dev_err(&op->dev, "%s: No 'reg' property, aborting\n",
10089 op->node->full_name); 10089 op->dev.of_node->full_name);
10090 return -ENODEV; 10090 return -ENODEV;
10091 } 10091 }
10092 10092
@@ -10099,7 +10099,7 @@ static int __devinit niu_of_probe(struct of_device *op,
10099 np = netdev_priv(dev); 10099 np = netdev_priv(dev);
10100 10100
10101 memset(&parent_id, 0, sizeof(parent_id)); 10101 memset(&parent_id, 0, sizeof(parent_id));
10102 parent_id.of = of_get_parent(op->node); 10102 parent_id.of = of_get_parent(op->dev.of_node);
10103 10103
10104 np->parent = niu_get_parent(np, &parent_id, 10104 np->parent = niu_get_parent(np, &parent_id,
10105 PLAT_TYPE_NIU); 10105 PLAT_TYPE_NIU);
@@ -10234,8 +10234,11 @@ static const struct of_device_id niu_match[] = {
10234MODULE_DEVICE_TABLE(of, niu_match); 10234MODULE_DEVICE_TABLE(of, niu_match);
10235 10235
10236static struct of_platform_driver niu_of_driver = { 10236static struct of_platform_driver niu_of_driver = {
10237 .name = "niu", 10237 .driver = {
10238 .match_table = niu_match, 10238 .name = "niu",
10239 .owner = THIS_MODULE,
10240 .of_match_table = niu_match,
10241 },
10239 .probe = niu_of_probe, 10242 .probe = niu_of_probe,
10240 .remove = __devexit_p(niu_of_remove), 10243 .remove = __devexit_p(niu_of_remove),
10241}; 10244};
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 7b6fe89f9db0..64e6a84bbbbe 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -322,6 +322,7 @@ static int smc91c92_probe(struct pcmcia_device *link)
322 return -ENOMEM; 322 return -ENOMEM;
323 smc = netdev_priv(dev); 323 smc = netdev_priv(dev);
324 smc->p_dev = link; 324 smc->p_dev = link;
325 link->priv = dev;
325 326
326 spin_lock_init(&smc->lock); 327 spin_lock_init(&smc->lock);
327 link->io.NumPorts1 = 16; 328 link->io.NumPorts1 = 16;
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index 8ee929b796d8..dbd003453737 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -53,6 +53,9 @@
53 53
54#define MII_LXT971_ISR 19 /* Interrupt Status Register */ 54#define MII_LXT971_ISR 19 /* Interrupt Status Register */
55 55
56/* register definitions for the 973 */
57#define MII_LXT973_PCR 16 /* Port Configuration Register */
58#define PCR_FIBER_SELECT 1
56 59
57MODULE_DESCRIPTION("Intel LXT PHY driver"); 60MODULE_DESCRIPTION("Intel LXT PHY driver");
58MODULE_AUTHOR("Andy Fleming"); 61MODULE_AUTHOR("Andy Fleming");
@@ -119,6 +122,33 @@ static int lxt971_config_intr(struct phy_device *phydev)
119 return err; 122 return err;
120} 123}
121 124
125static int lxt973_probe(struct phy_device *phydev)
126{
127 int val = phy_read(phydev, MII_LXT973_PCR);
128
129 if (val & PCR_FIBER_SELECT) {
130 /*
131 * If fiber is selected, then the only correct setting
132 * is 100Mbps, full duplex, and auto negotiation off.
133 */
134 val = phy_read(phydev, MII_BMCR);
135 val |= (BMCR_SPEED100 | BMCR_FULLDPLX);
136 val &= ~BMCR_ANENABLE;
137 phy_write(phydev, MII_BMCR, val);
138 /* Remember that the port is in fiber mode. */
139 phydev->priv = lxt973_probe;
140 } else {
141 phydev->priv = NULL;
142 }
143 return 0;
144}
145
146static int lxt973_config_aneg(struct phy_device *phydev)
147{
148 /* Do nothing if port is in fiber mode. */
149 return phydev->priv ? 0 : genphy_config_aneg(phydev);
150}
151
122static struct phy_driver lxt970_driver = { 152static struct phy_driver lxt970_driver = {
123 .phy_id = 0x78100000, 153 .phy_id = 0x78100000,
124 .name = "LXT970", 154 .name = "LXT970",
@@ -146,6 +176,18 @@ static struct phy_driver lxt971_driver = {
146 .driver = { .owner = THIS_MODULE,}, 176 .driver = { .owner = THIS_MODULE,},
147}; 177};
148 178
179static struct phy_driver lxt973_driver = {
180 .phy_id = 0x00137a10,
181 .name = "LXT973",
182 .phy_id_mask = 0xfffffff0,
183 .features = PHY_BASIC_FEATURES,
184 .flags = 0,
185 .probe = lxt973_probe,
186 .config_aneg = lxt973_config_aneg,
187 .read_status = genphy_read_status,
188 .driver = { .owner = THIS_MODULE,},
189};
190
149static int __init lxt_init(void) 191static int __init lxt_init(void)
150{ 192{
151 int ret; 193 int ret;
@@ -157,9 +199,15 @@ static int __init lxt_init(void)
157 ret = phy_driver_register(&lxt971_driver); 199 ret = phy_driver_register(&lxt971_driver);
158 if (ret) 200 if (ret)
159 goto err2; 201 goto err2;
202
203 ret = phy_driver_register(&lxt973_driver);
204 if (ret)
205 goto err3;
160 return 0; 206 return 0;
161 207
162 err2: 208 err3:
209 phy_driver_unregister(&lxt971_driver);
210 err2:
163 phy_driver_unregister(&lxt970_driver); 211 phy_driver_unregister(&lxt970_driver);
164 err1: 212 err1:
165 return ret; 213 return ret;
@@ -169,6 +217,7 @@ static void __exit lxt_exit(void)
169{ 217{
170 phy_driver_unregister(&lxt970_driver); 218 phy_driver_unregister(&lxt970_driver);
171 phy_driver_unregister(&lxt971_driver); 219 phy_driver_unregister(&lxt971_driver);
220 phy_driver_unregister(&lxt973_driver);
172} 221}
173 222
174module_init(lxt_init); 223module_init(lxt_init);
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 35897134a5dd..fc5fef2a8175 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -199,12 +199,12 @@ static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,
199 if (!pdata) 199 if (!pdata)
200 return -ENOMEM; 200 return -ENOMEM;
201 201
202 ret = of_get_gpio(ofdev->node, 0); 202 ret = of_get_gpio(ofdev->dev.of_node, 0);
203 if (ret < 0) 203 if (ret < 0)
204 goto out_free; 204 goto out_free;
205 pdata->mdc = ret; 205 pdata->mdc = ret;
206 206
207 ret = of_get_gpio(ofdev->node, 1); 207 ret = of_get_gpio(ofdev->dev.of_node, 1);
208 if (ret < 0) 208 if (ret < 0)
209 goto out_free; 209 goto out_free;
210 pdata->mdio = ret; 210 pdata->mdio = ret;
@@ -213,7 +213,7 @@ static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,
213 if (!new_bus) 213 if (!new_bus)
214 goto out_free; 214 goto out_free;
215 215
216 ret = of_mdiobus_register(new_bus, ofdev->node); 216 ret = of_mdiobus_register(new_bus, ofdev->dev.of_node);
217 if (ret) 217 if (ret)
218 mdio_gpio_bus_deinit(&ofdev->dev); 218 mdio_gpio_bus_deinit(&ofdev->dev);
219 219
@@ -241,8 +241,11 @@ static struct of_device_id mdio_ofgpio_match[] = {
241MODULE_DEVICE_TABLE(of, mdio_ofgpio_match); 241MODULE_DEVICE_TABLE(of, mdio_ofgpio_match);
242 242
243static struct of_platform_driver mdio_ofgpio_driver = { 243static struct of_platform_driver mdio_ofgpio_driver = {
244 .name = "mdio-gpio", 244 .driver = {
245 .match_table = mdio_ofgpio_match, 245 .name = "mdio-gpio",
246 .owner = THIS_MODULE,
247 .of_match_table = mdio_ofgpio_match,
248 },
246 .probe = mdio_ofgpio_probe, 249 .probe = mdio_ofgpio_probe,
247 .remove = __devexit_p(mdio_ofgpio_remove), 250 .remove = __devexit_p(mdio_ofgpio_remove),
248}; 251};
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 5441688daba7..1b2c29150202 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1422,7 +1422,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1422 flen = len; 1422 flen = len;
1423 if (nfree > 0) { 1423 if (nfree > 0) {
1424 if (pch->speed == 0) { 1424 if (pch->speed == 0) {
1425 flen = totlen/nfree; 1425 flen = len/nfree;
1426 if (nbigger > 0) { 1426 if (nbigger > 0) {
1427 flen++; 1427 flen++;
1428 nbigger--; 1428 nbigger--;
@@ -2926,5 +2926,5 @@ EXPORT_SYMBOL(ppp_output_wakeup);
2926EXPORT_SYMBOL(ppp_register_compressor); 2926EXPORT_SYMBOL(ppp_register_compressor);
2927EXPORT_SYMBOL(ppp_unregister_compressor); 2927EXPORT_SYMBOL(ppp_unregister_compressor);
2928MODULE_LICENSE("GPL"); 2928MODULE_LICENSE("GPL");
2929MODULE_ALIAS_CHARDEV_MAJOR(PPP_MAJOR); 2929MODULE_ALIAS_CHARDEV(PPP_MAJOR, 0);
2930MODULE_ALIAS("/dev/ppp"); 2930MODULE_ALIAS("devname:ppp");
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index b1b93ff2351f..805b64d1e893 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -289,6 +289,7 @@ static void pppoe_flush_dev(struct net_device *dev)
289 struct pppoe_net *pn; 289 struct pppoe_net *pn;
290 int i; 290 int i;
291 291
292 pn = pppoe_pernet(dev_net(dev));
292 write_lock_bh(&pn->hash_lock); 293 write_lock_bh(&pn->hash_lock);
293 for (i = 0; i < PPPOE_HASH_SIZE; i++) { 294 for (i = 0; i < PPPOE_HASH_SIZE; i++) {
294 struct pppox_sock *po = pn->hash_table[i]; 295 struct pppox_sock *po = pn->hash_table[i];
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 217e709bda3e..96b6cfbf0a3a 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -559,6 +559,11 @@ static void mdio_write(void __iomem *ioaddr, int reg_addr, int value)
559 break; 559 break;
560 udelay(25); 560 udelay(25);
561 } 561 }
562 /*
563 * According to hardware specs a 20us delay is required after write
564 * complete indication, but before sending next command.
565 */
566 udelay(20);
562} 567}
563 568
564static int mdio_read(void __iomem *ioaddr, int reg_addr) 569static int mdio_read(void __iomem *ioaddr, int reg_addr)
@@ -578,6 +583,12 @@ static int mdio_read(void __iomem *ioaddr, int reg_addr)
578 } 583 }
579 udelay(25); 584 udelay(25);
580 } 585 }
586 /*
587 * According to hardware specs a 20us delay is required after read
588 * complete indication, but before sending next command.
589 */
590 udelay(20);
591
581 return value; 592 return value;
582} 593}
583 594
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 2e6fd89f2a72..4762c91cb587 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -830,7 +830,7 @@ static inline const char *efx_dev_name(struct efx_nic *efx)
830 830
831static inline unsigned int efx_port_num(struct efx_nic *efx) 831static inline unsigned int efx_port_num(struct efx_nic *efx)
832{ 832{
833 return PCI_FUNC(efx->pci_dev->devfn); 833 return efx->net_dev->dev_id;
834} 834}
835 835
836/** 836/**
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index 727b4228e081..f2b1e6180753 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -206,6 +206,7 @@ static int siena_probe_nic(struct efx_nic *efx)
206{ 206{
207 struct siena_nic_data *nic_data; 207 struct siena_nic_data *nic_data;
208 bool already_attached = 0; 208 bool already_attached = 0;
209 efx_oword_t reg;
209 int rc; 210 int rc;
210 211
211 /* Allocate storage for hardware specific data */ 212 /* Allocate storage for hardware specific data */
@@ -220,6 +221,9 @@ static int siena_probe_nic(struct efx_nic *efx)
220 goto fail1; 221 goto fail1;
221 } 222 }
222 223
224 efx_reado(efx, &reg, FR_AZ_CS_DEBUG);
225 efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;
226
223 efx_mcdi_init(efx); 227 efx_mcdi_init(efx);
224 228
225 /* Recover from a failed assertion before probing */ 229 /* Recover from a failed assertion before probing */
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 586ed0915a29..501a55ffce57 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -1294,6 +1294,9 @@ static int sh_mdio_release(struct net_device *ndev)
1294 /* remove mdio bus info from net_device */ 1294 /* remove mdio bus info from net_device */
1295 dev_set_drvdata(&ndev->dev, NULL); 1295 dev_set_drvdata(&ndev->dev, NULL);
1296 1296
1297 /* free interrupts memory */
1298 kfree(bus->irq);
1299
1297 /* free bitbang info */ 1300 /* free bitbang info */
1298 free_mdio_bitbang(bus); 1301 free_mdio_bitbang(bus);
1299 1302
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 4591fe9bf0b9..367e96f317d4 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -1131,8 +1131,8 @@ static int __devinit bigmac_ether_init(struct of_device *op,
1131 goto fail_and_cleanup; 1131 goto fail_and_cleanup;
1132 1132
1133 /* Get supported SBUS burst sizes. */ 1133 /* Get supported SBUS burst sizes. */
1134 bsizes = of_getintprop_default(qec_op->node, "burst-sizes", 0xff); 1134 bsizes = of_getintprop_default(qec_op->dev.of_node, "burst-sizes", 0xff);
1135 bsizes_more = of_getintprop_default(qec_op->node, "burst-sizes", 0xff); 1135 bsizes_more = of_getintprop_default(qec_op->dev.of_node, "burst-sizes", 0xff);
1136 1136
1137 bsizes &= 0xff; 1137 bsizes &= 0xff;
1138 if (bsizes_more != 0xff) 1138 if (bsizes_more != 0xff)
@@ -1184,7 +1184,7 @@ static int __devinit bigmac_ether_init(struct of_device *op,
1184 } 1184 }
1185 1185
1186 /* Get the board revision of this BigMAC. */ 1186 /* Get the board revision of this BigMAC. */
1187 bp->board_rev = of_getintprop_default(bp->bigmac_op->node, 1187 bp->board_rev = of_getintprop_default(bp->bigmac_op->dev.of_node,
1188 "board-version", 1); 1188 "board-version", 1);
1189 1189
1190 /* Init auto-negotiation timer state. */ 1190 /* Init auto-negotiation timer state. */
@@ -1290,8 +1290,11 @@ static const struct of_device_id bigmac_sbus_match[] = {
1290MODULE_DEVICE_TABLE(of, bigmac_sbus_match); 1290MODULE_DEVICE_TABLE(of, bigmac_sbus_match);
1291 1291
1292static struct of_platform_driver bigmac_sbus_driver = { 1292static struct of_platform_driver bigmac_sbus_driver = {
1293 .name = "sunbmac", 1293 .driver = {
1294 .match_table = bigmac_sbus_match, 1294 .name = "sunbmac",
1295 .owner = THIS_MODULE,
1296 .of_match_table = bigmac_sbus_match,
1297 },
1295 .probe = bigmac_sbus_probe, 1298 .probe = bigmac_sbus_probe,
1296 .remove = __devexit_p(bigmac_sbus_remove), 1299 .remove = __devexit_p(bigmac_sbus_remove),
1297}; 1300};
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index 915c5909c7a8..3d9650b8d38f 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2481,7 +2481,7 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
2481 else { 2481 else {
2482 const struct linux_prom_registers *regs; 2482 const struct linux_prom_registers *regs;
2483 struct of_device *op = hp->happy_dev; 2483 struct of_device *op = hp->happy_dev;
2484 regs = of_get_property(op->node, "regs", NULL); 2484 regs = of_get_property(op->dev.of_node, "regs", NULL);
2485 if (regs) 2485 if (regs)
2486 sprintf(info->bus_info, "SBUS:%d", 2486 sprintf(info->bus_info, "SBUS:%d",
2487 regs->which_io); 2487 regs->which_io);
@@ -2641,14 +2641,14 @@ static const struct net_device_ops hme_netdev_ops = {
2641#ifdef CONFIG_SBUS 2641#ifdef CONFIG_SBUS
2642static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) 2642static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2643{ 2643{
2644 struct device_node *dp = op->node, *sbus_dp; 2644 struct device_node *dp = op->dev.of_node, *sbus_dp;
2645 struct quattro *qp = NULL; 2645 struct quattro *qp = NULL;
2646 struct happy_meal *hp; 2646 struct happy_meal *hp;
2647 struct net_device *dev; 2647 struct net_device *dev;
2648 int i, qfe_slot = -1; 2648 int i, qfe_slot = -1;
2649 int err = -ENODEV; 2649 int err = -ENODEV;
2650 2650
2651 sbus_dp = to_of_device(op->dev.parent)->node; 2651 sbus_dp = to_of_device(op->dev.parent)->dev.of_node;
2652 2652
2653 /* We can match PCI devices too, do not accept those here. */ 2653 /* We can match PCI devices too, do not accept those here. */
2654 if (strcmp(sbus_dp->name, "sbus")) 2654 if (strcmp(sbus_dp->name, "sbus"))
@@ -3237,7 +3237,7 @@ static void happy_meal_pci_exit(void)
3237#ifdef CONFIG_SBUS 3237#ifdef CONFIG_SBUS
3238static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match) 3238static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match)
3239{ 3239{
3240 struct device_node *dp = op->node; 3240 struct device_node *dp = op->dev.of_node;
3241 const char *model = of_get_property(dp, "model", NULL); 3241 const char *model = of_get_property(dp, "model", NULL);
3242 int is_qfe = (match->data != NULL); 3242 int is_qfe = (match->data != NULL);
3243 3243
@@ -3291,8 +3291,11 @@ static const struct of_device_id hme_sbus_match[] = {
3291MODULE_DEVICE_TABLE(of, hme_sbus_match); 3291MODULE_DEVICE_TABLE(of, hme_sbus_match);
3292 3292
3293static struct of_platform_driver hme_sbus_driver = { 3293static struct of_platform_driver hme_sbus_driver = {
3294 .name = "hme", 3294 .driver = {
3295 .match_table = hme_sbus_match, 3295 .name = "hme",
3296 .owner = THIS_MODULE,
3297 .of_match_table = hme_sbus_match,
3298 },
3296 .probe = hme_sbus_probe, 3299 .probe = hme_sbus_probe,
3297 .remove = __devexit_p(hme_sbus_remove), 3300 .remove = __devexit_p(hme_sbus_remove),
3298}; 3301};
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 386af7bbe678..7d9c33dd9d1a 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -1323,7 +1323,7 @@ static int __devinit sparc_lance_probe_one(struct of_device *op,
1323 struct of_device *ledma, 1323 struct of_device *ledma,
1324 struct of_device *lebuffer) 1324 struct of_device *lebuffer)
1325{ 1325{
1326 struct device_node *dp = op->node; 1326 struct device_node *dp = op->dev.of_node;
1327 static unsigned version_printed; 1327 static unsigned version_printed;
1328 struct lance_private *lp; 1328 struct lance_private *lp;
1329 struct net_device *dev; 1329 struct net_device *dev;
@@ -1410,7 +1410,7 @@ static int __devinit sparc_lance_probe_one(struct of_device *op,
1410 1410
1411 lp->burst_sizes = 0; 1411 lp->burst_sizes = 0;
1412 if (lp->ledma) { 1412 if (lp->ledma) {
1413 struct device_node *ledma_dp = ledma->node; 1413 struct device_node *ledma_dp = ledma->dev.of_node;
1414 struct device_node *sbus_dp; 1414 struct device_node *sbus_dp;
1415 unsigned int sbmask; 1415 unsigned int sbmask;
1416 const char *prop; 1416 const char *prop;
@@ -1506,7 +1506,7 @@ fail:
1506static int __devinit sunlance_sbus_probe(struct of_device *op, const struct of_device_id *match) 1506static int __devinit sunlance_sbus_probe(struct of_device *op, const struct of_device_id *match)
1507{ 1507{
1508 struct of_device *parent = to_of_device(op->dev.parent); 1508 struct of_device *parent = to_of_device(op->dev.parent);
1509 struct device_node *parent_dp = parent->node; 1509 struct device_node *parent_dp = parent->dev.of_node;
1510 int err; 1510 int err;
1511 1511
1512 if (!strcmp(parent_dp->name, "ledma")) { 1512 if (!strcmp(parent_dp->name, "ledma")) {
@@ -1545,8 +1545,11 @@ static const struct of_device_id sunlance_sbus_match[] = {
1545MODULE_DEVICE_TABLE(of, sunlance_sbus_match); 1545MODULE_DEVICE_TABLE(of, sunlance_sbus_match);
1546 1546
1547static struct of_platform_driver sunlance_sbus_driver = { 1547static struct of_platform_driver sunlance_sbus_driver = {
1548 .name = "sunlance", 1548 .driver = {
1549 .match_table = sunlance_sbus_match, 1549 .name = "sunlance",
1550 .owner = THIS_MODULE,
1551 .of_match_table = sunlance_sbus_match,
1552 },
1550 .probe = sunlance_sbus_probe, 1553 .probe = sunlance_sbus_probe,
1551 .remove = __devexit_p(sunlance_sbus_remove), 1554 .remove = __devexit_p(sunlance_sbus_remove),
1552}; 1555};
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index a7542d25c845..72b579c8d812 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -695,7 +695,7 @@ static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
695 strcpy(info->version, "3.0"); 695 strcpy(info->version, "3.0");
696 696
697 op = qep->op; 697 op = qep->op;
698 regs = of_get_property(op->node, "reg", NULL); 698 regs = of_get_property(op->dev.of_node, "reg", NULL);
699 if (regs) 699 if (regs)
700 sprintf(info->bus_info, "SBUS:%d", regs->which_io); 700 sprintf(info->bus_info, "SBUS:%d", regs->which_io);
701 701
@@ -799,7 +799,7 @@ static struct sunqec * __devinit get_qec(struct of_device *child)
799 if (qec_global_reset(qecp->gregs)) 799 if (qec_global_reset(qecp->gregs))
800 goto fail; 800 goto fail;
801 801
802 qecp->qec_bursts = qec_get_burst(op->node); 802 qecp->qec_bursts = qec_get_burst(op->dev.of_node);
803 803
804 qec_init_once(qecp, op); 804 qec_init_once(qecp, op);
805 805
@@ -857,7 +857,7 @@ static int __devinit qec_ether_init(struct of_device *op)
857 857
858 res = -ENODEV; 858 res = -ENODEV;
859 859
860 i = of_getintprop_default(op->node, "channel#", -1); 860 i = of_getintprop_default(op->dev.of_node, "channel#", -1);
861 if (i == -1) 861 if (i == -1)
862 goto fail; 862 goto fail;
863 qe->channel = i; 863 qe->channel = i;
@@ -977,8 +977,11 @@ static const struct of_device_id qec_sbus_match[] = {
977MODULE_DEVICE_TABLE(of, qec_sbus_match); 977MODULE_DEVICE_TABLE(of, qec_sbus_match);
978 978
979static struct of_platform_driver qec_sbus_driver = { 979static struct of_platform_driver qec_sbus_driver = {
980 .name = "qec", 980 .driver = {
981 .match_table = qec_sbus_match, 981 .name = "qec",
982 .owner = THIS_MODULE,
983 .of_match_table = qec_sbus_match,
984 },
982 .probe = qec_sbus_probe, 985 .probe = qec_sbus_probe,
983 .remove = __devexit_p(qec_sbus_remove), 986 .remove = __devexit_p(qec_sbus_remove),
984}; 987};
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c
index 20ab16192325..737df6032bbc 100644
--- a/drivers/net/tehuti.c
+++ b/drivers/net/tehuti.c
@@ -646,7 +646,7 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
646 error = copy_from_user(data, ifr->ifr_data, sizeof(data)); 646 error = copy_from_user(data, ifr->ifr_data, sizeof(data));
647 if (error) { 647 if (error) {
648 pr_err("cant copy from user\n"); 648 pr_err("cant copy from user\n");
649 RET(error); 649 RET(-EFAULT);
650 } 650 }
651 DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); 651 DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]);
652 } 652 }
@@ -665,7 +665,7 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd)
665 data[2]); 665 data[2]);
666 error = copy_to_user(ifr->ifr_data, data, sizeof(data)); 666 error = copy_to_user(ifr->ifr_data, data, sizeof(data));
667 if (error) 667 if (error)
668 RET(error); 668 RET(-EFAULT);
669 break; 669 break;
670 670
671 case BDX_OP_WRITE: 671 case BDX_OP_WRITE:
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 97b25533e5fb..6ad6fe706312 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -526,6 +526,8 @@ static inline struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
526 struct sk_buff *skb; 526 struct sk_buff *skb;
527 int err; 527 int err;
528 528
529 sock_update_classid(sk);
530
529 /* Under a page? Don't bother with paged skb. */ 531 /* Under a page? Don't bother with paged skb. */
530 if (prepad + len < PAGE_SIZE || !linear) 532 if (prepad + len < PAGE_SIZE || !linear)
531 linear = len; 533 linear = len;
@@ -1649,3 +1651,4 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION);
1649MODULE_AUTHOR(DRV_COPYRIGHT); 1651MODULE_AUTHOR(DRV_COPYRIGHT);
1650MODULE_LICENSE("GPL"); 1652MODULE_LICENSE("GPL");
1651MODULE_ALIAS_MISCDEV(TUN_MINOR); 1653MODULE_ALIAS_MISCDEV(TUN_MINOR);
1654MODULE_ALIAS("devname:net/tun");
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 932602db54b3..4a34833b85dd 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -3719,7 +3719,7 @@ static const struct net_device_ops ucc_geth_netdev_ops = {
3719static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match) 3719static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match)
3720{ 3720{
3721 struct device *device = &ofdev->dev; 3721 struct device *device = &ofdev->dev;
3722 struct device_node *np = ofdev->node; 3722 struct device_node *np = ofdev->dev.of_node;
3723 struct net_device *dev = NULL; 3723 struct net_device *dev = NULL;
3724 struct ucc_geth_private *ugeth = NULL; 3724 struct ucc_geth_private *ugeth = NULL;
3725 struct ucc_geth_info *ug_info; 3725 struct ucc_geth_info *ug_info;
@@ -3963,8 +3963,11 @@ static struct of_device_id ucc_geth_match[] = {
3963MODULE_DEVICE_TABLE(of, ucc_geth_match); 3963MODULE_DEVICE_TABLE(of, ucc_geth_match);
3964 3964
3965static struct of_platform_driver ucc_geth_driver = { 3965static struct of_platform_driver ucc_geth_driver = {
3966 .name = DRV_NAME, 3966 .driver = {
3967 .match_table = ucc_geth_match, 3967 .name = DRV_NAME,
3968 .owner = THIS_MODULE,
3969 .of_match_table = ucc_geth_match,
3970 },
3968 .probe = ucc_geth_probe, 3971 .probe = ucc_geth_probe,
3969 .remove = ucc_geth_remove, 3972 .remove = ucc_geth_remove,
3970 .suspend = ucc_geth_suspend, 3973 .suspend = ucc_geth_suspend,
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 31b73310ec77..9516f382a6ba 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -322,7 +322,7 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
322 size = (u16) (header & 0x0000ffff); 322 size = (u16) (header & 0x0000ffff);
323 323
324 if ((skb->len) - ((size + 1) & 0xfffe) == 0) { 324 if ((skb->len) - ((size + 1) & 0xfffe) == 0) {
325 u8 alignment = (u32)skb->data & 0x3; 325 u8 alignment = (unsigned long)skb->data & 0x3;
326 if (alignment != 0x2) { 326 if (alignment != 0x2) {
327 /* 327 /*
328 * not 16bit aligned so use the room provided by 328 * not 16bit aligned so use the room provided by
@@ -344,14 +344,14 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
344 return 2; 344 return 2;
345 } 345 }
346 346
347 if (size > ETH_FRAME_LEN) { 347 if (size > dev->net->mtu + ETH_HLEN) {
348 netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n", 348 netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
349 size); 349 size);
350 return 0; 350 return 0;
351 } 351 }
352 ax_skb = skb_clone(skb, GFP_ATOMIC); 352 ax_skb = skb_clone(skb, GFP_ATOMIC);
353 if (ax_skb) { 353 if (ax_skb) {
354 u8 alignment = (u32)packet & 0x3; 354 u8 alignment = (unsigned long)packet & 0x3;
355 ax_skb->len = size; 355 ax_skb->len = size;
356 356
357 if (alignment != 0x2) { 357 if (alignment != 0x2) {
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 9964df199511..0a3c41faea9c 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -475,6 +475,9 @@ static const struct usb_device_id hso_ids[] = {
475 {USB_DEVICE(0x0af0, 0x8302)}, 475 {USB_DEVICE(0x0af0, 0x8302)},
476 {USB_DEVICE(0x0af0, 0x8304)}, 476 {USB_DEVICE(0x0af0, 0x8304)},
477 {USB_DEVICE(0x0af0, 0x8400)}, 477 {USB_DEVICE(0x0af0, 0x8400)},
478 {USB_DEVICE(0x0af0, 0x8600)},
479 {USB_DEVICE(0x0af0, 0x8800)},
480 {USB_DEVICE(0x0af0, 0x8900)},
478 {USB_DEVICE(0x0af0, 0xd035)}, 481 {USB_DEVICE(0x0af0, 0xd035)},
479 {USB_DEVICE(0x0af0, 0xd055)}, 482 {USB_DEVICE(0x0af0, 0xd055)},
480 {USB_DEVICE(0x0af0, 0xd155)}, 483 {USB_DEVICE(0x0af0, 0xd155)},
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b0a85d038796..1edb7a61983c 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -122,7 +122,7 @@ static void skb_xmit_done(struct virtqueue *svq)
122 struct virtnet_info *vi = svq->vdev->priv; 122 struct virtnet_info *vi = svq->vdev->priv;
123 123
124 /* Suppress further interrupts. */ 124 /* Suppress further interrupts. */
125 svq->vq_ops->disable_cb(svq); 125 virtqueue_disable_cb(svq);
126 126
127 /* We were probably waiting for more output buffers. */ 127 /* We were probably waiting for more output buffers. */
128 netif_wake_queue(vi->dev); 128 netif_wake_queue(vi->dev);
@@ -210,7 +210,7 @@ static int receive_mergeable(struct virtnet_info *vi, struct sk_buff *skb)
210 return -EINVAL; 210 return -EINVAL;
211 } 211 }
212 212
213 page = vi->rvq->vq_ops->get_buf(vi->rvq, &len); 213 page = virtqueue_get_buf(vi->rvq, &len);
214 if (!page) { 214 if (!page) {
215 pr_debug("%s: rx error: %d buffers missing\n", 215 pr_debug("%s: rx error: %d buffers missing\n",
216 skb->dev->name, hdr->mhdr.num_buffers); 216 skb->dev->name, hdr->mhdr.num_buffers);
@@ -340,7 +340,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, gfp_t gfp)
340 340
341 skb_to_sgvec(skb, vi->rx_sg + 1, 0, skb->len); 341 skb_to_sgvec(skb, vi->rx_sg + 1, 0, skb->len);
342 342
343 err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, 2, skb); 343 err = virtqueue_add_buf_gfp(vi->rvq, vi->rx_sg, 0, 2, skb, gfp);
344 if (err < 0) 344 if (err < 0)
345 dev_kfree_skb(skb); 345 dev_kfree_skb(skb);
346 346
@@ -385,8 +385,8 @@ static int add_recvbuf_big(struct virtnet_info *vi, gfp_t gfp)
385 385
386 /* chain first in list head */ 386 /* chain first in list head */
387 first->private = (unsigned long)list; 387 first->private = (unsigned long)list;
388 err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2, 388 err = virtqueue_add_buf_gfp(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2,
389 first); 389 first, gfp);
390 if (err < 0) 390 if (err < 0)
391 give_pages(vi, first); 391 give_pages(vi, first);
392 392
@@ -404,7 +404,7 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi, gfp_t gfp)
404 404
405 sg_init_one(vi->rx_sg, page_address(page), PAGE_SIZE); 405 sg_init_one(vi->rx_sg, page_address(page), PAGE_SIZE);
406 406
407 err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, 1, page); 407 err = virtqueue_add_buf_gfp(vi->rvq, vi->rx_sg, 0, 1, page, gfp);
408 if (err < 0) 408 if (err < 0)
409 give_pages(vi, page); 409 give_pages(vi, page);
410 410
@@ -433,7 +433,7 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
433 } while (err > 0); 433 } while (err > 0);
434 if (unlikely(vi->num > vi->max)) 434 if (unlikely(vi->num > vi->max))
435 vi->max = vi->num; 435 vi->max = vi->num;
436 vi->rvq->vq_ops->kick(vi->rvq); 436 virtqueue_kick(vi->rvq);
437 return !oom; 437 return !oom;
438} 438}
439 439
@@ -442,7 +442,7 @@ static void skb_recv_done(struct virtqueue *rvq)
442 struct virtnet_info *vi = rvq->vdev->priv; 442 struct virtnet_info *vi = rvq->vdev->priv;
443 /* Schedule NAPI, Suppress further interrupts if successful. */ 443 /* Schedule NAPI, Suppress further interrupts if successful. */
444 if (napi_schedule_prep(&vi->napi)) { 444 if (napi_schedule_prep(&vi->napi)) {
445 rvq->vq_ops->disable_cb(rvq); 445 virtqueue_disable_cb(rvq);
446 __napi_schedule(&vi->napi); 446 __napi_schedule(&vi->napi);
447 } 447 }
448} 448}
@@ -471,7 +471,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
471 471
472again: 472again:
473 while (received < budget && 473 while (received < budget &&
474 (buf = vi->rvq->vq_ops->get_buf(vi->rvq, &len)) != NULL) { 474 (buf = virtqueue_get_buf(vi->rvq, &len)) != NULL) {
475 receive_buf(vi->dev, buf, len); 475 receive_buf(vi->dev, buf, len);
476 --vi->num; 476 --vi->num;
477 received++; 477 received++;
@@ -485,9 +485,9 @@ again:
485 /* Out of packets? */ 485 /* Out of packets? */
486 if (received < budget) { 486 if (received < budget) {
487 napi_complete(napi); 487 napi_complete(napi);
488 if (unlikely(!vi->rvq->vq_ops->enable_cb(vi->rvq)) && 488 if (unlikely(!virtqueue_enable_cb(vi->rvq)) &&
489 napi_schedule_prep(napi)) { 489 napi_schedule_prep(napi)) {
490 vi->rvq->vq_ops->disable_cb(vi->rvq); 490 virtqueue_disable_cb(vi->rvq);
491 __napi_schedule(napi); 491 __napi_schedule(napi);
492 goto again; 492 goto again;
493 } 493 }
@@ -501,7 +501,7 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi)
501 struct sk_buff *skb; 501 struct sk_buff *skb;
502 unsigned int len, tot_sgs = 0; 502 unsigned int len, tot_sgs = 0;
503 503
504 while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { 504 while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) {
505 pr_debug("Sent skb %p\n", skb); 505 pr_debug("Sent skb %p\n", skb);
506 vi->dev->stats.tx_bytes += skb->len; 506 vi->dev->stats.tx_bytes += skb->len;
507 vi->dev->stats.tx_packets++; 507 vi->dev->stats.tx_packets++;
@@ -554,7 +554,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
554 sg_set_buf(vi->tx_sg, &hdr->hdr, sizeof hdr->hdr); 554 sg_set_buf(vi->tx_sg, &hdr->hdr, sizeof hdr->hdr);
555 555
556 hdr->num_sg = skb_to_sgvec(skb, vi->tx_sg + 1, 0, skb->len) + 1; 556 hdr->num_sg = skb_to_sgvec(skb, vi->tx_sg + 1, 0, skb->len) + 1;
557 return vi->svq->vq_ops->add_buf(vi->svq, vi->tx_sg, hdr->num_sg, 557 return virtqueue_add_buf(vi->svq, vi->tx_sg, hdr->num_sg,
558 0, skb); 558 0, skb);
559} 559}
560 560
@@ -574,14 +574,14 @@ again:
574 if (unlikely(capacity < 0)) { 574 if (unlikely(capacity < 0)) {
575 netif_stop_queue(dev); 575 netif_stop_queue(dev);
576 dev_warn(&dev->dev, "Unexpected full queue\n"); 576 dev_warn(&dev->dev, "Unexpected full queue\n");
577 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { 577 if (unlikely(!virtqueue_enable_cb(vi->svq))) {
578 vi->svq->vq_ops->disable_cb(vi->svq); 578 virtqueue_disable_cb(vi->svq);
579 netif_start_queue(dev); 579 netif_start_queue(dev);
580 goto again; 580 goto again;
581 } 581 }
582 return NETDEV_TX_BUSY; 582 return NETDEV_TX_BUSY;
583 } 583 }
584 vi->svq->vq_ops->kick(vi->svq); 584 virtqueue_kick(vi->svq);
585 585
586 /* Don't wait up for transmitted skbs to be freed. */ 586 /* Don't wait up for transmitted skbs to be freed. */
587 skb_orphan(skb); 587 skb_orphan(skb);
@@ -591,12 +591,12 @@ again:
591 * before it gets out of hand. Naturally, this wastes entries. */ 591 * before it gets out of hand. Naturally, this wastes entries. */
592 if (capacity < 2+MAX_SKB_FRAGS) { 592 if (capacity < 2+MAX_SKB_FRAGS) {
593 netif_stop_queue(dev); 593 netif_stop_queue(dev);
594 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { 594 if (unlikely(!virtqueue_enable_cb(vi->svq))) {
595 /* More just got used, free them then recheck. */ 595 /* More just got used, free them then recheck. */
596 capacity += free_old_xmit_skbs(vi); 596 capacity += free_old_xmit_skbs(vi);
597 if (capacity >= 2+MAX_SKB_FRAGS) { 597 if (capacity >= 2+MAX_SKB_FRAGS) {
598 netif_start_queue(dev); 598 netif_start_queue(dev);
599 vi->svq->vq_ops->disable_cb(vi->svq); 599 virtqueue_disable_cb(vi->svq);
600 } 600 }
601 } 601 }
602 } 602 }
@@ -641,7 +641,7 @@ static int virtnet_open(struct net_device *dev)
641 * now. virtnet_poll wants re-enable the queue, so we disable here. 641 * now. virtnet_poll wants re-enable the queue, so we disable here.
642 * We synchronize against interrupts via NAPI_STATE_SCHED */ 642 * We synchronize against interrupts via NAPI_STATE_SCHED */
643 if (napi_schedule_prep(&vi->napi)) { 643 if (napi_schedule_prep(&vi->napi)) {
644 vi->rvq->vq_ops->disable_cb(vi->rvq); 644 virtqueue_disable_cb(vi->rvq);
645 __napi_schedule(&vi->napi); 645 __napi_schedule(&vi->napi);
646 } 646 }
647 return 0; 647 return 0;
@@ -678,15 +678,15 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
678 sg_set_buf(&sg[i + 1], sg_virt(s), s->length); 678 sg_set_buf(&sg[i + 1], sg_virt(s), s->length);
679 sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); 679 sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
680 680
681 BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) < 0); 681 BUG_ON(virtqueue_add_buf(vi->cvq, sg, out, in, vi) < 0);
682 682
683 vi->cvq->vq_ops->kick(vi->cvq); 683 virtqueue_kick(vi->cvq);
684 684
685 /* 685 /*
686 * Spin for a response, the kick causes an ioport write, trapping 686 * Spin for a response, the kick causes an ioport write, trapping
687 * into the hypervisor, so the request should be handled immediately. 687 * into the hypervisor, so the request should be handled immediately.
688 */ 688 */
689 while (!vi->cvq->vq_ops->get_buf(vi->cvq, &tmp)) 689 while (!virtqueue_get_buf(vi->cvq, &tmp))
690 cpu_relax(); 690 cpu_relax();
691 691
692 return status == VIRTIO_NET_OK; 692 return status == VIRTIO_NET_OK;
@@ -1003,13 +1003,13 @@ static void free_unused_bufs(struct virtnet_info *vi)
1003{ 1003{
1004 void *buf; 1004 void *buf;
1005 while (1) { 1005 while (1) {
1006 buf = vi->svq->vq_ops->detach_unused_buf(vi->svq); 1006 buf = virtqueue_detach_unused_buf(vi->svq);
1007 if (!buf) 1007 if (!buf)
1008 break; 1008 break;
1009 dev_kfree_skb(buf); 1009 dev_kfree_skb(buf);
1010 } 1010 }
1011 while (1) { 1011 while (1) {
1012 buf = vi->rvq->vq_ops->detach_unused_buf(vi->rvq); 1012 buf = virtqueue_detach_unused_buf(vi->rvq);
1013 if (!buf) 1013 if (!buf)
1014 break; 1014 break;
1015 if (vi->mergeable_rx_bufs || vi->big_packets) 1015 if (vi->mergeable_rx_bufs || vi->big_packets)
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 166e77dfffda..e47f5a986b1c 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -37,8 +37,6 @@
37#include <net/x25device.h> 37#include <net/x25device.h>
38#include "x25_asy.h" 38#include "x25_asy.h"
39 39
40#include <net/x25device.h>
41
42static struct net_device **x25_asy_devs; 40static struct net_device **x25_asy_devs;
43static int x25_asy_maxdev = SL_NRUNIT; 41static int x25_asy_maxdev = SL_NRUNIT;
44 42
diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
index 3f283bff0ff7..11491354e5b5 100644
--- a/drivers/net/wimax/i2400m/fw.c
+++ b/drivers/net/wimax/i2400m/fw.c
@@ -1192,7 +1192,7 @@ int i2400m_fw_hdr_check(struct i2400m *i2400m,
1192 unsigned module_type, header_len, major_version, minor_version, 1192 unsigned module_type, header_len, major_version, minor_version,
1193 module_id, module_vendor, date, size; 1193 module_id, module_vendor, date, size;
1194 1194
1195 module_type = bcf_hdr->module_type; 1195 module_type = le32_to_cpu(bcf_hdr->module_type);
1196 header_len = sizeof(u32) * le32_to_cpu(bcf_hdr->header_len); 1196 header_len = sizeof(u32) * le32_to_cpu(bcf_hdr->header_len);
1197 major_version = (le32_to_cpu(bcf_hdr->header_version) & 0xffff0000) 1197 major_version = (le32_to_cpu(bcf_hdr->header_version) & 0xffff0000)
1198 >> 16; 1198 >> 16;
diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
index 6537593fae66..8cc9e319f435 100644
--- a/drivers/net/wimax/i2400m/rx.c
+++ b/drivers/net/wimax/i2400m/rx.c
@@ -1027,12 +1027,12 @@ void i2400m_rx_edata(struct i2400m *i2400m, struct sk_buff *skb_rx,
1027 ro_sn = (reorder >> I2400M_RO_SN_SHIFT) & I2400M_RO_SN; 1027 ro_sn = (reorder >> I2400M_RO_SN_SHIFT) & I2400M_RO_SN;
1028 1028
1029 spin_lock_irqsave(&i2400m->rx_lock, flags); 1029 spin_lock_irqsave(&i2400m->rx_lock, flags);
1030 roq = &i2400m->rx_roq[ro_cin]; 1030 if (i2400m->rx_roq == NULL) {
1031 if (roq == NULL) {
1032 kfree_skb(skb); /* rx_roq is already destroyed */ 1031 kfree_skb(skb); /* rx_roq is already destroyed */
1033 spin_unlock_irqrestore(&i2400m->rx_lock, flags); 1032 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
1034 goto error; 1033 goto error;
1035 } 1034 }
1035 roq = &i2400m->rx_roq[ro_cin];
1036 kref_get(&i2400m->rx_roq_refcount); 1036 kref_get(&i2400m->rx_roq_refcount);
1037 spin_unlock_irqrestore(&i2400m->rx_lock, flags); 1037 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
1038 1038
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index a441aad922c2..3b7ab20a5c54 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -5162,13 +5162,6 @@ static void proc_SSID_on_close(struct inode *inode, struct file *file)
5162 enable_MAC(ai, 1); 5162 enable_MAC(ai, 1);
5163} 5163}
5164 5164
5165static inline u8 hexVal(char c) {
5166 if (c>='0' && c<='9') return c -= '0';
5167 if (c>='a' && c<='f') return c -= 'a'-10;
5168 if (c>='A' && c<='F') return c -= 'A'-10;
5169 return 0;
5170}
5171
5172static void proc_APList_on_close( struct inode *inode, struct file *file ) { 5165static void proc_APList_on_close( struct inode *inode, struct file *file ) {
5173 struct proc_data *data = (struct proc_data *)file->private_data; 5166 struct proc_data *data = (struct proc_data *)file->private_data;
5174 struct proc_dir_entry *dp = PDE(inode); 5167 struct proc_dir_entry *dp = PDE(inode);
@@ -5188,11 +5181,11 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) {
5188 switch(j%3) { 5181 switch(j%3) {
5189 case 0: 5182 case 0:
5190 APList_rid.ap[i][j/3]= 5183 APList_rid.ap[i][j/3]=
5191 hexVal(data->wbuffer[j+i*6*3])<<4; 5184 hex_to_bin(data->wbuffer[j+i*6*3])<<4;
5192 break; 5185 break;
5193 case 1: 5186 case 1:
5194 APList_rid.ap[i][j/3]|= 5187 APList_rid.ap[i][j/3]|=
5195 hexVal(data->wbuffer[j+i*6*3]); 5188 hex_to_bin(data->wbuffer[j+i*6*3]);
5196 break; 5189 break;
5197 } 5190 }
5198 } 5191 }
@@ -5340,10 +5333,10 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
5340 for( i = 0; i < 16*3 && data->wbuffer[i+j]; i++ ) { 5333 for( i = 0; i < 16*3 && data->wbuffer[i+j]; i++ ) {
5341 switch(i%3) { 5334 switch(i%3) {
5342 case 0: 5335 case 0:
5343 key[i/3] = hexVal(data->wbuffer[i+j])<<4; 5336 key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4;
5344 break; 5337 break;
5345 case 1: 5338 case 1:
5346 key[i/3] |= hexVal(data->wbuffer[i+j]); 5339 key[i/3] |= hex_to_bin(data->wbuffer[i+j]);
5347 break; 5340 break;
5348 } 5341 }
5349 } 5342 }
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index 82ab532a4923..a93dc18a45c3 100644
--- a/drivers/net/wireless/ath/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -739,17 +739,27 @@ err_out:
739static void ar9170_usb_firmware_failed(struct ar9170_usb *aru) 739static void ar9170_usb_firmware_failed(struct ar9170_usb *aru)
740{ 740{
741 struct device *parent = aru->udev->dev.parent; 741 struct device *parent = aru->udev->dev.parent;
742 struct usb_device *udev;
743
744 /*
745 * Store a copy of the usb_device pointer locally.
746 * This is because device_release_driver initiates
747 * ar9170_usb_disconnect, which in turn frees our
748 * driver context (aru).
749 */
750 udev = aru->udev;
742 751
743 complete(&aru->firmware_loading_complete); 752 complete(&aru->firmware_loading_complete);
744 753
745 /* unbind anything failed */ 754 /* unbind anything failed */
746 if (parent) 755 if (parent)
747 device_lock(parent); 756 device_lock(parent);
748 device_release_driver(&aru->udev->dev); 757
758 device_release_driver(&udev->dev);
749 if (parent) 759 if (parent)
750 device_unlock(parent); 760 device_unlock(parent);
751 761
752 usb_put_dev(aru->udev); 762 usb_put_dev(udev);
753} 763}
754 764
755static void ar9170_usb_firmware_finish(const struct firmware *fw, void *context) 765static void ar9170_usb_firmware_finish(const struct firmware *fw, void *context)
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 5f04cf38a5bc..648972df369d 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -195,7 +195,7 @@ static const struct ieee80211_rate ath5k_rates[] = {
195static int __devinit ath5k_pci_probe(struct pci_dev *pdev, 195static int __devinit ath5k_pci_probe(struct pci_dev *pdev,
196 const struct pci_device_id *id); 196 const struct pci_device_id *id);
197static void __devexit ath5k_pci_remove(struct pci_dev *pdev); 197static void __devexit ath5k_pci_remove(struct pci_dev *pdev);
198#ifdef CONFIG_PM 198#ifdef CONFIG_PM_SLEEP
199static int ath5k_pci_suspend(struct device *dev); 199static int ath5k_pci_suspend(struct device *dev);
200static int ath5k_pci_resume(struct device *dev); 200static int ath5k_pci_resume(struct device *dev);
201 201
@@ -203,7 +203,7 @@ static SIMPLE_DEV_PM_OPS(ath5k_pm_ops, ath5k_pci_suspend, ath5k_pci_resume);
203#define ATH5K_PM_OPS (&ath5k_pm_ops) 203#define ATH5K_PM_OPS (&ath5k_pm_ops)
204#else 204#else
205#define ATH5K_PM_OPS NULL 205#define ATH5K_PM_OPS NULL
206#endif /* CONFIG_PM */ 206#endif /* CONFIG_PM_SLEEP */
207 207
208static struct pci_driver ath5k_pci_driver = { 208static struct pci_driver ath5k_pci_driver = {
209 .name = KBUILD_MODNAME, 209 .name = KBUILD_MODNAME,
@@ -222,7 +222,6 @@ static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
222static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, 222static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
223 struct ath5k_txq *txq); 223 struct ath5k_txq *txq);
224static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan); 224static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan);
225static int ath5k_reset_wake(struct ath5k_softc *sc);
226static int ath5k_start(struct ieee80211_hw *hw); 225static int ath5k_start(struct ieee80211_hw *hw);
227static void ath5k_stop(struct ieee80211_hw *hw); 226static void ath5k_stop(struct ieee80211_hw *hw);
228static int ath5k_add_interface(struct ieee80211_hw *hw, 227static int ath5k_add_interface(struct ieee80211_hw *hw,
@@ -709,7 +708,7 @@ ath5k_pci_remove(struct pci_dev *pdev)
709 ieee80211_free_hw(hw); 708 ieee80211_free_hw(hw);
710} 709}
711 710
712#ifdef CONFIG_PM 711#ifdef CONFIG_PM_SLEEP
713static int ath5k_pci_suspend(struct device *dev) 712static int ath5k_pci_suspend(struct device *dev)
714{ 713{
715 struct ieee80211_hw *hw = pci_get_drvdata(to_pci_dev(dev)); 714 struct ieee80211_hw *hw = pci_get_drvdata(to_pci_dev(dev));
@@ -735,7 +734,7 @@ static int ath5k_pci_resume(struct device *dev)
735 ath5k_led_enable(sc); 734 ath5k_led_enable(sc);
736 return 0; 735 return 0;
737} 736}
738#endif /* CONFIG_PM */ 737#endif /* CONFIG_PM_SLEEP */
739 738
740 739
741/***********************\ 740/***********************\
@@ -1214,6 +1213,7 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1214 struct ath5k_hw *ah = sc->ah; 1213 struct ath5k_hw *ah = sc->ah;
1215 struct sk_buff *skb = bf->skb; 1214 struct sk_buff *skb = bf->skb;
1216 struct ath5k_desc *ds; 1215 struct ath5k_desc *ds;
1216 int ret;
1217 1217
1218 if (!skb) { 1218 if (!skb) {
1219 skb = ath5k_rx_skb_alloc(sc, &bf->skbaddr); 1219 skb = ath5k_rx_skb_alloc(sc, &bf->skbaddr);
@@ -1240,9 +1240,9 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
1240 ds = bf->desc; 1240 ds = bf->desc;
1241 ds->ds_link = bf->daddr; /* link to self */ 1241 ds->ds_link = bf->daddr; /* link to self */
1242 ds->ds_data = bf->skbaddr; 1242 ds->ds_data = bf->skbaddr;
1243 ah->ah_setup_rx_desc(ah, ds, 1243 ret = ah->ah_setup_rx_desc(ah, ds, ah->common.rx_bufsize, 0);
1244 skb_tailroom(skb), /* buffer size */ 1244 if (ret)
1245 0); 1245 return ret;
1246 1246
1247 if (sc->rxlink != NULL) 1247 if (sc->rxlink != NULL)
1248 *sc->rxlink = bf->daddr; 1248 *sc->rxlink = bf->daddr;
@@ -2769,7 +2769,7 @@ ath5k_tasklet_reset(unsigned long data)
2769{ 2769{
2770 struct ath5k_softc *sc = (void *)data; 2770 struct ath5k_softc *sc = (void *)data;
2771 2771
2772 ath5k_reset_wake(sc); 2772 ath5k_reset(sc, sc->curchan);
2773} 2773}
2774 2774
2775/* 2775/*
@@ -2940,23 +2940,13 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan)
2940 ath5k_beacon_config(sc); 2940 ath5k_beacon_config(sc);
2941 /* intrs are enabled by ath5k_beacon_config */ 2941 /* intrs are enabled by ath5k_beacon_config */
2942 2942
2943 ieee80211_wake_queues(sc->hw);
2944
2943 return 0; 2945 return 0;
2944err: 2946err:
2945 return ret; 2947 return ret;
2946} 2948}
2947 2949
2948static int
2949ath5k_reset_wake(struct ath5k_softc *sc)
2950{
2951 int ret;
2952
2953 ret = ath5k_reset(sc, sc->curchan);
2954 if (!ret)
2955 ieee80211_wake_queues(sc->hw);
2956
2957 return ret;
2958}
2959
2960static int ath5k_start(struct ieee80211_hw *hw) 2950static int ath5k_start(struct ieee80211_hw *hw)
2961{ 2951{
2962 return ath5k_init(hw->priv); 2952 return ath5k_init(hw->priv);
@@ -3150,13 +3140,15 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
3150 3140
3151 if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) { 3141 if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) {
3152 if (*new_flags & FIF_PROMISC_IN_BSS) { 3142 if (*new_flags & FIF_PROMISC_IN_BSS) {
3153 rfilt |= AR5K_RX_FILTER_PROM;
3154 __set_bit(ATH_STAT_PROMISC, sc->status); 3143 __set_bit(ATH_STAT_PROMISC, sc->status);
3155 } else { 3144 } else {
3156 __clear_bit(ATH_STAT_PROMISC, sc->status); 3145 __clear_bit(ATH_STAT_PROMISC, sc->status);
3157 } 3146 }
3158 } 3147 }
3159 3148
3149 if (test_bit(ATH_STAT_PROMISC, sc->status))
3150 rfilt |= AR5K_RX_FILTER_PROM;
3151
3160 /* Note, AR5K_RX_FILTER_MCAST is already enabled */ 3152 /* Note, AR5K_RX_FILTER_MCAST is already enabled */
3161 if (*new_flags & FIF_ALLMULTI) { 3153 if (*new_flags & FIF_ALLMULTI) {
3162 mfilt[0] = ~0; 3154 mfilt[0] = ~0;
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 1b81c4778800..492cbb15720d 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1814,6 +1814,13 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1814 u8 def_ant, tx_ant, ee_mode; 1814 u8 def_ant, tx_ant, ee_mode;
1815 u32 sta_id1 = 0; 1815 u32 sta_id1 = 0;
1816 1816
1817 /* if channel is not initialized yet we can't set the antennas
1818 * so just store the mode. it will be set on the next reset */
1819 if (channel == NULL) {
1820 ah->ah_ant_mode = ant_mode;
1821 return;
1822 }
1823
1817 def_ant = ah->ah_def_ant; 1824 def_ant = ah->ah_def_ant;
1818 1825
1819 ATH5K_TRACE(ah->ah_sc); 1826 ATH5K_TRACE(ah->ah_sc);
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index c8a4558f79ba..f43d85a302c4 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -76,22 +76,13 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,
76 ds = bf->bf_desc; 76 ds = bf->bf_desc;
77 flags = ATH9K_TXDESC_NOACK; 77 flags = ATH9K_TXDESC_NOACK;
78 78
79 if (((sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) || 79 ds->ds_link = 0;
80 (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) && 80 /*
81 (ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)) { 81 * Switch antenna every beacon.
82 ds->ds_link = bf->bf_daddr; /* self-linked */ 82 * Should only switch every beacon period, not for every SWBA
83 flags |= ATH9K_TXDESC_VEOL; 83 * XXX assumes two antennae
84 /* Let hardware handle antenna switching. */ 84 */
85 antenna = 0; 85 antenna = ((sc->beacon.ast_be_xmit / sc->nbcnvifs) & 1 ? 2 : 1);
86 } else {
87 ds->ds_link = 0;
88 /*
89 * Switch antenna every beacon.
90 * Should only switch every beacon period, not for every SWBA
91 * XXX assumes two antennae
92 */
93 antenna = ((sc->beacon.ast_be_xmit / sc->nbcnvifs) & 1 ? 2 : 1);
94 }
95 86
96 sband = &sc->sbands[common->hw->conf.channel->band]; 87 sband = &sc->sbands[common->hw->conf.channel->band];
97 rate = sband->bitrates[rateidx].hw_value; 88 rate = sband->bitrates[rateidx].hw_value;
@@ -215,36 +206,6 @@ static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
215 return bf; 206 return bf;
216} 207}
217 208
218/*
219 * Startup beacon transmission for adhoc mode when they are sent entirely
220 * by the hardware using the self-linked descriptor + veol trick.
221*/
222static void ath_beacon_start_adhoc(struct ath_softc *sc,
223 struct ieee80211_vif *vif)
224{
225 struct ath_hw *ah = sc->sc_ah;
226 struct ath_common *common = ath9k_hw_common(ah);
227 struct ath_buf *bf;
228 struct ath_vif *avp;
229 struct sk_buff *skb;
230
231 avp = (void *)vif->drv_priv;
232
233 if (avp->av_bcbuf == NULL)
234 return;
235
236 bf = avp->av_bcbuf;
237 skb = bf->bf_mpdu;
238
239 ath_beacon_setup(sc, avp, bf, 0);
240
241 /* NB: caller is known to have already stopped tx dma */
242 ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bf->bf_daddr);
243 ath9k_hw_txstart(ah, sc->beacon.beaconq);
244 ath_print(common, ATH_DBG_BEACON, "TXDP%u = %llx (%p)\n",
245 sc->beacon.beaconq, ito64(bf->bf_daddr), bf->bf_desc);
246}
247
248int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif) 209int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
249{ 210{
250 struct ath_softc *sc = aphy->sc; 211 struct ath_softc *sc = aphy->sc;
@@ -265,7 +226,8 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
265 list_del(&avp->av_bcbuf->list); 226 list_del(&avp->av_bcbuf->list);
266 227
267 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP || 228 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP ||
268 !(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)) { 229 sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC ||
230 sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) {
269 int slot; 231 int slot;
270 /* 232 /*
271 * Assign the vif to a beacon xmit slot. As 233 * Assign the vif to a beacon xmit slot. As
@@ -274,17 +236,11 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
274 avp->av_bslot = 0; 236 avp->av_bslot = 0;
275 for (slot = 0; slot < ATH_BCBUF; slot++) 237 for (slot = 0; slot < ATH_BCBUF; slot++)
276 if (sc->beacon.bslot[slot] == NULL) { 238 if (sc->beacon.bslot[slot] == NULL) {
277 /*
278 * XXX hack, space out slots to better
279 * deal with misses
280 */
281 if (slot+1 < ATH_BCBUF &&
282 sc->beacon.bslot[slot+1] == NULL) {
283 avp->av_bslot = slot+1;
284 break;
285 }
286 avp->av_bslot = slot; 239 avp->av_bslot = slot;
240
287 /* NB: keep looking for a double slot */ 241 /* NB: keep looking for a double slot */
242 if (slot == 0 || !sc->beacon.bslot[slot-1])
243 break;
288 } 244 }
289 BUG_ON(sc->beacon.bslot[avp->av_bslot] != NULL); 245 BUG_ON(sc->beacon.bslot[avp->av_bslot] != NULL);
290 sc->beacon.bslot[avp->av_bslot] = vif; 246 sc->beacon.bslot[avp->av_bslot] = vif;
@@ -721,8 +677,7 @@ static void ath_beacon_config_adhoc(struct ath_softc *sc,
721 * self-linked tx descriptor and let the hardware deal with things. 677 * self-linked tx descriptor and let the hardware deal with things.
722 */ 678 */
723 intval |= ATH9K_BEACON_ENA; 679 intval |= ATH9K_BEACON_ENA;
724 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)) 680 ah->imask |= ATH9K_INT_SWBA;
725 ah->imask |= ATH9K_INT_SWBA;
726 681
727 ath_beaconq_config(sc); 682 ath_beaconq_config(sc);
728 683
@@ -732,10 +687,6 @@ static void ath_beacon_config_adhoc(struct ath_softc *sc,
732 ath9k_beacon_init(sc, nexttbtt, intval); 687 ath9k_beacon_init(sc, nexttbtt, intval);
733 sc->beacon.bmisscnt = 0; 688 sc->beacon.bmisscnt = 0;
734 ath9k_hw_set_interrupts(ah, ah->imask); 689 ath9k_hw_set_interrupts(ah, ah->imask);
735
736 /* FIXME: Handle properly when vif is NULL */
737 if (vif && ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)
738 ath_beacon_start_adhoc(sc, vif);
739} 690}
740 691
741void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif) 692void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 46dc41a16faa..77b359162d6c 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -107,12 +107,14 @@ static inline void ath9k_skb_queue_purge(struct hif_device_usb *hif_dev,
107static void hif_usb_tx_cb(struct urb *urb) 107static void hif_usb_tx_cb(struct urb *urb)
108{ 108{
109 struct tx_buf *tx_buf = (struct tx_buf *) urb->context; 109 struct tx_buf *tx_buf = (struct tx_buf *) urb->context;
110 struct hif_device_usb *hif_dev = tx_buf->hif_dev; 110 struct hif_device_usb *hif_dev;
111 struct sk_buff *skb; 111 struct sk_buff *skb;
112 112
113 if (!hif_dev || !tx_buf) 113 if (!tx_buf || !tx_buf->hif_dev)
114 return; 114 return;
115 115
116 hif_dev = tx_buf->hif_dev;
117
116 switch (urb->status) { 118 switch (urb->status) {
117 case 0: 119 case 0:
118 break; 120 break;
@@ -607,6 +609,10 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
607 609
608 return 0; 610 return 0;
609err: 611err:
612 if (tx_buf) {
613 kfree(tx_buf->buf);
614 kfree(tx_buf);
615 }
610 ath9k_hif_usb_dealloc_tx_urbs(hif_dev); 616 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
611 return -ENOMEM; 617 return -ENOMEM;
612} 618}
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index ad556aa8da39..c251603ab032 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -23,6 +23,7 @@
23#include <linux/skbuff.h> 23#include <linux/skbuff.h>
24#include <linux/netdevice.h> 24#include <linux/netdevice.h>
25#include <linux/leds.h> 25#include <linux/leds.h>
26#include <linux/slab.h>
26#include <net/mac80211.h> 27#include <net/mac80211.h>
27 28
28#include "common.h" 29#include "common.h"
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 893b552981a0..abfa0493236f 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -752,7 +752,6 @@ static int ath_key_config(struct ath_common *common,
752 struct ath_hw *ah = common->ah; 752 struct ath_hw *ah = common->ah;
753 struct ath9k_keyval hk; 753 struct ath9k_keyval hk;
754 const u8 *mac = NULL; 754 const u8 *mac = NULL;
755 u8 gmac[ETH_ALEN];
756 int ret = 0; 755 int ret = 0;
757 int idx; 756 int idx;
758 757
@@ -776,30 +775,9 @@ static int ath_key_config(struct ath_common *common,
776 memcpy(hk.kv_val, key->key, key->keylen); 775 memcpy(hk.kv_val, key->key, key->keylen);
777 776
778 if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { 777 if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
779 778 /* For now, use the default keys for broadcast keys. This may
780 if (key->ap_addr) { 779 * need to change with virtual interfaces. */
781 /* 780 idx = key->keyidx;
782 * Group keys on hardware that supports multicast frame
783 * key search use a mac that is the sender's address with
784 * the high bit set instead of the app-specified address.
785 */
786 memcpy(gmac, key->ap_addr, ETH_ALEN);
787 gmac[0] |= 0x80;
788 mac = gmac;
789
790 if (key->alg == ALG_TKIP)
791 idx = ath_reserve_key_cache_slot_tkip(common);
792 else
793 idx = ath_reserve_key_cache_slot(common);
794 if (idx < 0)
795 mac = NULL; /* no free key cache entries */
796 }
797
798 if (!mac) {
799 /* For now, use the default keys for broadcast keys. This may
800 * need to change with virtual interfaces. */
801 idx = key->keyidx;
802 }
803 } else if (key->keyidx) { 781 } else if (key->keyidx) {
804 if (WARN_ON(!sta)) 782 if (WARN_ON(!sta))
805 return -EOPNOTSUPP; 783 return -EOPNOTSUPP;
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 257b10ba6f57..1ec836cf1c0d 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -28,7 +28,6 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = {
28 { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */ 28 { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */
29 { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI */ 29 { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI */
30 { PCI_VDEVICE(ATHEROS, 0x002E) }, /* PCI-E */ 30 { PCI_VDEVICE(ATHEROS, 0x002E) }, /* PCI-E */
31 { PCI_VDEVICE(ATHEROS, 0x0030) }, /* PCI-E AR9300 */
32 { 0 } 31 { 0 }
33}; 32};
34 33
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index ba139132c85f..ca6065b71b46 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -19,6 +19,12 @@
19 19
20#define SKB_CB_ATHBUF(__skb) (*((struct ath_buf **)__skb->cb)) 20#define SKB_CB_ATHBUF(__skb) (*((struct ath_buf **)__skb->cb))
21 21
22static inline bool ath9k_check_auto_sleep(struct ath_softc *sc)
23{
24 return sc->ps_enabled &&
25 (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP);
26}
27
22static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc, 28static struct ieee80211_hw * ath_get_virt_hw(struct ath_softc *sc,
23 struct ieee80211_hdr *hdr) 29 struct ieee80211_hdr *hdr)
24{ 30{
@@ -616,8 +622,8 @@ static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb)
616 hdr = (struct ieee80211_hdr *)skb->data; 622 hdr = (struct ieee80211_hdr *)skb->data;
617 623
618 /* Process Beacon and CAB receive in PS state */ 624 /* Process Beacon and CAB receive in PS state */
619 if ((sc->ps_flags & PS_WAIT_FOR_BEACON) && 625 if (((sc->ps_flags & PS_WAIT_FOR_BEACON) || ath9k_check_auto_sleep(sc))
620 ieee80211_is_beacon(hdr->frame_control)) 626 && ieee80211_is_beacon(hdr->frame_control))
621 ath_rx_ps_beacon(sc, skb); 627 ath_rx_ps_beacon(sc, skb);
622 else if ((sc->ps_flags & PS_WAIT_FOR_CAB) && 628 else if ((sc->ps_flags & PS_WAIT_FOR_CAB) &&
623 (ieee80211_is_data(hdr->frame_control) || 629 (ieee80211_is_data(hdr->frame_control) ||
@@ -932,9 +938,10 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
932 sc->rx.rxotherant = 0; 938 sc->rx.rxotherant = 0;
933 } 939 }
934 940
935 if (unlikely(sc->ps_flags & (PS_WAIT_FOR_BEACON | 941 if (unlikely(ath9k_check_auto_sleep(sc) ||
936 PS_WAIT_FOR_CAB | 942 (sc->ps_flags & (PS_WAIT_FOR_BEACON |
937 PS_WAIT_FOR_PSPOLL_DATA))) 943 PS_WAIT_FOR_CAB |
944 PS_WAIT_FOR_PSPOLL_DATA))))
938 ath_rx_ps(sc, skb); 945 ath_rx_ps(sc, skb);
939 946
940 ath_rx_send_to_mac80211(hw, sc, skb, rxs); 947 ath_rx_send_to_mac80211(hw, sc, skb, rxs);
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 3db19172b43b..859aa4ab0769 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1198,7 +1198,7 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
1198 int r; 1198 int r;
1199 1199
1200 ath_print(common, ATH_DBG_FATAL, 1200 ath_print(common, ATH_DBG_FATAL,
1201 "Unable to stop TxDMA. Reset HAL!\n"); 1201 "Failed to stop TX DMA. Resetting hardware!\n");
1202 1202
1203 spin_lock_bh(&sc->sc_resetlock); 1203 spin_lock_bh(&sc->sc_resetlock);
1204 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false); 1204 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false);
@@ -1728,6 +1728,8 @@ static int ath_tx_setup_buffer(struct ieee80211_hw *hw, struct ath_buf *bf,
1728 } else 1728 } else
1729 bf->bf_isnullfunc = false; 1729 bf->bf_isnullfunc = false;
1730 1730
1731 bf->bf_tx_aborted = false;
1732
1731 return 0; 1733 return 0;
1732} 1734}
1733 1735
@@ -1989,7 +1991,7 @@ static int ath_tx_num_badfrms(struct ath_softc *sc, struct ath_buf *bf,
1989 int nbad = 0; 1991 int nbad = 0;
1990 int isaggr = 0; 1992 int isaggr = 0;
1991 1993
1992 if (bf->bf_tx_aborted) 1994 if (bf->bf_lastbf->bf_tx_aborted)
1993 return 0; 1995 return 0;
1994 1996
1995 isaggr = bf_isaggr(bf); 1997 isaggr = bf_isaggr(bf);
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index d70732819423..ff9b5c882184 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -2618,15 +2618,6 @@ static irqreturn_t prism2_interrupt(int irq, void *dev_id)
2618 int events = 0; 2618 int events = 0;
2619 u16 ev; 2619 u16 ev;
2620 2620
2621 /* Detect early interrupt before driver is fully configued */
2622 if (!dev->base_addr) {
2623 if (net_ratelimit()) {
2624 printk(KERN_DEBUG "%s: Interrupt, but dev not configured\n",
2625 dev->name);
2626 }
2627 return IRQ_HANDLED;
2628 }
2629
2630 iface = netdev_priv(dev); 2621 iface = netdev_priv(dev);
2631 local = iface->local; 2622 local = iface->local;
2632 2623
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 068f7f8435c5..c44a303e62ed 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2852,6 +2852,7 @@ static struct iwl_lib_ops iwl3945_lib = {
2852 .isr = iwl_isr_legacy, 2852 .isr = iwl_isr_legacy,
2853 .config_ap = iwl3945_config_ap, 2853 .config_ap = iwl3945_config_ap,
2854 .manage_ibss_station = iwl3945_manage_ibss_station, 2854 .manage_ibss_station = iwl3945_manage_ibss_station,
2855 .recover_from_tx_stall = iwl_bg_monitor_recover,
2855 .check_plcp_health = iwl3945_good_plcp_health, 2856 .check_plcp_health = iwl3945_good_plcp_health,
2856 2857
2857 .debugfs_ops = { 2858 .debugfs_ops = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ict.c b/drivers/net/wireless/iwlwifi/iwl-agn-ict.c
index a273e373b7b0..c92b2c0cbd91 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ict.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ict.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/gfp.h>
33#include <net/mac80211.h> 34#include <net/mac80211.h>
34 35
35#include "iwl-dev.h" 36#include "iwl-dev.h"
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 1004cfc403b1..0f292a210ed9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -1119,10 +1119,9 @@ static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
1119 struct iwl_scan_channel *scan_ch) 1119 struct iwl_scan_channel *scan_ch)
1120{ 1120{
1121 const struct ieee80211_supported_band *sband; 1121 const struct ieee80211_supported_band *sband;
1122 const struct iwl_channel_info *ch_info;
1123 u16 passive_dwell = 0; 1122 u16 passive_dwell = 0;
1124 u16 active_dwell = 0; 1123 u16 active_dwell = 0;
1125 int i, added = 0; 1124 int added = 0;
1126 u16 channel = 0; 1125 u16 channel = 0;
1127 1126
1128 sband = iwl_get_hw_mode(priv, band); 1127 sband = iwl_get_hw_mode(priv, band);
@@ -1137,32 +1136,7 @@ static int iwl_get_single_channel_for_scan(struct iwl_priv *priv,
1137 if (passive_dwell <= active_dwell) 1136 if (passive_dwell <= active_dwell)
1138 passive_dwell = active_dwell + 1; 1137 passive_dwell = active_dwell + 1;
1139 1138
1140 /* only scan single channel, good enough to reset the RF */ 1139 channel = iwl_get_single_channel_number(priv, band);
1141 /* pick the first valid not in-use channel */
1142 if (band == IEEE80211_BAND_5GHZ) {
1143 for (i = 14; i < priv->channel_count; i++) {
1144 if (priv->channel_info[i].channel !=
1145 le16_to_cpu(priv->staging_rxon.channel)) {
1146 channel = priv->channel_info[i].channel;
1147 ch_info = iwl_get_channel_info(priv,
1148 band, channel);
1149 if (is_channel_valid(ch_info))
1150 break;
1151 }
1152 }
1153 } else {
1154 for (i = 0; i < 14; i++) {
1155 if (priv->channel_info[i].channel !=
1156 le16_to_cpu(priv->staging_rxon.channel)) {
1157 channel =
1158 priv->channel_info[i].channel;
1159 ch_info = iwl_get_channel_info(priv,
1160 band, channel);
1161 if (is_channel_valid(ch_info))
1162 break;
1163 }
1164 }
1165 }
1166 if (channel) { 1140 if (channel) {
1167 scan_ch->channel = cpu_to_le16(channel); 1141 scan_ch->channel = cpu_to_le16(channel);
1168 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; 1142 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index c402bfc83f36..a732f1094e5d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -1125,6 +1125,7 @@ static void iwlagn_tx_status(struct iwl_priv *priv, struct sk_buff *skb)
1125 struct ieee80211_sta *sta; 1125 struct ieee80211_sta *sta;
1126 struct iwl_station_priv *sta_priv; 1126 struct iwl_station_priv *sta_priv;
1127 1127
1128 rcu_read_lock();
1128 sta = ieee80211_find_sta(priv->vif, hdr->addr1); 1129 sta = ieee80211_find_sta(priv->vif, hdr->addr1);
1129 if (sta) { 1130 if (sta) {
1130 sta_priv = (void *)sta->drv_priv; 1131 sta_priv = (void *)sta->drv_priv;
@@ -1133,6 +1134,7 @@ static void iwlagn_tx_status(struct iwl_priv *priv, struct sk_buff *skb)
1133 atomic_dec_return(&sta_priv->pending_frames) == 0) 1134 atomic_dec_return(&sta_priv->pending_frames) == 0)
1134 ieee80211_sta_block_awake(priv->hw, sta, false); 1135 ieee80211_sta_block_awake(priv->hw, sta, false);
1135 } 1136 }
1137 rcu_read_unlock();
1136 1138
1137 ieee80211_tx_status_irqsafe(priv->hw, skb); 1139 ieee80211_tx_status_irqsafe(priv->hw, skb);
1138} 1140}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index aef4f71f1981..7726e67044c0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1484,6 +1484,156 @@ bool iwl_good_ack_health(struct iwl_priv *priv,
1484} 1484}
1485 1485
1486 1486
1487/*****************************************************************************
1488 *
1489 * sysfs attributes
1490 *
1491 *****************************************************************************/
1492
1493#ifdef CONFIG_IWLWIFI_DEBUG
1494
1495/*
1496 * The following adds a new attribute to the sysfs representation
1497 * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/)
1498 * used for controlling the debug level.
1499 *
1500 * See the level definitions in iwl for details.
1501 *
1502 * The debug_level being managed using sysfs below is a per device debug
1503 * level that is used instead of the global debug level if it (the per
1504 * device debug level) is set.
1505 */
1506static ssize_t show_debug_level(struct device *d,
1507 struct device_attribute *attr, char *buf)
1508{
1509 struct iwl_priv *priv = dev_get_drvdata(d);
1510 return sprintf(buf, "0x%08X\n", iwl_get_debug_level(priv));
1511}
1512static ssize_t store_debug_level(struct device *d,
1513 struct device_attribute *attr,
1514 const char *buf, size_t count)
1515{
1516 struct iwl_priv *priv = dev_get_drvdata(d);
1517 unsigned long val;
1518 int ret;
1519
1520 ret = strict_strtoul(buf, 0, &val);
1521 if (ret)
1522 IWL_ERR(priv, "%s is not in hex or decimal form.\n", buf);
1523 else {
1524 priv->debug_level = val;
1525 if (iwl_alloc_traffic_mem(priv))
1526 IWL_ERR(priv,
1527 "Not enough memory to generate traffic log\n");
1528 }
1529 return strnlen(buf, count);
1530}
1531
1532static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
1533 show_debug_level, store_debug_level);
1534
1535
1536#endif /* CONFIG_IWLWIFI_DEBUG */
1537
1538
1539static ssize_t show_temperature(struct device *d,
1540 struct device_attribute *attr, char *buf)
1541{
1542 struct iwl_priv *priv = dev_get_drvdata(d);
1543
1544 if (!iwl_is_alive(priv))
1545 return -EAGAIN;
1546
1547 return sprintf(buf, "%d\n", priv->temperature);
1548}
1549
1550static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL);
1551
1552static ssize_t show_tx_power(struct device *d,
1553 struct device_attribute *attr, char *buf)
1554{
1555 struct iwl_priv *priv = dev_get_drvdata(d);
1556
1557 if (!iwl_is_ready_rf(priv))
1558 return sprintf(buf, "off\n");
1559 else
1560 return sprintf(buf, "%d\n", priv->tx_power_user_lmt);
1561}
1562
1563static ssize_t store_tx_power(struct device *d,
1564 struct device_attribute *attr,
1565 const char *buf, size_t count)
1566{
1567 struct iwl_priv *priv = dev_get_drvdata(d);
1568 unsigned long val;
1569 int ret;
1570
1571 ret = strict_strtoul(buf, 10, &val);
1572 if (ret)
1573 IWL_INFO(priv, "%s is not in decimal form.\n", buf);
1574 else {
1575 ret = iwl_set_tx_power(priv, val, false);
1576 if (ret)
1577 IWL_ERR(priv, "failed setting tx power (0x%d).\n",
1578 ret);
1579 else
1580 ret = count;
1581 }
1582 return ret;
1583}
1584
1585static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
1586
1587static ssize_t show_rts_ht_protection(struct device *d,
1588 struct device_attribute *attr, char *buf)
1589{
1590 struct iwl_priv *priv = dev_get_drvdata(d);
1591
1592 return sprintf(buf, "%s\n",
1593 priv->cfg->use_rts_for_ht ? "RTS/CTS" : "CTS-to-self");
1594}
1595
1596static ssize_t store_rts_ht_protection(struct device *d,
1597 struct device_attribute *attr,
1598 const char *buf, size_t count)
1599{
1600 struct iwl_priv *priv = dev_get_drvdata(d);
1601 unsigned long val;
1602 int ret;
1603
1604 ret = strict_strtoul(buf, 10, &val);
1605 if (ret)
1606 IWL_INFO(priv, "Input is not in decimal form.\n");
1607 else {
1608 if (!iwl_is_associated(priv))
1609 priv->cfg->use_rts_for_ht = val ? true : false;
1610 else
1611 IWL_ERR(priv, "Sta associated with AP - "
1612 "Change protection mechanism is not allowed\n");
1613 ret = count;
1614 }
1615 return ret;
1616}
1617
1618static DEVICE_ATTR(rts_ht_protection, S_IWUSR | S_IRUGO,
1619 show_rts_ht_protection, store_rts_ht_protection);
1620
1621
1622static struct attribute *iwl_sysfs_entries[] = {
1623 &dev_attr_temperature.attr,
1624 &dev_attr_tx_power.attr,
1625 &dev_attr_rts_ht_protection.attr,
1626#ifdef CONFIG_IWLWIFI_DEBUG
1627 &dev_attr_debug_level.attr,
1628#endif
1629 NULL
1630};
1631
1632static struct attribute_group iwl_attribute_group = {
1633 .name = NULL, /* put in device directory */
1634 .attrs = iwl_sysfs_entries,
1635};
1636
1487/****************************************************************************** 1637/******************************************************************************
1488 * 1638 *
1489 * uCode download functions 1639 * uCode download functions
@@ -1965,6 +2115,13 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1965 if (err) 2115 if (err)
1966 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); 2116 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
1967 2117
2118 err = sysfs_create_group(&priv->pci_dev->dev.kobj,
2119 &iwl_attribute_group);
2120 if (err) {
2121 IWL_ERR(priv, "failed to create sysfs device attributes\n");
2122 goto out_unbind;
2123 }
2124
1968 /* We have our copies now, allow OS release its copies */ 2125 /* We have our copies now, allow OS release its copies */
1969 release_firmware(ucode_raw); 2126 release_firmware(ucode_raw);
1970 complete(&priv->_agn.firmware_loading_complete); 2127 complete(&priv->_agn.firmware_loading_complete);
@@ -3264,141 +3421,6 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3264 3421
3265/***************************************************************************** 3422/*****************************************************************************
3266 * 3423 *
3267 * sysfs attributes
3268 *
3269 *****************************************************************************/
3270
3271#ifdef CONFIG_IWLWIFI_DEBUG
3272
3273/*
3274 * The following adds a new attribute to the sysfs representation
3275 * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/)
3276 * used for controlling the debug level.
3277 *
3278 * See the level definitions in iwl for details.
3279 *
3280 * The debug_level being managed using sysfs below is a per device debug
3281 * level that is used instead of the global debug level if it (the per
3282 * device debug level) is set.
3283 */
3284static ssize_t show_debug_level(struct device *d,
3285 struct device_attribute *attr, char *buf)
3286{
3287 struct iwl_priv *priv = dev_get_drvdata(d);
3288 return sprintf(buf, "0x%08X\n", iwl_get_debug_level(priv));
3289}
3290static ssize_t store_debug_level(struct device *d,
3291 struct device_attribute *attr,
3292 const char *buf, size_t count)
3293{
3294 struct iwl_priv *priv = dev_get_drvdata(d);
3295 unsigned long val;
3296 int ret;
3297
3298 ret = strict_strtoul(buf, 0, &val);
3299 if (ret)
3300 IWL_ERR(priv, "%s is not in hex or decimal form.\n", buf);
3301 else {
3302 priv->debug_level = val;
3303 if (iwl_alloc_traffic_mem(priv))
3304 IWL_ERR(priv,
3305 "Not enough memory to generate traffic log\n");
3306 }
3307 return strnlen(buf, count);
3308}
3309
3310static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
3311 show_debug_level, store_debug_level);
3312
3313
3314#endif /* CONFIG_IWLWIFI_DEBUG */
3315
3316
3317static ssize_t show_temperature(struct device *d,
3318 struct device_attribute *attr, char *buf)
3319{
3320 struct iwl_priv *priv = dev_get_drvdata(d);
3321
3322 if (!iwl_is_alive(priv))
3323 return -EAGAIN;
3324
3325 return sprintf(buf, "%d\n", priv->temperature);
3326}
3327
3328static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL);
3329
3330static ssize_t show_tx_power(struct device *d,
3331 struct device_attribute *attr, char *buf)
3332{
3333 struct iwl_priv *priv = dev_get_drvdata(d);
3334
3335 if (!iwl_is_ready_rf(priv))
3336 return sprintf(buf, "off\n");
3337 else
3338 return sprintf(buf, "%d\n", priv->tx_power_user_lmt);
3339}
3340
3341static ssize_t store_tx_power(struct device *d,
3342 struct device_attribute *attr,
3343 const char *buf, size_t count)
3344{
3345 struct iwl_priv *priv = dev_get_drvdata(d);
3346 unsigned long val;
3347 int ret;
3348
3349 ret = strict_strtoul(buf, 10, &val);
3350 if (ret)
3351 IWL_INFO(priv, "%s is not in decimal form.\n", buf);
3352 else {
3353 ret = iwl_set_tx_power(priv, val, false);
3354 if (ret)
3355 IWL_ERR(priv, "failed setting tx power (0x%d).\n",
3356 ret);
3357 else
3358 ret = count;
3359 }
3360 return ret;
3361}
3362
3363static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
3364
3365static ssize_t show_rts_ht_protection(struct device *d,
3366 struct device_attribute *attr, char *buf)
3367{
3368 struct iwl_priv *priv = dev_get_drvdata(d);
3369
3370 return sprintf(buf, "%s\n",
3371 priv->cfg->use_rts_for_ht ? "RTS/CTS" : "CTS-to-self");
3372}
3373
3374static ssize_t store_rts_ht_protection(struct device *d,
3375 struct device_attribute *attr,
3376 const char *buf, size_t count)
3377{
3378 struct iwl_priv *priv = dev_get_drvdata(d);
3379 unsigned long val;
3380 int ret;
3381
3382 ret = strict_strtoul(buf, 10, &val);
3383 if (ret)
3384 IWL_INFO(priv, "Input is not in decimal form.\n");
3385 else {
3386 if (!iwl_is_associated(priv))
3387 priv->cfg->use_rts_for_ht = val ? true : false;
3388 else
3389 IWL_ERR(priv, "Sta associated with AP - "
3390 "Change protection mechanism is not allowed\n");
3391 ret = count;
3392 }
3393 return ret;
3394}
3395
3396static DEVICE_ATTR(rts_ht_protection, S_IWUSR | S_IRUGO,
3397 show_rts_ht_protection, store_rts_ht_protection);
3398
3399
3400/*****************************************************************************
3401 *
3402 * driver setup and teardown 3424 * driver setup and teardown
3403 * 3425 *
3404 *****************************************************************************/ 3426 *****************************************************************************/
@@ -3550,21 +3572,6 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
3550 kfree(priv->scan_cmd); 3572 kfree(priv->scan_cmd);
3551} 3573}
3552 3574
3553static struct attribute *iwl_sysfs_entries[] = {
3554 &dev_attr_temperature.attr,
3555 &dev_attr_tx_power.attr,
3556 &dev_attr_rts_ht_protection.attr,
3557#ifdef CONFIG_IWLWIFI_DEBUG
3558 &dev_attr_debug_level.attr,
3559#endif
3560 NULL
3561};
3562
3563static struct attribute_group iwl_attribute_group = {
3564 .name = NULL, /* put in device directory */
3565 .attrs = iwl_sysfs_entries,
3566};
3567
3568static struct ieee80211_ops iwl_hw_ops = { 3575static struct ieee80211_ops iwl_hw_ops = {
3569 .tx = iwl_mac_tx, 3576 .tx = iwl_mac_tx,
3570 .start = iwl_mac_start, 3577 .start = iwl_mac_start,
@@ -3750,11 +3757,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3750 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); 3757 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq);
3751 goto out_disable_msi; 3758 goto out_disable_msi;
3752 } 3759 }
3753 err = sysfs_create_group(&pdev->dev.kobj, &iwl_attribute_group);
3754 if (err) {
3755 IWL_ERR(priv, "failed to create sysfs device attributes\n");
3756 goto out_free_irq;
3757 }
3758 3760
3759 iwl_setup_deferred_work(priv); 3761 iwl_setup_deferred_work(priv);
3760 iwl_setup_rx_handlers(priv); 3762 iwl_setup_rx_handlers(priv);
@@ -3788,15 +3790,13 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3788 3790
3789 err = iwl_request_firmware(priv, true); 3791 err = iwl_request_firmware(priv, true);
3790 if (err) 3792 if (err)
3791 goto out_remove_sysfs; 3793 goto out_destroy_workqueue;
3792 3794
3793 return 0; 3795 return 0;
3794 3796
3795 out_remove_sysfs: 3797 out_destroy_workqueue:
3796 destroy_workqueue(priv->workqueue); 3798 destroy_workqueue(priv->workqueue);
3797 priv->workqueue = NULL; 3799 priv->workqueue = NULL;
3798 sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group);
3799 out_free_irq:
3800 free_irq(priv->pci_dev->irq, priv); 3800 free_irq(priv->pci_dev->irq, priv);
3801 iwl_free_isr_ict(priv); 3801 iwl_free_isr_ict(priv);
3802 out_disable_msi: 3802 out_disable_msi:
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 5a7eca8fb789..426e95567de3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -854,6 +854,45 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
854} 854}
855EXPORT_SYMBOL(iwl_set_rxon_chain); 855EXPORT_SYMBOL(iwl_set_rxon_chain);
856 856
857/* Return valid channel */
858u8 iwl_get_single_channel_number(struct iwl_priv *priv,
859 enum ieee80211_band band)
860{
861 const struct iwl_channel_info *ch_info;
862 int i;
863 u8 channel = 0;
864
865 /* only scan single channel, good enough to reset the RF */
866 /* pick the first valid not in-use channel */
867 if (band == IEEE80211_BAND_5GHZ) {
868 for (i = 14; i < priv->channel_count; i++) {
869 if (priv->channel_info[i].channel !=
870 le16_to_cpu(priv->staging_rxon.channel)) {
871 channel = priv->channel_info[i].channel;
872 ch_info = iwl_get_channel_info(priv,
873 band, channel);
874 if (is_channel_valid(ch_info))
875 break;
876 }
877 }
878 } else {
879 for (i = 0; i < 14; i++) {
880 if (priv->channel_info[i].channel !=
881 le16_to_cpu(priv->staging_rxon.channel)) {
882 channel =
883 priv->channel_info[i].channel;
884 ch_info = iwl_get_channel_info(priv,
885 band, channel);
886 if (is_channel_valid(ch_info))
887 break;
888 }
889 }
890 }
891
892 return channel;
893}
894EXPORT_SYMBOL(iwl_get_single_channel_number);
895
857/** 896/**
858 * iwl_set_rxon_channel - Set the phymode and channel values in staging RXON 897 * iwl_set_rxon_channel - Set the phymode and channel values in staging RXON
859 * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz 898 * @phymode: MODE_IEEE80211A sets to 5.2GHz; all else set to 2.4GHz
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 7e5a5ba41fd2..31775bd9c361 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -343,6 +343,8 @@ int iwl_check_rxon_cmd(struct iwl_priv *priv);
343int iwl_full_rxon_required(struct iwl_priv *priv); 343int iwl_full_rxon_required(struct iwl_priv *priv);
344void iwl_set_rxon_chain(struct iwl_priv *priv); 344void iwl_set_rxon_chain(struct iwl_priv *priv);
345int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch); 345int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch);
346u8 iwl_get_single_channel_number(struct iwl_priv *priv,
347 enum ieee80211_band band);
346void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf); 348void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
347u8 iwl_is_ht40_tx_allowed(struct iwl_priv *priv, 349u8 iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
348 struct ieee80211_sta_ht_cap *sta_ht_inf); 350 struct ieee80211_sta_ht_cap *sta_ht_inf);
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 107e173112f6..5d3f51ff2f0d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -376,6 +376,11 @@ void iwl_bg_start_internal_scan(struct work_struct *work)
376 376
377 mutex_lock(&priv->mutex); 377 mutex_lock(&priv->mutex);
378 378
379 if (priv->is_internal_short_scan == true) {
380 IWL_DEBUG_SCAN(priv, "Internal scan already in progress\n");
381 goto unlock;
382 }
383
379 if (!iwl_is_ready_rf(priv)) { 384 if (!iwl_is_ready_rf(priv)) {
380 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n"); 385 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n");
381 goto unlock; 386 goto unlock;
@@ -497,17 +502,27 @@ void iwl_bg_scan_completed(struct work_struct *work)
497{ 502{
498 struct iwl_priv *priv = 503 struct iwl_priv *priv =
499 container_of(work, struct iwl_priv, scan_completed); 504 container_of(work, struct iwl_priv, scan_completed);
505 bool internal = false;
500 506
501 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n"); 507 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n");
502 508
503 cancel_delayed_work(&priv->scan_check); 509 cancel_delayed_work(&priv->scan_check);
504 510
505 if (!priv->is_internal_short_scan) 511 mutex_lock(&priv->mutex);
506 ieee80211_scan_completed(priv->hw, false); 512 if (priv->is_internal_short_scan) {
507 else {
508 priv->is_internal_short_scan = false; 513 priv->is_internal_short_scan = false;
509 IWL_DEBUG_SCAN(priv, "internal short scan completed\n"); 514 IWL_DEBUG_SCAN(priv, "internal short scan completed\n");
515 internal = true;
510 } 516 }
517 mutex_unlock(&priv->mutex);
518
519 /*
520 * Do not hold mutex here since this will cause mac80211 to call
521 * into driver again into functions that will attempt to take
522 * mutex.
523 */
524 if (!internal)
525 ieee80211_scan_completed(priv->hw, false);
511 526
512 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 527 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
513 return; 528 return;
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 85ed235ac901..83a26361a9b5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -431,7 +431,7 @@ int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs,
431 struct iwl_link_quality_cmd *link_cmd; 431 struct iwl_link_quality_cmd *link_cmd;
432 unsigned long flags; 432 unsigned long flags;
433 433
434 if (*sta_id_r) 434 if (sta_id_r)
435 *sta_id_r = IWL_INVALID_STATION; 435 *sta_id_r = IWL_INVALID_STATION;
436 436
437 ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id); 437 ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 3e5bffb6034f..6c353cacc8d6 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1844,6 +1844,49 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
1844#endif 1844#endif
1845} 1845}
1846 1846
1847static int iwl3945_get_single_channel_for_scan(struct iwl_priv *priv,
1848 struct ieee80211_vif *vif,
1849 enum ieee80211_band band,
1850 struct iwl3945_scan_channel *scan_ch)
1851{
1852 const struct ieee80211_supported_band *sband;
1853 u16 passive_dwell = 0;
1854 u16 active_dwell = 0;
1855 int added = 0;
1856 u8 channel = 0;
1857
1858 sband = iwl_get_hw_mode(priv, band);
1859 if (!sband) {
1860 IWL_ERR(priv, "invalid band\n");
1861 return added;
1862 }
1863
1864 active_dwell = iwl_get_active_dwell_time(priv, band, 0);
1865 passive_dwell = iwl_get_passive_dwell_time(priv, band, vif);
1866
1867 if (passive_dwell <= active_dwell)
1868 passive_dwell = active_dwell + 1;
1869
1870
1871 channel = iwl_get_single_channel_number(priv, band);
1872
1873 if (channel) {
1874 scan_ch->channel = channel;
1875 scan_ch->type = 0; /* passive */
1876 scan_ch->active_dwell = cpu_to_le16(active_dwell);
1877 scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
1878 /* Set txpower levels to defaults */
1879 scan_ch->tpc.dsp_atten = 110;
1880 if (band == IEEE80211_BAND_5GHZ)
1881 scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3;
1882 else
1883 scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3));
1884 added++;
1885 } else
1886 IWL_ERR(priv, "no valid channel found\n");
1887 return added;
1888}
1889
1847static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, 1890static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
1848 enum ieee80211_band band, 1891 enum ieee80211_band band,
1849 u8 is_active, u8 n_probes, 1892 u8 is_active, u8 n_probes,
@@ -2992,9 +3035,16 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2992 /* select Rx antennas */ 3035 /* select Rx antennas */
2993 scan->flags |= iwl3945_get_antenna_flags(priv); 3036 scan->flags |= iwl3945_get_antenna_flags(priv);
2994 3037
2995 scan->channel_count = 3038 if (priv->is_internal_short_scan) {
2996 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, 3039 scan->channel_count =
2997 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)], vif); 3040 iwl3945_get_single_channel_for_scan(priv, vif, band,
3041 (void *)&scan->data[le16_to_cpu(
3042 scan->tx_cmd.len)]);
3043 } else {
3044 scan->channel_count =
3045 iwl3945_get_channels_for_scan(priv, band, is_active, n_probes,
3046 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)], vif);
3047 }
2998 3048
2999 if (scan->channel_count == 0) { 3049 if (scan->channel_count == 0) {
3000 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 3050 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index a115bfa9513a..7a377f5b7662 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -329,9 +329,8 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
329 /* create the exported radio header */ 329 /* create the exported radio header */
330 330
331 /* radiotap header */ 331 /* radiotap header */
332 radiotap_hdr.hdr.it_version = 0; 332 memset(&radiotap_hdr, 0, sizeof(radiotap_hdr));
333 /* XXX must check this value for pad */ 333 /* XXX must check radiotap_hdr.hdr.it_pad for pad */
334 radiotap_hdr.hdr.it_pad = 0;
335 radiotap_hdr.hdr.it_len = cpu_to_le16 (sizeof(struct rx_radiotap_hdr)); 334 radiotap_hdr.hdr.it_len = cpu_to_le16 (sizeof(struct rx_radiotap_hdr));
336 radiotap_hdr.hdr.it_present = cpu_to_le32 (RX_RADIOTAP_PRESENT); 335 radiotap_hdr.hdr.it_present = cpu_to_le32 (RX_RADIOTAP_PRESENT);
337 radiotap_hdr.rate = convert_mv_rate_to_radiotap(prxpd->rx_rate); 336 radiotap_hdr.rate = convert_mv_rate_to_radiotap(prxpd->rx_rate);
diff --git a/drivers/net/wireless/orinoco/airport.c b/drivers/net/wireless/orinoco/airport.c
index 9bcee10c9308..4a0a0e5265c9 100644
--- a/drivers/net/wireless/orinoco/airport.c
+++ b/drivers/net/wireless/orinoco/airport.c
@@ -239,8 +239,11 @@ static struct of_device_id airport_match[] =
239MODULE_DEVICE_TABLE(of, airport_match); 239MODULE_DEVICE_TABLE(of, airport_match);
240 240
241static struct macio_driver airport_driver = { 241static struct macio_driver airport_driver = {
242 .name = DRIVER_NAME, 242 .driver = {
243 .match_table = airport_match, 243 .name = DRIVER_NAME,
244 .owner = THIS_MODULE,
245 .of_match_table = airport_match,
246 },
244 .probe = airport_attach, 247 .probe = airport_attach,
245 .remove = airport_detach, 248 .remove = airport_detach,
246 .suspend = airport_suspend, 249 .suspend = airport_suspend,
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index d5b197b4d5bb..73073259f508 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -80,6 +80,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
80 {USB_DEVICE(0x1413, 0x5400)}, /* Telsey 802.11g USB2.0 Adapter */ 80 {USB_DEVICE(0x1413, 0x5400)}, /* Telsey 802.11g USB2.0 Adapter */
81 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */ 81 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
82 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */ 82 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */
83 {USB_DEVICE(0x413c, 0x5513)}, /* Dell WLA3310 USB Wireless Adapter */
83 {USB_DEVICE(0x413c, 0x8102)}, /* Spinnaker DUT */ 84 {USB_DEVICE(0x413c, 0x8102)}, /* Spinnaker DUT */
84 {USB_DEVICE(0x413c, 0x8104)}, /* Cohiba Proto board */ 85 {USB_DEVICE(0x413c, 0x8104)}, /* Cohiba Proto board */
85 {} 86 {}
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 2d2890878dea..4bd61ee627c0 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2572,14 +2572,18 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
2572 2572
2573static void rndis_wlan_do_link_down_work(struct usbnet *usbdev) 2573static void rndis_wlan_do_link_down_work(struct usbnet *usbdev)
2574{ 2574{
2575 union iwreq_data evt; 2575 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
2576 2576
2577 netif_carrier_off(usbdev->net); 2577 if (priv->connected) {
2578 priv->connected = false;
2579 memset(priv->bssid, 0, ETH_ALEN);
2580
2581 deauthenticate(usbdev);
2578 2582
2579 evt.data.flags = 0; 2583 cfg80211_disconnected(usbdev->net, 0, NULL, 0, GFP_KERNEL);
2580 evt.data.length = 0; 2584 }
2581 memset(evt.ap_addr.sa_data, 0, ETH_ALEN); 2585
2582 wireless_send_event(usbdev->net, SIOCGIWAP, &evt, NULL); 2586 netif_carrier_off(usbdev->net);
2583} 2587}
2584 2588
2585static void rndis_wlan_worker(struct work_struct *work) 2589static void rndis_wlan_worker(struct work_struct *work)
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 4ba7b038928f..ad2c98af7e9d 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -926,7 +926,7 @@ static void rt2400pci_disable_radio(struct rt2x00_dev *rt2x00dev)
926static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev, 926static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev,
927 enum dev_state state) 927 enum dev_state state)
928{ 928{
929 u32 reg; 929 u32 reg, reg2;
930 unsigned int i; 930 unsigned int i;
931 char put_to_sleep; 931 char put_to_sleep;
932 char bbp_state; 932 char bbp_state;
@@ -947,11 +947,12 @@ static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev,
947 * device has entered the correct state. 947 * device has entered the correct state.
948 */ 948 */
949 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 949 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
950 rt2x00pci_register_read(rt2x00dev, PWRCSR1, &reg); 950 rt2x00pci_register_read(rt2x00dev, PWRCSR1, &reg2);
951 bbp_state = rt2x00_get_field32(reg, PWRCSR1_BBP_CURR_STATE); 951 bbp_state = rt2x00_get_field32(reg2, PWRCSR1_BBP_CURR_STATE);
952 rf_state = rt2x00_get_field32(reg, PWRCSR1_RF_CURR_STATE); 952 rf_state = rt2x00_get_field32(reg2, PWRCSR1_RF_CURR_STATE);
953 if (bbp_state == state && rf_state == state) 953 if (bbp_state == state && rf_state == state)
954 return 0; 954 return 0;
955 rt2x00pci_register_write(rt2x00dev, PWRCSR1, reg);
955 msleep(10); 956 msleep(10);
956 } 957 }
957 958
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 89d132d4af12..41da3d218c65 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1084,7 +1084,7 @@ static void rt2500pci_disable_radio(struct rt2x00_dev *rt2x00dev)
1084static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev, 1084static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
1085 enum dev_state state) 1085 enum dev_state state)
1086{ 1086{
1087 u32 reg; 1087 u32 reg, reg2;
1088 unsigned int i; 1088 unsigned int i;
1089 char put_to_sleep; 1089 char put_to_sleep;
1090 char bbp_state; 1090 char bbp_state;
@@ -1105,11 +1105,12 @@ static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
1105 * device has entered the correct state. 1105 * device has entered the correct state.
1106 */ 1106 */
1107 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1107 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1108 rt2x00pci_register_read(rt2x00dev, PWRCSR1, &reg); 1108 rt2x00pci_register_read(rt2x00dev, PWRCSR1, &reg2);
1109 bbp_state = rt2x00_get_field32(reg, PWRCSR1_BBP_CURR_STATE); 1109 bbp_state = rt2x00_get_field32(reg2, PWRCSR1_BBP_CURR_STATE);
1110 rf_state = rt2x00_get_field32(reg, PWRCSR1_RF_CURR_STATE); 1110 rf_state = rt2x00_get_field32(reg2, PWRCSR1_RF_CURR_STATE);
1111 if (bbp_state == state && rf_state == state) 1111 if (bbp_state == state && rf_state == state)
1112 return 0; 1112 return 0;
1113 rt2x00pci_register_write(rt2x00dev, PWRCSR1, reg);
1113 msleep(10); 1114 msleep(10);
1114 } 1115 }
1115 1116
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index a016f7ccde29..f71eee67f977 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -206,7 +206,7 @@ void rt2x00pci_uninitialize(struct rt2x00_dev *rt2x00dev)
206 /* 206 /*
207 * Free irq line. 207 * Free irq line.
208 */ 208 */
209 free_irq(to_pci_dev(rt2x00dev->dev)->irq, rt2x00dev); 209 free_irq(rt2x00dev->irq, rt2x00dev);
210 210
211 /* 211 /*
212 * Free DMA 212 * Free DMA
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 2e3076f67535..6a74baf4e934 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1689,7 +1689,7 @@ static void rt61pci_disable_radio(struct rt2x00_dev *rt2x00dev)
1689 1689
1690static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state) 1690static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
1691{ 1691{
1692 u32 reg; 1692 u32 reg, reg2;
1693 unsigned int i; 1693 unsigned int i;
1694 char put_to_sleep; 1694 char put_to_sleep;
1695 1695
@@ -1706,10 +1706,11 @@ static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
1706 * device has entered the correct state. 1706 * device has entered the correct state.
1707 */ 1707 */
1708 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1708 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1709 rt2x00pci_register_read(rt2x00dev, MAC_CSR12, &reg); 1709 rt2x00pci_register_read(rt2x00dev, MAC_CSR12, &reg2);
1710 state = rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE); 1710 state = rt2x00_get_field32(reg2, MAC_CSR12_BBP_CURRENT_STATE);
1711 if (state == !put_to_sleep) 1711 if (state == !put_to_sleep)
1712 return 0; 1712 return 0;
1713 rt2x00pci_register_write(rt2x00dev, MAC_CSR12, reg);
1713 msleep(10); 1714 msleep(10);
1714 } 1715 }
1715 1716
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index e35bd19c3c5a..6e0d82efe924 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1366,7 +1366,7 @@ static void rt73usb_disable_radio(struct rt2x00_dev *rt2x00dev)
1366 1366
1367static int rt73usb_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state) 1367static int rt73usb_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
1368{ 1368{
1369 u32 reg; 1369 u32 reg, reg2;
1370 unsigned int i; 1370 unsigned int i;
1371 char put_to_sleep; 1371 char put_to_sleep;
1372 1372
@@ -1383,10 +1383,11 @@ static int rt73usb_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
1383 * device has entered the correct state. 1383 * device has entered the correct state.
1384 */ 1384 */
1385 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 1385 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1386 rt2x00usb_register_read(rt2x00dev, MAC_CSR12, &reg); 1386 rt2x00usb_register_read(rt2x00dev, MAC_CSR12, &reg2);
1387 state = rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE); 1387 state = rt2x00_get_field32(reg2, MAC_CSR12_BBP_CURRENT_STATE);
1388 if (state == !put_to_sleep) 1388 if (state == !put_to_sleep)
1389 return 0; 1389 return 0;
1390 rt2x00usb_register_write(rt2x00dev, MAC_CSR12, reg);
1390 msleep(10); 1391 msleep(10);
1391 } 1392 }
1392 1393
diff --git a/drivers/net/wireless/wl12xx/wl1251_sdio.c b/drivers/net/wireless/wl12xx/wl1251_sdio.c
index d234285c2c81..c561332e7009 100644
--- a/drivers/net/wireless/wl12xx/wl1251_sdio.c
+++ b/drivers/net/wireless/wl12xx/wl1251_sdio.c
@@ -259,6 +259,7 @@ disable:
259 sdio_disable_func(func); 259 sdio_disable_func(func);
260release: 260release:
261 sdio_release_host(func); 261 sdio_release_host(func);
262 wl1251_free_hw(wl);
262 return ret; 263 return ret;
263} 264}
264 265
diff --git a/drivers/net/wireless/wl12xx/wl1271_rx.c b/drivers/net/wireless/wl12xx/wl1271_rx.c
index 57f4bfd959c8..b98fb643fab0 100644
--- a/drivers/net/wireless/wl12xx/wl1271_rx.c
+++ b/drivers/net/wireless/wl12xx/wl1271_rx.c
@@ -113,6 +113,8 @@ static void wl1271_rx_handle_data(struct wl1271 *wl, u32 length)
113 wl1271_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len, 113 wl1271_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len,
114 beacon ? "beacon" : ""); 114 beacon ? "beacon" : "");
115 115
116 skb_trim(skb, skb->len - desc->pad_len);
117
116 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); 118 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
117 ieee80211_rx_ni(wl->hw, skb); 119 ieee80211_rx_ni(wl->hw, skb);
118} 120}
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index a7db68d37ee9..d04c5b262050 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -1088,7 +1088,7 @@ static void xemaclite_remove_ndev(struct net_device *ndev)
1088 */ 1088 */
1089static bool get_bool(struct of_device *ofdev, const char *s) 1089static bool get_bool(struct of_device *ofdev, const char *s)
1090{ 1090{
1091 u32 *p = (u32 *)of_get_property(ofdev->node, s, NULL); 1091 u32 *p = (u32 *)of_get_property(ofdev->dev.of_node, s, NULL);
1092 1092
1093 if (p) { 1093 if (p) {
1094 return (bool)*p; 1094 return (bool)*p;
@@ -1130,14 +1130,14 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev,
1130 dev_info(dev, "Device Tree Probing\n"); 1130 dev_info(dev, "Device Tree Probing\n");
1131 1131
1132 /* Get iospace for the device */ 1132 /* Get iospace for the device */
1133 rc = of_address_to_resource(ofdev->node, 0, &r_mem); 1133 rc = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
1134 if (rc) { 1134 if (rc) {
1135 dev_err(dev, "invalid address\n"); 1135 dev_err(dev, "invalid address\n");
1136 return rc; 1136 return rc;
1137 } 1137 }
1138 1138
1139 /* Get IRQ for the device */ 1139 /* Get IRQ for the device */
1140 rc = of_irq_to_resource(ofdev->node, 0, &r_irq); 1140 rc = of_irq_to_resource(ofdev->dev.of_node, 0, &r_irq);
1141 if (rc == NO_IRQ) { 1141 if (rc == NO_IRQ) {
1142 dev_err(dev, "no IRQ found\n"); 1142 dev_err(dev, "no IRQ found\n");
1143 return rc; 1143 return rc;
@@ -1182,7 +1182,7 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev,
1182 lp->next_rx_buf_to_use = 0x0; 1182 lp->next_rx_buf_to_use = 0x0;
1183 lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong"); 1183 lp->tx_ping_pong = get_bool(ofdev, "xlnx,tx-ping-pong");
1184 lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); 1184 lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
1185 mac_address = of_get_mac_address(ofdev->node); 1185 mac_address = of_get_mac_address(ofdev->dev.of_node);
1186 1186
1187 if (mac_address) 1187 if (mac_address)
1188 /* Set the MAC address. */ 1188 /* Set the MAC address. */
@@ -1197,7 +1197,7 @@ static int __devinit xemaclite_of_probe(struct of_device *ofdev,
1197 /* Set the MAC address in the EmacLite device */ 1197 /* Set the MAC address in the EmacLite device */
1198 xemaclite_update_address(lp, ndev->dev_addr); 1198 xemaclite_update_address(lp, ndev->dev_addr);
1199 1199
1200 lp->phy_node = of_parse_phandle(ofdev->node, "phy-handle", 0); 1200 lp->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0);
1201 rc = xemaclite_mdio_setup(lp, &ofdev->dev); 1201 rc = xemaclite_mdio_setup(lp, &ofdev->dev);
1202 if (rc) 1202 if (rc)
1203 dev_warn(&ofdev->dev, "error registering MDIO bus\n"); 1203 dev_warn(&ofdev->dev, "error registering MDIO bus\n");
@@ -1291,8 +1291,11 @@ static struct of_device_id xemaclite_of_match[] __devinitdata = {
1291MODULE_DEVICE_TABLE(of, xemaclite_of_match); 1291MODULE_DEVICE_TABLE(of, xemaclite_of_match);
1292 1292
1293static struct of_platform_driver xemaclite_of_driver = { 1293static struct of_platform_driver xemaclite_of_driver = {
1294 .name = DRIVER_NAME, 1294 .driver = {
1295 .match_table = xemaclite_of_match, 1295 .name = DRIVER_NAME,
1296 .owner = THIS_MODULE,
1297 .of_match_table = xemaclite_of_match,
1298 },
1296 .probe = xemaclite_of_probe, 1299 .probe = xemaclite_of_probe,
1297 .remove = __devexit_p(xemaclite_of_remove), 1300 .remove = __devexit_p(xemaclite_of_remove),
1298}; 1301};