aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2010-08-10 07:22:08 -0400
committerJiri Kosina <jkosina@suse.cz>2010-08-10 07:22:08 -0400
commitfb8231a8b139035476f2a8aaac837d0099b66dad (patch)
tree2875806beb96ea0cdab292146767a5085721dc6a /drivers/net
parent426d31071ac476ea62c62656b242930c17b58c00 (diff)
parentf6cec0ae58c17522a7bc4e2f39dae19f199ab534 (diff)
Merge branch 'master' into for-next
Conflicts: arch/arm/mach-omap1/board-nokia770.c
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/Kconfig4
-rw-r--r--drivers/net/au1000_eth.c31
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c25
-rw-r--r--drivers/net/cxgb4vf/cxgb4vf_main.c31
-rw-r--r--drivers/net/davinci_emac.c2
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/e1000/e1000_main.c3
-rw-r--r--drivers/net/e1000e/netdev.c20
-rw-r--r--drivers/net/enic/enic_main.c17
-rw-r--r--drivers/net/fsl_pq_mdio.c1
-rw-r--r--drivers/net/ibm_newemac/core.c4
-rw-r--r--drivers/net/igb/igb_main.c2
-rw-r--r--drivers/net/igbvf/netdev.c2
-rw-r--r--drivers/net/ixgb/ixgb_main.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c15
-rw-r--r--drivers/net/ixgbevf/ixgbevf_main.c2
-rw-r--r--drivers/net/myri_sbus.c6
-rw-r--r--drivers/net/netxen/netxen_nic_main.c15
-rw-r--r--drivers/net/niu.c15
-rw-r--r--drivers/net/niu.h4
-rw-r--r--drivers/net/pcmcia/3c574_cs.c14
-rw-r--r--drivers/net/pcmcia/3c589_cs.c14
-rw-r--r--drivers/net/pcmcia/axnet_cs.c48
-rw-r--r--drivers/net/pcmcia/com20020_cs.c22
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c48
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c29
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c32
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c63
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c71
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c60
-rw-r--r--drivers/net/ppp_async.c6
-rw-r--r--drivers/net/ppp_synctty.c6
-rw-r--r--drivers/net/pppoe.c4
-rw-r--r--drivers/net/r8169.c16
-rw-r--r--drivers/net/smc91x.h37
-rw-r--r--drivers/net/sunbmac.c6
-rw-r--r--drivers/net/sunhme.c10
-rw-r--r--drivers/net/sunlance.c6
-rw-r--r--drivers/net/sunqe.c10
-rw-r--r--drivers/net/usb/usbnet.c1
-rw-r--r--drivers/net/via-velocity.c4
-rw-r--r--drivers/net/virtio_net.c14
-rw-r--r--drivers/net/wireless/airo_cs.c74
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_calib.c43
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_calib.c18
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c388
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_paprd.c17
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c118
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.h8
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h25
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c104
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c36
-rw-r--r--drivers/net/wireless/atmel_cs.c25
-rw-r--r--drivers/net/wireless/b43/pcmcia.c13
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c136
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-devtrace.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c6
-rw-r--r--drivers/net/wireless/libertas/cfg.c214
-rw-r--r--drivers/net/wireless/libertas/dev.h5
-rw-r--r--drivers/net/wireless/libertas/if_cs.c16
-rw-r--r--drivers/net/wireless/libertas/main.c1
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c30
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c62
-rw-r--r--drivers/net/wireless/p54/p54pci.c2
-rw-r--r--drivers/net/wireless/ray_cs.c27
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c21
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180_dev.c2
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_spi.c3
-rw-r--r--drivers/net/wireless/wl3501_cs.c24
-rw-r--r--drivers/net/xilinx_emaclite.c2
84 files changed, 1286 insertions, 956 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ebe68395ecf8..5a6895320b48 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -484,7 +484,7 @@ config XTENSA_XT2000_SONIC
484 484
485config MIPS_AU1X00_ENET 485config MIPS_AU1X00_ENET
486 tristate "MIPS AU1000 Ethernet support" 486 tristate "MIPS AU1000 Ethernet support"
487 depends on SOC_AU1X00 487 depends on MIPS_ALCHEMY
488 select PHYLIB 488 select PHYLIB
489 select CRC32 489 select CRC32
490 help 490 help
@@ -914,7 +914,7 @@ config SMC91X
914 tristate "SMC 91C9x/91C1xxx support" 914 tristate "SMC 91C9x/91C1xxx support"
915 select CRC32 915 select CRC32
916 select MII 916 select MII
917 depends on ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || \ 917 depends on ARM || M32R || SUPERH || \
918 MIPS || BLACKFIN || MN10300 || COLDFIRE 918 MIPS || BLACKFIN || MN10300 || COLDFIRE
919 help 919 help
920 This is a driver for SMC's 91x series of Ethernet chipsets, 920 This is a driver for SMC's 91x series of Ethernet chipsets,
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 386d4feec652..15ae6df2ff00 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -104,14 +104,6 @@ MODULE_VERSION(DRV_VERSION);
104 * complete immediately. 104 * complete immediately.
105 */ 105 */
106 106
107/* These addresses are only used if yamon doesn't tell us what
108 * the mac address is, and the mac address is not passed on the
109 * command line.
110 */
111static unsigned char au1000_mac_addr[6] __devinitdata = {
112 0x00, 0x50, 0xc2, 0x0c, 0x30, 0x00
113};
114
115struct au1000_private *au_macs[NUM_ETH_INTERFACES]; 107struct au1000_private *au_macs[NUM_ETH_INTERFACES];
116 108
117/* 109/*
@@ -1002,7 +994,6 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1002 db_dest_t *pDB, *pDBfree; 994 db_dest_t *pDB, *pDBfree;
1003 int irq, i, err = 0; 995 int irq, i, err = 0;
1004 struct resource *base, *macen; 996 struct resource *base, *macen;
1005 char ethaddr[6];
1006 997
1007 base = platform_get_resource(pdev, IORESOURCE_MEM, 0); 998 base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1008 if (!base) { 999 if (!base) {
@@ -1079,24 +1070,13 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1079 } 1070 }
1080 aup->mac_id = pdev->id; 1071 aup->mac_id = pdev->id;
1081 1072
1082 if (pdev->id == 0) { 1073 if (pdev->id == 0)
1083 if (prom_get_ethernet_addr(ethaddr) == 0)
1084 memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr));
1085 else {
1086 netdev_info(dev, "No MAC address found\n");
1087 /* Use the hard coded MAC addresses */
1088 }
1089
1090 au1000_setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR); 1074 au1000_setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR);
1091 } else if (pdev->id == 1) 1075 else if (pdev->id == 1)
1092 au1000_setup_hw_rings(aup, MAC1_RX_DMA_ADDR, MAC1_TX_DMA_ADDR); 1076 au1000_setup_hw_rings(aup, MAC1_RX_DMA_ADDR, MAC1_TX_DMA_ADDR);
1093 1077
1094 /* 1078 /* set a random MAC now in case platform_data doesn't provide one */
1095 * Assign to the Ethernet ports two consecutive MAC addresses 1079 random_ether_addr(dev->dev_addr);
1096 * to match those that are printed on their stickers
1097 */
1098 memcpy(dev->dev_addr, au1000_mac_addr, sizeof(au1000_mac_addr));
1099 dev->dev_addr[5] += pdev->id;
1100 1080
1101 *aup->enable = 0; 1081 *aup->enable = 0;
1102 aup->mac_enabled = 0; 1082 aup->mac_enabled = 0;
@@ -1106,6 +1086,9 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1106 dev_info(&pdev->dev, "no platform_data passed, PHY search on MAC0\n"); 1086 dev_info(&pdev->dev, "no platform_data passed, PHY search on MAC0\n");
1107 aup->phy1_search_mac0 = 1; 1087 aup->phy1_search_mac0 = 1;
1108 } else { 1088 } else {
1089 if (is_valid_ether_addr(pd->mac))
1090 memcpy(dev->dev_addr, pd->mac, 6);
1091
1109 aup->phy_static_config = pd->phy_static_config; 1092 aup->phy_static_config = pd->phy_static_config;
1110 aup->phy_search_highest_addr = pd->phy_search_highest_addr; 1093 aup->phy_search_highest_addr = pd->phy_search_highest_addr;
1111 aup->phy1_search_mac0 = pd->phy1_search_mac0; 1094 aup->phy1_search_mac0 = pd->phy1_search_mac0;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 066fd5b09fda..ad19585d960b 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -3198,17 +3198,17 @@ static int __devinit init_one(struct pci_dev *pdev,
3198 } 3198 }
3199 } 3199 }
3200 3200
3201 err = pci_request_regions(pdev, DRV_NAME); 3201 err = pci_enable_device(pdev);
3202 if (err) { 3202 if (err) {
3203 /* Just info, some other driver may have claimed the device. */ 3203 dev_err(&pdev->dev, "cannot enable PCI device\n");
3204 dev_info(&pdev->dev, "cannot obtain PCI resources\n"); 3204 goto out;
3205 return err;
3206 } 3205 }
3207 3206
3208 err = pci_enable_device(pdev); 3207 err = pci_request_regions(pdev, DRV_NAME);
3209 if (err) { 3208 if (err) {
3210 dev_err(&pdev->dev, "cannot enable PCI device\n"); 3209 /* Just info, some other driver may have claimed the device. */
3211 goto out_release_regions; 3210 dev_info(&pdev->dev, "cannot obtain PCI resources\n");
3211 goto out_disable_device;
3212 } 3212 }
3213 3213
3214 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { 3214 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
@@ -3217,11 +3217,11 @@ static int __devinit init_one(struct pci_dev *pdev,
3217 if (err) { 3217 if (err) {
3218 dev_err(&pdev->dev, "unable to obtain 64-bit DMA for " 3218 dev_err(&pdev->dev, "unable to obtain 64-bit DMA for "
3219 "coherent allocations\n"); 3219 "coherent allocations\n");
3220 goto out_disable_device; 3220 goto out_release_regions;
3221 } 3221 }
3222 } else if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) { 3222 } else if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) {
3223 dev_err(&pdev->dev, "no usable DMA configuration\n"); 3223 dev_err(&pdev->dev, "no usable DMA configuration\n");
3224 goto out_disable_device; 3224 goto out_release_regions;
3225 } 3225 }
3226 3226
3227 pci_set_master(pdev); 3227 pci_set_master(pdev);
@@ -3234,7 +3234,7 @@ static int __devinit init_one(struct pci_dev *pdev,
3234 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); 3234 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
3235 if (!adapter) { 3235 if (!adapter) {
3236 err = -ENOMEM; 3236 err = -ENOMEM;
3237 goto out_disable_device; 3237 goto out_release_regions;
3238 } 3238 }
3239 3239
3240 adapter->nofail_skb = 3240 adapter->nofail_skb =
@@ -3370,11 +3370,12 @@ out_free_dev:
3370out_free_adapter: 3370out_free_adapter:
3371 kfree(adapter); 3371 kfree(adapter);
3372 3372
3373out_disable_device:
3374 pci_disable_device(pdev);
3375out_release_regions: 3373out_release_regions:
3376 pci_release_regions(pdev); 3374 pci_release_regions(pdev);
3375out_disable_device:
3376 pci_disable_device(pdev);
3377 pci_set_drvdata(pdev, NULL); 3377 pci_set_drvdata(pdev, NULL);
3378out:
3378 return err; 3379 return err;
3379} 3380}
3380 3381
diff --git a/drivers/net/cxgb4vf/cxgb4vf_main.c b/drivers/net/cxgb4vf/cxgb4vf_main.c
index a16563219ac9..7b6d07f50c71 100644
--- a/drivers/net/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/cxgb4vf/cxgb4vf_main.c
@@ -2462,23 +2462,24 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
2462 version_printed = 1; 2462 version_printed = 1;
2463 } 2463 }
2464 2464
2465
2465 /* 2466 /*
2466 * Reserve PCI resources for the device. If we can't get them some 2467 * Initialize generic PCI device state.
2467 * other driver may have already claimed the device ...
2468 */ 2468 */
2469 err = pci_request_regions(pdev, KBUILD_MODNAME); 2469 err = pci_enable_device(pdev);
2470 if (err) { 2470 if (err) {
2471 dev_err(&pdev->dev, "cannot obtain PCI resources\n"); 2471 dev_err(&pdev->dev, "cannot enable PCI device\n");
2472 return err; 2472 return err;
2473 } 2473 }
2474 2474
2475 /* 2475 /*
2476 * Initialize generic PCI device state. 2476 * Reserve PCI resources for the device. If we can't get them some
2477 * other driver may have already claimed the device ...
2477 */ 2478 */
2478 err = pci_enable_device(pdev); 2479 err = pci_request_regions(pdev, KBUILD_MODNAME);
2479 if (err) { 2480 if (err) {
2480 dev_err(&pdev->dev, "cannot enable PCI device\n"); 2481 dev_err(&pdev->dev, "cannot obtain PCI resources\n");
2481 goto err_release_regions; 2482 goto err_disable_device;
2482 } 2483 }
2483 2484
2484 /* 2485 /*
@@ -2491,14 +2492,14 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
2491 if (err) { 2492 if (err) {
2492 dev_err(&pdev->dev, "unable to obtain 64-bit DMA for" 2493 dev_err(&pdev->dev, "unable to obtain 64-bit DMA for"
2493 " coherent allocations\n"); 2494 " coherent allocations\n");
2494 goto err_disable_device; 2495 goto err_release_regions;
2495 } 2496 }
2496 pci_using_dac = 1; 2497 pci_using_dac = 1;
2497 } else { 2498 } else {
2498 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 2499 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
2499 if (err != 0) { 2500 if (err != 0) {
2500 dev_err(&pdev->dev, "no usable DMA configuration\n"); 2501 dev_err(&pdev->dev, "no usable DMA configuration\n");
2501 goto err_disable_device; 2502 goto err_release_regions;
2502 } 2503 }
2503 pci_using_dac = 0; 2504 pci_using_dac = 0;
2504 } 2505 }
@@ -2514,7 +2515,7 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
2514 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); 2515 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
2515 if (!adapter) { 2516 if (!adapter) {
2516 err = -ENOMEM; 2517 err = -ENOMEM;
2517 goto err_disable_device; 2518 goto err_release_regions;
2518 } 2519 }
2519 pci_set_drvdata(pdev, adapter); 2520 pci_set_drvdata(pdev, adapter);
2520 adapter->pdev = pdev; 2521 adapter->pdev = pdev;
@@ -2750,13 +2751,13 @@ err_free_adapter:
2750 kfree(adapter); 2751 kfree(adapter);
2751 pci_set_drvdata(pdev, NULL); 2752 pci_set_drvdata(pdev, NULL);
2752 2753
2753err_disable_device:
2754 pci_disable_device(pdev);
2755 pci_clear_master(pdev);
2756
2757err_release_regions: 2754err_release_regions:
2758 pci_release_regions(pdev); 2755 pci_release_regions(pdev);
2759 pci_set_drvdata(pdev, NULL); 2756 pci_set_drvdata(pdev, NULL);
2757 pci_clear_master(pdev);
2758
2759err_disable_device:
2760 pci_disable_device(pdev);
2760 2761
2761err_out: 2762err_out:
2762 return err; 2763 return err;
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index d0824e322068..7fbd052ddb0a 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -2944,8 +2944,8 @@ static int __devexit davinci_emac_remove(struct platform_device *pdev)
2944 release_mem_region(res->start, res->end - res->start + 1); 2944 release_mem_region(res->start, res->end - res->start + 1);
2945 2945
2946 unregister_netdev(ndev); 2946 unregister_netdev(ndev);
2947 free_netdev(ndev);
2948 iounmap(priv->remap_addr); 2947 iounmap(priv->remap_addr);
2948 free_netdev(ndev);
2949 2949
2950 clk_disable(emac_clk); 2950 clk_disable(emac_clk);
2951 clk_put(emac_clk); 2951 clk_put(emac_clk);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index b194bad29ace..8e2eab4e7c75 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1779,6 +1779,7 @@ static int e100_tx_clean(struct nic *nic)
1779 for (cb = nic->cb_to_clean; 1779 for (cb = nic->cb_to_clean;
1780 cb->status & cpu_to_le16(cb_complete); 1780 cb->status & cpu_to_le16(cb_complete);
1781 cb = nic->cb_to_clean = cb->next) { 1781 cb = nic->cb_to_clean = cb->next) {
1782 rmb(); /* read skb after status */
1782 netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev, 1783 netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev,
1783 "cb[%d]->status = 0x%04X\n", 1784 "cb[%d]->status = 0x%04X\n",
1784 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), 1785 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)),
@@ -1927,6 +1928,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1927 1928
1928 netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev, 1929 netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev,
1929 "status=0x%04X\n", rfd_status); 1930 "status=0x%04X\n", rfd_status);
1931 rmb(); /* read size after status bit */
1930 1932
1931 /* If data isn't ready, nothing to indicate */ 1933 /* If data isn't ready, nothing to indicate */
1932 if (unlikely(!(rfd_status & cb_complete))) { 1934 if (unlikely(!(rfd_status & cb_complete))) {
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 02833af8a0b1..5cc39ed289c6 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3454,6 +3454,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3454 while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && 3454 while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
3455 (count < tx_ring->count)) { 3455 (count < tx_ring->count)) {
3456 bool cleaned = false; 3456 bool cleaned = false;
3457 rmb(); /* read buffer_info after eop_desc */
3457 for ( ; !cleaned; count++) { 3458 for ( ; !cleaned; count++) {
3458 tx_desc = E1000_TX_DESC(*tx_ring, i); 3459 tx_desc = E1000_TX_DESC(*tx_ring, i);
3459 buffer_info = &tx_ring->buffer_info[i]; 3460 buffer_info = &tx_ring->buffer_info[i];
@@ -3643,6 +3644,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
3643 if (*work_done >= work_to_do) 3644 if (*work_done >= work_to_do)
3644 break; 3645 break;
3645 (*work_done)++; 3646 (*work_done)++;
3647 rmb(); /* read descriptor and rx_buffer_info after status DD */
3646 3648
3647 status = rx_desc->status; 3649 status = rx_desc->status;
3648 skb = buffer_info->skb; 3650 skb = buffer_info->skb;
@@ -3849,6 +3851,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
3849 if (*work_done >= work_to_do) 3851 if (*work_done >= work_to_do)
3850 break; 3852 break;
3851 (*work_done)++; 3853 (*work_done)++;
3854 rmb(); /* read descriptor and rx_buffer_info after status DD */
3852 3855
3853 status = rx_desc->status; 3856 status = rx_desc->status;
3854 skb = buffer_info->skb; 3857 skb = buffer_info->skb;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 36d31a416320..2b8ef44bd2b1 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -781,6 +781,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
781 if (*work_done >= work_to_do) 781 if (*work_done >= work_to_do)
782 break; 782 break;
783 (*work_done)++; 783 (*work_done)++;
784 rmb(); /* read descriptor and rx_buffer_info after status DD */
784 785
785 status = rx_desc->status; 786 status = rx_desc->status;
786 skb = buffer_info->skb; 787 skb = buffer_info->skb;
@@ -991,6 +992,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
991 while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && 992 while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
992 (count < tx_ring->count)) { 993 (count < tx_ring->count)) {
993 bool cleaned = false; 994 bool cleaned = false;
995 rmb(); /* read buffer_info after eop_desc */
994 for (; !cleaned; count++) { 996 for (; !cleaned; count++) {
995 tx_desc = E1000_TX_DESC(*tx_ring, i); 997 tx_desc = E1000_TX_DESC(*tx_ring, i);
996 buffer_info = &tx_ring->buffer_info[i]; 998 buffer_info = &tx_ring->buffer_info[i];
@@ -1087,6 +1089,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
1087 break; 1089 break;
1088 (*work_done)++; 1090 (*work_done)++;
1089 skb = buffer_info->skb; 1091 skb = buffer_info->skb;
1092 rmb(); /* read descriptor and rx_buffer_info after status DD */
1090 1093
1091 /* in the packet split case this is header only */ 1094 /* in the packet split case this is header only */
1092 prefetch(skb->data - NET_IP_ALIGN); 1095 prefetch(skb->data - NET_IP_ALIGN);
@@ -1286,6 +1289,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1286 if (*work_done >= work_to_do) 1289 if (*work_done >= work_to_do)
1287 break; 1290 break;
1288 (*work_done)++; 1291 (*work_done)++;
1292 rmb(); /* read descriptor and rx_buffer_info after status DD */
1289 1293
1290 status = rx_desc->status; 1294 status = rx_desc->status;
1291 skb = buffer_info->skb; 1295 skb = buffer_info->skb;
@@ -5825,11 +5829,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5825 5829
5826 e1000_print_device_info(adapter); 5830 e1000_print_device_info(adapter);
5827 5831
5828 if (pci_dev_run_wake(pdev)) { 5832 if (pci_dev_run_wake(pdev))
5829 pm_runtime_set_active(&pdev->dev); 5833 pm_runtime_put_noidle(&pdev->dev);
5830 pm_runtime_enable(&pdev->dev);
5831 }
5832 pm_schedule_suspend(&pdev->dev, MSEC_PER_SEC);
5833 5834
5834 return 0; 5835 return 0;
5835 5836
@@ -5875,8 +5876,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5875 struct e1000_adapter *adapter = netdev_priv(netdev); 5876 struct e1000_adapter *adapter = netdev_priv(netdev);
5876 bool down = test_bit(__E1000_DOWN, &adapter->state); 5877 bool down = test_bit(__E1000_DOWN, &adapter->state);
5877 5878
5878 pm_runtime_get_sync(&pdev->dev);
5879
5880 /* 5879 /*
5881 * flush_scheduled work may reschedule our watchdog task, so 5880 * flush_scheduled work may reschedule our watchdog task, so
5882 * explicitly disable watchdog tasks from being rescheduled 5881 * explicitly disable watchdog tasks from being rescheduled
@@ -5901,11 +5900,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5901 clear_bit(__E1000_DOWN, &adapter->state); 5900 clear_bit(__E1000_DOWN, &adapter->state);
5902 unregister_netdev(netdev); 5901 unregister_netdev(netdev);
5903 5902
5904 if (pci_dev_run_wake(pdev)) { 5903 if (pci_dev_run_wake(pdev))
5905 pm_runtime_disable(&pdev->dev); 5904 pm_runtime_get_noresume(&pdev->dev);
5906 pm_runtime_set_suspended(&pdev->dev);
5907 }
5908 pm_runtime_put_noidle(&pdev->dev);
5909 5905
5910 /* 5906 /*
5911 * Release control of h/w to f/w. If f/w is AMT enabled, this 5907 * Release control of h/w to f/w. If f/w is AMT enabled, this
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index 77a7f87d498e..9aab85366d21 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1087,10 +1087,7 @@ static int enic_set_port_profile(struct enic *enic, u8 *mac)
1087{ 1087{
1088 struct vic_provinfo *vp; 1088 struct vic_provinfo *vp;
1089 u8 oui[3] = VIC_PROVINFO_CISCO_OUI; 1089 u8 oui[3] = VIC_PROVINFO_CISCO_OUI;
1090 u8 *uuid;
1091 char uuid_str[38]; 1090 char uuid_str[38];
1092 static char *uuid_fmt = "%02X%02X%02X%02X-%02X%02X-%02X%02X-"
1093 "%02X%02X-%02X%02X%02X%02X%0X%02X";
1094 int err; 1091 int err;
1095 1092
1096 err = enic_vnic_dev_deinit(enic); 1093 err = enic_vnic_dev_deinit(enic);
@@ -1121,24 +1118,14 @@ static int enic_set_port_profile(struct enic *enic, u8 *mac)
1121 ETH_ALEN, mac); 1118 ETH_ALEN, mac);
1122 1119
1123 if (enic->pp.set & ENIC_SET_INSTANCE) { 1120 if (enic->pp.set & ENIC_SET_INSTANCE) {
1124 uuid = enic->pp.instance_uuid; 1121 sprintf(uuid_str, "%pUB", enic->pp.instance_uuid);
1125 sprintf(uuid_str, uuid_fmt,
1126 uuid[0], uuid[1], uuid[2], uuid[3],
1127 uuid[4], uuid[5], uuid[6], uuid[7],
1128 uuid[8], uuid[9], uuid[10], uuid[11],
1129 uuid[12], uuid[13], uuid[14], uuid[15]);
1130 vic_provinfo_add_tlv(vp, 1122 vic_provinfo_add_tlv(vp,
1131 VIC_LINUX_PROV_TLV_CLIENT_UUID_STR, 1123 VIC_LINUX_PROV_TLV_CLIENT_UUID_STR,
1132 sizeof(uuid_str), uuid_str); 1124 sizeof(uuid_str), uuid_str);
1133 } 1125 }
1134 1126
1135 if (enic->pp.set & ENIC_SET_HOST) { 1127 if (enic->pp.set & ENIC_SET_HOST) {
1136 uuid = enic->pp.host_uuid; 1128 sprintf(uuid_str, "%pUB", enic->pp.host_uuid);
1137 sprintf(uuid_str, uuid_fmt,
1138 uuid[0], uuid[1], uuid[2], uuid[3],
1139 uuid[4], uuid[5], uuid[6], uuid[7],
1140 uuid[8], uuid[9], uuid[10], uuid[11],
1141 uuid[12], uuid[13], uuid[14], uuid[15]);
1142 vic_provinfo_add_tlv(vp, 1129 vic_provinfo_add_tlv(vp,
1143 VIC_LINUX_PROV_TLV_HOST_UUID_STR, 1130 VIC_LINUX_PROV_TLV_HOST_UUID_STR,
1144 sizeof(uuid_str), uuid_str); 1131 sizeof(uuid_str), uuid_str);
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index b4c41d72c423..f53f850b6418 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -35,6 +35,7 @@
35#include <linux/mii.h> 35#include <linux/mii.h>
36#include <linux/phy.h> 36#include <linux/phy.h>
37#include <linux/of.h> 37#include <linux/of.h>
38#include <linux/of_address.h>
38#include <linux/of_mdio.h> 39#include <linux/of_mdio.h>
39#include <linux/of_platform.h> 40#include <linux/of_platform.h>
40 41
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 0f1d4e96cf89..eeec7bc2ce74 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -2339,11 +2339,11 @@ static int __devinit emac_wait_deps(struct emac_instance *dev)
2339 deps[EMAC_DEP_MDIO_IDX].phandle = dev->mdio_ph; 2339 deps[EMAC_DEP_MDIO_IDX].phandle = dev->mdio_ph;
2340 if (dev->blist && dev->blist > emac_boot_list) 2340 if (dev->blist && dev->blist > emac_boot_list)
2341 deps[EMAC_DEP_PREV_IDX].phandle = 0xffffffffu; 2341 deps[EMAC_DEP_PREV_IDX].phandle = 0xffffffffu;
2342 bus_register_notifier(&of_platform_bus_type, &emac_of_bus_notifier); 2342 bus_register_notifier(&platform_bus_type, &emac_of_bus_notifier);
2343 wait_event_timeout(emac_probe_wait, 2343 wait_event_timeout(emac_probe_wait,
2344 emac_check_deps(dev, deps), 2344 emac_check_deps(dev, deps),
2345 EMAC_PROBE_DEP_TIMEOUT); 2345 EMAC_PROBE_DEP_TIMEOUT);
2346 bus_unregister_notifier(&of_platform_bus_type, &emac_of_bus_notifier); 2346 bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier);
2347 err = emac_check_deps(dev, deps) ? 0 : -ENODEV; 2347 err = emac_check_deps(dev, deps) ? 0 : -ENODEV;
2348 for (i = 0; i < EMAC_DEP_COUNT; i++) { 2348 for (i = 0; i < EMAC_DEP_COUNT; i++) {
2349 if (deps[i].node) 2349 if (deps[i].node)
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index f0f82dc7c5db..aaf506c56ccb 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -5353,6 +5353,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
5353 5353
5354 while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) && 5354 while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) &&
5355 (count < tx_ring->count)) { 5355 (count < tx_ring->count)) {
5356 rmb(); /* read buffer_info after eop_desc status */
5356 for (cleaned = false; !cleaned; count++) { 5357 for (cleaned = false; !cleaned; count++) {
5357 tx_desc = E1000_TX_DESC_ADV(*tx_ring, i); 5358 tx_desc = E1000_TX_DESC_ADV(*tx_ring, i);
5358 buffer_info = &tx_ring->buffer_info[i]; 5359 buffer_info = &tx_ring->buffer_info[i];
@@ -5558,6 +5559,7 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *q_vector,
5558 if (*work_done >= budget) 5559 if (*work_done >= budget)
5559 break; 5560 break;
5560 (*work_done)++; 5561 (*work_done)++;
5562 rmb(); /* read descriptor and rx_buffer_info after status DD */
5561 5563
5562 skb = buffer_info->skb; 5564 skb = buffer_info->skb;
5563 prefetch(skb->data - NET_IP_ALIGN); 5565 prefetch(skb->data - NET_IP_ALIGN);
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
index ec808fa8dc21..c539f7c9c3e0 100644
--- a/drivers/net/igbvf/netdev.c
+++ b/drivers/net/igbvf/netdev.c
@@ -248,6 +248,7 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter,
248 if (*work_done >= work_to_do) 248 if (*work_done >= work_to_do)
249 break; 249 break;
250 (*work_done)++; 250 (*work_done)++;
251 rmb(); /* read descriptor and rx_buffer_info after status DD */
251 252
252 buffer_info = &rx_ring->buffer_info[i]; 253 buffer_info = &rx_ring->buffer_info[i];
253 254
@@ -780,6 +781,7 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
780 781
781 while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) && 782 while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) &&
782 (count < tx_ring->count)) { 783 (count < tx_ring->count)) {
784 rmb(); /* read buffer_info after eop_desc status */
783 for (cleaned = false; !cleaned; count++) { 785 for (cleaned = false; !cleaned; count++) {
784 tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i); 786 tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i);
785 buffer_info = &tx_ring->buffer_info[i]; 787 buffer_info = &tx_ring->buffer_info[i];
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index c6b75c83100c..45fc89b9ba64 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1816,6 +1816,7 @@ ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
1816 1816
1817 while (eop_desc->status & IXGB_TX_DESC_STATUS_DD) { 1817 while (eop_desc->status & IXGB_TX_DESC_STATUS_DD) {
1818 1818
1819 rmb(); /* read buffer_info after eop_desc */
1819 for (cleaned = false; !cleaned; ) { 1820 for (cleaned = false; !cleaned; ) {
1820 tx_desc = IXGB_TX_DESC(*tx_ring, i); 1821 tx_desc = IXGB_TX_DESC(*tx_ring, i);
1821 buffer_info = &tx_ring->buffer_info[i]; 1822 buffer_info = &tx_ring->buffer_info[i];
@@ -1976,6 +1977,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
1976 break; 1977 break;
1977 1978
1978 (*work_done)++; 1979 (*work_done)++;
1980 rmb(); /* read descriptor and rx_buffer_info after status DD */
1979 status = rx_desc->status; 1981 status = rx_desc->status;
1980 skb = buffer_info->skb; 1982 skb = buffer_info->skb;
1981 buffer_info->skb = NULL; 1983 buffer_info->skb = NULL;
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 7d6a415bcf88..e32af434cc9d 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -748,6 +748,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,
748 while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) && 748 while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) &&
749 (count < tx_ring->work_limit)) { 749 (count < tx_ring->work_limit)) {
750 bool cleaned = false; 750 bool cleaned = false;
751 rmb(); /* read buffer_info after eop_desc */
751 for ( ; !cleaned; count++) { 752 for ( ; !cleaned; count++) {
752 struct sk_buff *skb; 753 struct sk_buff *skb;
753 tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); 754 tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i);
@@ -6155,9 +6156,11 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)
6155 txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1); 6156 txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1);
6156 txq += adapter->ring_feature[RING_F_FCOE].mask; 6157 txq += adapter->ring_feature[RING_F_FCOE].mask;
6157 return txq; 6158 return txq;
6159#ifdef CONFIG_IXGBE_DCB
6158 } else if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { 6160 } else if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
6159 txq = adapter->fcoe.up; 6161 txq = adapter->fcoe.up;
6160 return txq; 6162 return txq;
6163#endif
6161 } 6164 }
6162 } 6165 }
6163#endif 6166#endif
@@ -6216,10 +6219,14 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
6216 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED && 6219 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED &&
6217 (skb->protocol == htons(ETH_P_FCOE) || 6220 (skb->protocol == htons(ETH_P_FCOE) ||
6218 skb->protocol == htons(ETH_P_FIP))) { 6221 skb->protocol == htons(ETH_P_FIP))) {
6219 tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK 6222#ifdef CONFIG_IXGBE_DCB
6220 << IXGBE_TX_FLAGS_VLAN_SHIFT); 6223 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
6221 tx_flags |= ((adapter->fcoe.up << 13) 6224 tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK
6222 << IXGBE_TX_FLAGS_VLAN_SHIFT); 6225 << IXGBE_TX_FLAGS_VLAN_SHIFT);
6226 tx_flags |= ((adapter->fcoe.up << 13)
6227 << IXGBE_TX_FLAGS_VLAN_SHIFT);
6228 }
6229#endif
6223 /* flag for FCoE offloads */ 6230 /* flag for FCoE offloads */
6224 if (skb->protocol == htons(ETH_P_FCOE)) 6231 if (skb->protocol == htons(ETH_P_FCOE))
6225 tx_flags |= IXGBE_TX_FLAGS_FCOE; 6232 tx_flags |= IXGBE_TX_FLAGS_FCOE;
diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c
index 3e291ccc629d..918c00359b0a 100644
--- a/drivers/net/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ixgbevf/ixgbevf_main.c
@@ -231,6 +231,7 @@ static bool ixgbevf_clean_tx_irq(struct ixgbevf_adapter *adapter,
231 while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) && 231 while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) &&
232 (count < tx_ring->work_limit)) { 232 (count < tx_ring->work_limit)) {
233 bool cleaned = false; 233 bool cleaned = false;
234 rmb(); /* read buffer_info after eop_desc */
234 for ( ; !cleaned; count++) { 235 for ( ; !cleaned; count++) {
235 struct sk_buff *skb; 236 struct sk_buff *skb;
236 tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); 237 tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i);
@@ -518,6 +519,7 @@ static bool ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector,
518 break; 519 break;
519 (*work_done)++; 520 (*work_done)++;
520 521
522 rmb(); /* read descriptor and rx_buffer_info after status DD */
521 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 523 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
522 hdr_info = le16_to_cpu(ixgbevf_get_hdr_info(rx_desc)); 524 hdr_info = le16_to_cpu(ixgbevf_get_hdr_info(rx_desc));
523 len = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >> 525 len = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >>
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 1a57c3da1f49..04e552aa14ec 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -1079,7 +1079,7 @@ static int __devinit myri_sbus_probe(struct of_device *op, const struct of_devic
1079 1079
1080 mp->dev = dev; 1080 mp->dev = dev;
1081 dev->watchdog_timeo = 5*HZ; 1081 dev->watchdog_timeo = 5*HZ;
1082 dev->irq = op->irqs[0]; 1082 dev->irq = op->archdata.irqs[0];
1083 dev->netdev_ops = &myri_ops; 1083 dev->netdev_ops = &myri_ops;
1084 1084
1085 /* Register interrupt handler now. */ 1085 /* Register interrupt handler now. */
@@ -1172,12 +1172,12 @@ static struct of_platform_driver myri_sbus_driver = {
1172 1172
1173static int __init myri_sbus_init(void) 1173static int __init myri_sbus_init(void)
1174{ 1174{
1175 return of_register_driver(&myri_sbus_driver, &of_bus_type); 1175 return of_register_platform_driver(&myri_sbus_driver);
1176} 1176}
1177 1177
1178static void __exit myri_sbus_exit(void) 1178static void __exit myri_sbus_exit(void)
1179{ 1179{
1180 of_unregister_driver(&myri_sbus_driver); 1180 of_unregister_platform_driver(&myri_sbus_driver);
1181} 1181}
1182 1182
1183module_init(myri_sbus_init); 1183module_init(myri_sbus_init);
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 6ce6ce1df6d2..fd86e18604e6 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -2001,27 +2001,26 @@ static void netxen_tx_timeout_task(struct work_struct *work)
2001 if (++adapter->tx_timeo_cnt >= NX_MAX_TX_TIMEOUTS) 2001 if (++adapter->tx_timeo_cnt >= NX_MAX_TX_TIMEOUTS)
2002 goto request_reset; 2002 goto request_reset;
2003 2003
2004 rtnl_lock();
2004 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 2005 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
2005 /* try to scrub interrupt */ 2006 /* try to scrub interrupt */
2006 netxen_napi_disable(adapter); 2007 netxen_napi_disable(adapter);
2007 2008
2008 adapter->netdev->trans_start = jiffies;
2009
2010 netxen_napi_enable(adapter); 2009 netxen_napi_enable(adapter);
2011 2010
2012 netif_wake_queue(adapter->netdev); 2011 netif_wake_queue(adapter->netdev);
2013 2012
2014 clear_bit(__NX_RESETTING, &adapter->state); 2013 clear_bit(__NX_RESETTING, &adapter->state);
2015 return;
2016 } else { 2014 } else {
2017 clear_bit(__NX_RESETTING, &adapter->state); 2015 clear_bit(__NX_RESETTING, &adapter->state);
2018 if (!netxen_nic_reset_context(adapter)) { 2016 if (netxen_nic_reset_context(adapter)) {
2019 adapter->netdev->trans_start = jiffies; 2017 rtnl_unlock();
2020 return; 2018 goto request_reset;
2021 } 2019 }
2022
2023 /* context reset failed, fall through for fw reset */
2024 } 2020 }
2021 adapter->netdev->trans_start = jiffies;
2022 rtnl_unlock();
2023 return;
2025 2024
2026request_reset: 2025request_reset:
2027 adapter->need_fw_reset = 1; 2026 adapter->need_fw_reset = 1;
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index b9b950845b0e..404f2d552888 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -28,10 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29 29
30#include <linux/io.h> 30#include <linux/io.h>
31
32#ifdef CONFIG_SPARC64
33#include <linux/of_device.h> 31#include <linux/of_device.h>
34#endif
35 32
36#include "niu.h" 33#include "niu.h"
37 34
@@ -9114,12 +9111,12 @@ static int __devinit niu_n2_irq_init(struct niu *np, u8 *ldg_num_map)
9114 if (!int_prop) 9111 if (!int_prop)
9115 return -ENODEV; 9112 return -ENODEV;
9116 9113
9117 for (i = 0; i < op->num_irqs; i++) { 9114 for (i = 0; i < op->archdata.num_irqs; i++) {
9118 ldg_num_map[i] = int_prop[i]; 9115 ldg_num_map[i] = int_prop[i];
9119 np->ldg[i].irq = op->irqs[i]; 9116 np->ldg[i].irq = op->archdata.irqs[i];
9120 } 9117 }
9121 9118
9122 np->num_ldg = op->num_irqs; 9119 np->num_ldg = op->archdata.num_irqs;
9123 9120
9124 return 0; 9121 return 0;
9125#else 9122#else
@@ -10249,14 +10246,14 @@ static int __init niu_init(void)
10249 niu_debug = netif_msg_init(debug, NIU_MSG_DEFAULT); 10246 niu_debug = netif_msg_init(debug, NIU_MSG_DEFAULT);
10250 10247
10251#ifdef CONFIG_SPARC64 10248#ifdef CONFIG_SPARC64
10252 err = of_register_driver(&niu_of_driver, &of_bus_type); 10249 err = of_register_platform_driver(&niu_of_driver);
10253#endif 10250#endif
10254 10251
10255 if (!err) { 10252 if (!err) {
10256 err = pci_register_driver(&niu_pci_driver); 10253 err = pci_register_driver(&niu_pci_driver);
10257#ifdef CONFIG_SPARC64 10254#ifdef CONFIG_SPARC64
10258 if (err) 10255 if (err)
10259 of_unregister_driver(&niu_of_driver); 10256 of_unregister_platform_driver(&niu_of_driver);
10260#endif 10257#endif
10261 } 10258 }
10262 10259
@@ -10267,7 +10264,7 @@ static void __exit niu_exit(void)
10267{ 10264{
10268 pci_unregister_driver(&niu_pci_driver); 10265 pci_unregister_driver(&niu_pci_driver);
10269#ifdef CONFIG_SPARC64 10266#ifdef CONFIG_SPARC64
10270 of_unregister_driver(&niu_of_driver); 10267 of_unregister_platform_driver(&niu_of_driver);
10271#endif 10268#endif
10272} 10269}
10273 10270
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index d6715465f35d..a41fa8ebe05f 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -3236,7 +3236,7 @@ struct niu_phy_ops {
3236 int (*link_status)(struct niu *np, int *); 3236 int (*link_status)(struct niu *np, int *);
3237}; 3237};
3238 3238
3239struct of_device; 3239struct platform_device;
3240struct niu { 3240struct niu {
3241 void __iomem *regs; 3241 void __iomem *regs;
3242 struct net_device *dev; 3242 struct net_device *dev;
@@ -3297,7 +3297,7 @@ struct niu {
3297 struct niu_vpd vpd; 3297 struct niu_vpd vpd;
3298 u32 eeprom_len; 3298 u32 eeprom_len;
3299 3299
3300 struct of_device *op; 3300 struct platform_device *op;
3301 void __iomem *vir_regs_1; 3301 void __iomem *vir_regs_1;
3302 void __iomem *vir_regs_2; 3302 void __iomem *vir_regs_2;
3303}; 3303};
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 10ee106a1617..c683f77c6f42 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -87,7 +87,6 @@ earlier 3Com products.
87#include <linux/bitops.h> 87#include <linux/bitops.h>
88#include <linux/mii.h> 88#include <linux/mii.h>
89 89
90#include <pcmcia/cs_types.h>
91#include <pcmcia/cs.h> 90#include <pcmcia/cs.h>
92#include <pcmcia/cistpl.h> 91#include <pcmcia/cistpl.h>
93#include <pcmcia/cisreg.h> 92#include <pcmcia/cisreg.h>
@@ -279,8 +278,8 @@ static int tc574_probe(struct pcmcia_device *link)
279 lp->p_dev = link; 278 lp->p_dev = link;
280 279
281 spin_lock_init(&lp->window_lock); 280 spin_lock_init(&lp->window_lock);
282 link->io.NumPorts1 = 32; 281 link->resource[0]->end = 32;
283 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 282 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
284 link->conf.Attributes = CONF_ENABLE_IRQ; 283 link->conf.Attributes = CONF_ENABLE_IRQ;
285 link->conf.IntType = INT_MEMORY_AND_IO; 284 link->conf.IntType = INT_MEMORY_AND_IO;
286 link->conf.ConfigIndex = 1; 285 link->conf.ConfigIndex = 1;
@@ -338,10 +337,11 @@ static int tc574_config(struct pcmcia_device *link)
338 337
339 dev_dbg(&link->dev, "3c574_config()\n"); 338 dev_dbg(&link->dev, "3c574_config()\n");
340 339
341 link->io.IOAddrLines = 16; 340 link->io_lines = 16;
341
342 for (i = j = 0; j < 0x400; j += 0x20) { 342 for (i = j = 0; j < 0x400; j += 0x20) {
343 link->io.BasePort1 = j ^ 0x300; 343 link->resource[0]->start = j ^ 0x300;
344 i = pcmcia_request_io(link, &link->io); 344 i = pcmcia_request_io(link);
345 if (i == 0) 345 if (i == 0)
346 break; 346 break;
347 } 347 }
@@ -357,7 +357,7 @@ static int tc574_config(struct pcmcia_device *link)
357 goto failed; 357 goto failed;
358 358
359 dev->irq = link->irq; 359 dev->irq = link->irq;
360 dev->base_addr = link->io.BasePort1; 360 dev->base_addr = link->resource[0]->start;
361 361
362 ioaddr = dev->base_addr; 362 ioaddr = dev->base_addr;
363 363
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index ce63c3773b4c..61f9cf2100ff 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -41,7 +41,6 @@
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42#include <linux/jiffies.h> 42#include <linux/jiffies.h>
43 43
44#include <pcmcia/cs_types.h>
45#include <pcmcia/cs.h> 44#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
47#include <pcmcia/cisreg.h> 46#include <pcmcia/cisreg.h>
@@ -214,8 +213,8 @@ static int tc589_probe(struct pcmcia_device *link)
214 lp->p_dev = link; 213 lp->p_dev = link;
215 214
216 spin_lock_init(&lp->lock); 215 spin_lock_init(&lp->lock);
217 link->io.NumPorts1 = 16; 216 link->resource[0]->end = 16;
218 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 217 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
219 218
220 link->conf.Attributes = CONF_ENABLE_IRQ; 219 link->conf.Attributes = CONF_ENABLE_IRQ;
221 link->conf.IntType = INT_MEMORY_AND_IO; 220 link->conf.IntType = INT_MEMORY_AND_IO;
@@ -278,12 +277,13 @@ static int tc589_config(struct pcmcia_device *link)
278 "3Com card??\n"); 277 "3Com card??\n");
279 multi = (link->card_id == PRODID_3COM_3C562); 278 multi = (link->card_id == PRODID_3COM_3C562);
280 279
280 link->io_lines = 16;
281
281 /* For the 3c562, the base address must be xx00-xx7f */ 282 /* For the 3c562, the base address must be xx00-xx7f */
282 link->io.IOAddrLines = 16;
283 for (i = j = 0; j < 0x400; j += 0x10) { 283 for (i = j = 0; j < 0x400; j += 0x10) {
284 if (multi && (j & 0x80)) continue; 284 if (multi && (j & 0x80)) continue;
285 link->io.BasePort1 = j ^ 0x300; 285 link->resource[0]->start = j ^ 0x300;
286 i = pcmcia_request_io(link, &link->io); 286 i = pcmcia_request_io(link);
287 if (i == 0) 287 if (i == 0)
288 break; 288 break;
289 } 289 }
@@ -299,7 +299,7 @@ static int tc589_config(struct pcmcia_device *link)
299 goto failed; 299 goto failed;
300 300
301 dev->irq = link->irq; 301 dev->irq = link->irq;
302 dev->base_addr = link->io.BasePort1; 302 dev->base_addr = link->resource[0]->start;
303 ioaddr = dev->base_addr; 303 ioaddr = dev->base_addr;
304 EL3WINDOW(0); 304 EL3WINDOW(0);
305 305
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 33525bf2a3d3..5f05ffb240cc 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -39,7 +39,6 @@
39#include <linux/mii.h> 39#include <linux/mii.h>
40#include "../8390.h" 40#include "../8390.h"
41 41
42#include <pcmcia/cs_types.h>
43#include <pcmcia/cs.h> 42#include <pcmcia/cs.h>
44#include <pcmcia/cistpl.h> 43#include <pcmcia/cistpl.h>
45#include <pcmcia/ciscode.h> 44#include <pcmcia/ciscode.h>
@@ -260,28 +259,30 @@ static int get_prom(struct pcmcia_device *link)
260static int try_io_port(struct pcmcia_device *link) 259static int try_io_port(struct pcmcia_device *link)
261{ 260{
262 int j, ret; 261 int j, ret;
263 if (link->io.NumPorts1 == 32) { 262 link->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
264 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 263 link->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
264 if (link->resource[0]->end == 32) {
265 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
265 /* for master/slave multifunction cards */ 266 /* for master/slave multifunction cards */
266 if (link->io.NumPorts2 > 0) 267 if (link->resource[1]->end > 0)
267 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 268 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
268 } else { 269 } else {
269 /* This should be two 16-port windows */ 270 /* This should be two 16-port windows */
270 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 271 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
271 link->io.Attributes2 = IO_DATA_PATH_WIDTH_16; 272 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_16;
272 } 273 }
273 if (link->io.BasePort1 == 0) { 274 if (link->resource[0]->start == 0) {
274 link->io.IOAddrLines = 16;
275 for (j = 0; j < 0x400; j += 0x20) { 275 for (j = 0; j < 0x400; j += 0x20) {
276 link->io.BasePort1 = j ^ 0x300; 276 link->resource[0]->start = j ^ 0x300;
277 link->io.BasePort2 = (j ^ 0x300) + 0x10; 277 link->resource[1]->start = (j ^ 0x300) + 0x10;
278 ret = pcmcia_request_io(link, &link->io); 278 link->io_lines = 16;
279 ret = pcmcia_request_io(link);
279 if (ret == 0) 280 if (ret == 0)
280 return ret; 281 return ret;
281 } 282 }
282 return ret; 283 return ret;
283 } else { 284 } else {
284 return pcmcia_request_io(link, &link->io); 285 return pcmcia_request_io(link);
285 } 286 }
286} 287}
287 288
@@ -302,15 +303,15 @@ static int axnet_configcheck(struct pcmcia_device *p_dev,
302 network function with window 0, and serial with window 1 */ 303 network function with window 0, and serial with window 1 */
303 if (io->nwin > 1) { 304 if (io->nwin > 1) {
304 i = (io->win[1].len > io->win[0].len); 305 i = (io->win[1].len > io->win[0].len);
305 p_dev->io.BasePort2 = io->win[1-i].base; 306 p_dev->resource[1]->start = io->win[1-i].base;
306 p_dev->io.NumPorts2 = io->win[1-i].len; 307 p_dev->resource[1]->end = io->win[1-i].len;
307 } else { 308 } else {
308 i = p_dev->io.NumPorts2 = 0; 309 i = p_dev->resource[1]->end = 0;
309 } 310 }
310 p_dev->io.BasePort1 = io->win[i].base; 311 p_dev->resource[0]->start = io->win[i].base;
311 p_dev->io.NumPorts1 = io->win[i].len; 312 p_dev->resource[0]->end = io->win[i].len;
312 p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 313 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
313 if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) 314 if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32)
314 return try_io_port(p_dev); 315 return try_io_port(p_dev);
315 316
316 return -ENODEV; 317 return -ENODEV;
@@ -333,7 +334,7 @@ static int axnet_config(struct pcmcia_device *link)
333 if (!link->irq) 334 if (!link->irq)
334 goto failed; 335 goto failed;
335 336
336 if (link->io.NumPorts2 == 8) { 337 if (resource_size(link->resource[1]) == 8) {
337 link->conf.Attributes |= CONF_ENABLE_SPKR; 338 link->conf.Attributes |= CONF_ENABLE_SPKR;
338 link->conf.Status = CCSR_AUDIO_ENA; 339 link->conf.Status = CCSR_AUDIO_ENA;
339 } 340 }
@@ -343,7 +344,7 @@ static int axnet_config(struct pcmcia_device *link)
343 goto failed; 344 goto failed;
344 345
345 dev->irq = link->irq; 346 dev->irq = link->irq;
346 dev->base_addr = link->io.BasePort1; 347 dev->base_addr = link->resource[0]->start;
347 348
348 if (!get_prom(link)) { 349 if (!get_prom(link)) {
349 printk(KERN_NOTICE "axnet_cs: this is not an AX88190 card!\n"); 350 printk(KERN_NOTICE "axnet_cs: this is not an AX88190 card!\n");
@@ -379,8 +380,7 @@ static int axnet_config(struct pcmcia_device *link)
379 /* Maybe PHY is in power down mode. (PPD_SET = 1) 380 /* Maybe PHY is in power down mode. (PPD_SET = 1)
380 Bit 2 of CCSR is active low. */ 381 Bit 2 of CCSR is active low. */
381 if (i == 32) { 382 if (i == 32) {
382 conf_reg_t reg = { 0, CS_WRITE, CISREG_CCSR, 0x04 }; 383 pcmcia_write_config_byte(link, CISREG_CCSR, 0x04);
383 pcmcia_access_configuration_register(link, &reg);
384 for (i = 0; i < 32; i++) { 384 for (i = 0; i < 32; i++) {
385 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1); 385 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1);
386 j2 = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 2); 386 j2 = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 2);
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 5643f94541bc..3c400cfa82ae 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -43,7 +43,6 @@
43#include <linux/arcdevice.h> 43#include <linux/arcdevice.h>
44#include <linux/com20020.h> 44#include <linux/com20020.h>
45 45
46#include <pcmcia/cs_types.h>
47#include <pcmcia/cs.h> 46#include <pcmcia/cs.h>
48#include <pcmcia/cistpl.h> 47#include <pcmcia/cistpl.h>
49#include <pcmcia/ds.h> 48#include <pcmcia/ds.h>
@@ -159,9 +158,8 @@ static int com20020_probe(struct pcmcia_device *p_dev)
159 /* fill in our module parameters as defaults */ 158 /* fill in our module parameters as defaults */
160 dev->dev_addr[0] = node; 159 dev->dev_addr[0] = node;
161 160
162 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 161 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
163 p_dev->io.NumPorts1 = 16; 162 p_dev->resource[0]->end = 16;
164 p_dev->io.IOAddrLines = 16;
165 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 163 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
166 p_dev->conf.IntType = INT_MEMORY_AND_IO; 164 p_dev->conf.IntType = INT_MEMORY_AND_IO;
167 165
@@ -246,20 +244,24 @@ static int com20020_config(struct pcmcia_device *link)
246 244
247 dev_dbg(&link->dev, "com20020_config\n"); 245 dev_dbg(&link->dev, "com20020_config\n");
248 246
249 dev_dbg(&link->dev, "baseport1 is %Xh\n", link->io.BasePort1); 247 dev_dbg(&link->dev, "baseport1 is %Xh\n",
248 (unsigned int) link->resource[0]->start);
249
250 i = -ENODEV; 250 i = -ENODEV;
251 if (!link->io.BasePort1) 251 link->io_lines = 16;
252
253 if (!link->resource[0]->start)
252 { 254 {
253 for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) 255 for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10)
254 { 256 {
255 link->io.BasePort1 = ioaddr; 257 link->resource[0]->start = ioaddr;
256 i = pcmcia_request_io(link, &link->io); 258 i = pcmcia_request_io(link);
257 if (i == 0) 259 if (i == 0)
258 break; 260 break;
259 } 261 }
260 } 262 }
261 else 263 else
262 i = pcmcia_request_io(link, &link->io); 264 i = pcmcia_request_io(link);
263 265
264 if (i != 0) 266 if (i != 0)
265 { 267 {
@@ -267,7 +269,7 @@ static int com20020_config(struct pcmcia_device *link)
267 goto failed; 269 goto failed;
268 } 270 }
269 271
270 ioaddr = dev->base_addr = link->io.BasePort1; 272 ioaddr = dev->base_addr = link->resource[0]->start;
271 dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr); 273 dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr);
272 274
273 dev_dbg(&link->dev, "request IRQ %d\n", 275 dev_dbg(&link->dev, "request IRQ %d\n",
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 7c27c50211a5..98fffb03ecd7 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -49,7 +49,6 @@
49#include <linux/ioport.h> 49#include <linux/ioport.h>
50#include <linux/crc32.h> 50#include <linux/crc32.h>
51 51
52#include <pcmcia/cs_types.h>
53#include <pcmcia/cs.h> 52#include <pcmcia/cs.h>
54#include <pcmcia/cistpl.h> 53#include <pcmcia/cistpl.h>
55#include <pcmcia/ciscode.h> 54#include <pcmcia/ciscode.h>
@@ -249,9 +248,8 @@ static int fmvj18x_probe(struct pcmcia_device *link)
249 lp->base = NULL; 248 lp->base = NULL;
250 249
251 /* The io structure describes IO port mapping */ 250 /* The io structure describes IO port mapping */
252 link->io.NumPorts1 = 32; 251 link->resource[0]->end = 32;
253 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 252 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
254 link->io.IOAddrLines = 5;
255 253
256 /* General socket configuration */ 254 /* General socket configuration */
257 link->conf.Attributes = CONF_ENABLE_IRQ; 255 link->conf.Attributes = CONF_ENABLE_IRQ;
@@ -289,13 +287,13 @@ static int mfc_try_io_port(struct pcmcia_device *link)
289 { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 287 { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
290 288
291 for (i = 0; i < 5; i++) { 289 for (i = 0; i < 5; i++) {
292 link->io.BasePort2 = serial_base[i]; 290 link->resource[1]->start = serial_base[i];
293 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 291 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
294 if (link->io.BasePort2 == 0) { 292 if (link->resource[1]->start == 0) {
295 link->io.NumPorts2 = 0; 293 link->resource[1]->end = 0;
296 printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); 294 printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n");
297 } 295 }
298 ret = pcmcia_request_io(link, &link->io); 296 ret = pcmcia_request_io(link);
299 if (ret == 0) 297 if (ret == 0)
300 return ret; 298 return ret;
301 } 299 }
@@ -311,12 +309,12 @@ static int ungermann_try_io_port(struct pcmcia_device *link)
311 0x380,0x3c0 only for ioport. 309 0x380,0x3c0 only for ioport.
312 */ 310 */
313 for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { 311 for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) {
314 link->io.BasePort1 = ioaddr; 312 link->resource[0]->start = ioaddr;
315 ret = pcmcia_request_io(link, &link->io); 313 ret = pcmcia_request_io(link);
316 if (ret == 0) { 314 if (ret == 0) {
317 /* calculate ConfigIndex value */ 315 /* calculate ConfigIndex value */
318 link->conf.ConfigIndex = 316 link->conf.ConfigIndex =
319 ((link->io.BasePort1 & 0x0f0) >> 3) | 0x22; 317 ((link->resource[0]->start & 0x0f0) >> 3) | 0x22;
320 return ret; 318 return ret;
321 } 319 }
322 } 320 }
@@ -346,6 +344,8 @@ static int fmvj18x_config(struct pcmcia_device *link)
346 344
347 dev_dbg(&link->dev, "fmvj18x_config\n"); 345 dev_dbg(&link->dev, "fmvj18x_config\n");
348 346
347 link->io_lines = 5;
348
349 len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf); 349 len = pcmcia_get_tuple(link, CISTPL_FUNCE, &buf);
350 kfree(buf); 350 kfree(buf);
351 351
@@ -364,20 +364,20 @@ static int fmvj18x_config(struct pcmcia_device *link)
364 /* MultiFunction Card */ 364 /* MultiFunction Card */
365 link->conf.ConfigBase = 0x800; 365 link->conf.ConfigBase = 0x800;
366 link->conf.ConfigIndex = 0x47; 366 link->conf.ConfigIndex = 0x47;
367 link->io.NumPorts2 = 8; 367 link->resource[1]->end = 8;
368 } 368 }
369 break; 369 break;
370 case MANFID_NEC: 370 case MANFID_NEC:
371 cardtype = NEC; /* MultiFunction Card */ 371 cardtype = NEC; /* MultiFunction Card */
372 link->conf.ConfigBase = 0x800; 372 link->conf.ConfigBase = 0x800;
373 link->conf.ConfigIndex = 0x47; 373 link->conf.ConfigIndex = 0x47;
374 link->io.NumPorts2 = 8; 374 link->resource[1]->end = 8;
375 break; 375 break;
376 case MANFID_KME: 376 case MANFID_KME:
377 cardtype = KME; /* MultiFunction Card */ 377 cardtype = KME; /* MultiFunction Card */
378 link->conf.ConfigBase = 0x800; 378 link->conf.ConfigBase = 0x800;
379 link->conf.ConfigIndex = 0x47; 379 link->conf.ConfigIndex = 0x47;
380 link->io.NumPorts2 = 8; 380 link->resource[1]->end = 8;
381 break; 381 break;
382 case MANFID_CONTEC: 382 case MANFID_CONTEC:
383 cardtype = CONTEC; 383 cardtype = CONTEC;
@@ -418,14 +418,14 @@ static int fmvj18x_config(struct pcmcia_device *link)
418 } 418 }
419 } 419 }
420 420
421 if (link->io.NumPorts2 != 0) { 421 if (link->resource[1]->end != 0) {
422 ret = mfc_try_io_port(link); 422 ret = mfc_try_io_port(link);
423 if (ret != 0) goto failed; 423 if (ret != 0) goto failed;
424 } else if (cardtype == UNGERMANN) { 424 } else if (cardtype == UNGERMANN) {
425 ret = ungermann_try_io_port(link); 425 ret = ungermann_try_io_port(link);
426 if (ret != 0) goto failed; 426 if (ret != 0) goto failed;
427 } else { 427 } else {
428 ret = pcmcia_request_io(link, &link->io); 428 ret = pcmcia_request_io(link);
429 if (ret) 429 if (ret)
430 goto failed; 430 goto failed;
431 } 431 }
@@ -437,9 +437,9 @@ static int fmvj18x_config(struct pcmcia_device *link)
437 goto failed; 437 goto failed;
438 438
439 dev->irq = link->irq; 439 dev->irq = link->irq;
440 dev->base_addr = link->io.BasePort1; 440 dev->base_addr = link->resource[0]->start;
441 441
442 if (link->io.BasePort2 != 0) { 442 if (resource_size(link->resource[1]) != 0) {
443 ret = fmvj18x_setup_mfc(link); 443 ret = fmvj18x_setup_mfc(link);
444 if (ret != 0) goto failed; 444 if (ret != 0) goto failed;
445 } 445 }
@@ -545,7 +545,6 @@ failed:
545static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id) 545static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
546{ 546{
547 win_req_t req; 547 win_req_t req;
548 memreq_t mem;
549 u_char __iomem *base; 548 u_char __iomem *base;
550 int i, j; 549 int i, j;
551 550
@@ -558,9 +557,7 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
558 return -1; 557 return -1;
559 558
560 base = ioremap(req.Base, req.Size); 559 base = ioremap(req.Base, req.Size);
561 mem.Page = 0; 560 pcmcia_map_mem_page(link, link->win, 0);
562 mem.CardOffset = 0;
563 pcmcia_map_mem_page(link, link->win, &mem);
564 561
565 /* 562 /*
566 * MBH10304 CISTPL_FUNCE_LAN_NODE_ID format 563 * MBH10304 CISTPL_FUNCE_LAN_NODE_ID format
@@ -594,7 +591,6 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
594static int fmvj18x_setup_mfc(struct pcmcia_device *link) 591static int fmvj18x_setup_mfc(struct pcmcia_device *link)
595{ 592{
596 win_req_t req; 593 win_req_t req;
597 memreq_t mem;
598 int i; 594 int i;
599 struct net_device *dev = link->priv; 595 struct net_device *dev = link->priv;
600 unsigned int ioaddr; 596 unsigned int ioaddr;
@@ -614,9 +610,7 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link)
614 return -1; 610 return -1;
615 } 611 }
616 612
617 mem.Page = 0; 613 i = pcmcia_map_mem_page(link, link->win, 0);
618 mem.CardOffset = 0;
619 i = pcmcia_map_mem_page(link, link->win, &mem);
620 if (i != 0) { 614 if (i != 0) {
621 iounmap(lp->base); 615 iounmap(lp->base);
622 lp->base = NULL; 616 lp->base = NULL;
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 67ee9851a8ed..b0d06a3d962f 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -57,7 +57,6 @@
57#include <linux/trdevice.h> 57#include <linux/trdevice.h>
58#include <linux/ibmtr.h> 58#include <linux/ibmtr.h>
59 59
60#include <pcmcia/cs_types.h>
61#include <pcmcia/cs.h> 60#include <pcmcia/cs.h>
62#include <pcmcia/cistpl.h> 61#include <pcmcia/cistpl.h>
63#include <pcmcia/ds.h> 62#include <pcmcia/ds.h>
@@ -152,9 +151,8 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link)
152 link->priv = info; 151 link->priv = info;
153 info->ti = netdev_priv(dev); 152 info->ti = netdev_priv(dev);
154 153
155 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 154 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
156 link->io.NumPorts1 = 4; 155 link->resource[0]->end = 4;
157 link->io.IOAddrLines = 16;
158 link->conf.Attributes = CONF_ENABLE_IRQ; 156 link->conf.Attributes = CONF_ENABLE_IRQ;
159 link->conf.IntType = INT_MEMORY_AND_IO; 157 link->conf.IntType = INT_MEMORY_AND_IO;
160 link->conf.Present = PRESENT_OPTION; 158 link->conf.Present = PRESENT_OPTION;
@@ -213,26 +211,26 @@ static int __devinit ibmtr_config(struct pcmcia_device *link)
213 struct net_device *dev = info->dev; 211 struct net_device *dev = info->dev;
214 struct tok_info *ti = netdev_priv(dev); 212 struct tok_info *ti = netdev_priv(dev);
215 win_req_t req; 213 win_req_t req;
216 memreq_t mem;
217 int i, ret; 214 int i, ret;
218 215
219 dev_dbg(&link->dev, "ibmtr_config\n"); 216 dev_dbg(&link->dev, "ibmtr_config\n");
220 217
221 link->conf.ConfigIndex = 0x61; 218 link->conf.ConfigIndex = 0x61;
219 link->io_lines = 16;
222 220
223 /* Determine if this is PRIMARY or ALTERNATE. */ 221 /* Determine if this is PRIMARY or ALTERNATE. */
224 222
225 /* Try PRIMARY card at 0xA20-0xA23 */ 223 /* Try PRIMARY card at 0xA20-0xA23 */
226 link->io.BasePort1 = 0xA20; 224 link->resource[0]->start = 0xA20;
227 i = pcmcia_request_io(link, &link->io); 225 i = pcmcia_request_io(link);
228 if (i != 0) { 226 if (i != 0) {
229 /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ 227 /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */
230 link->io.BasePort1 = 0xA24; 228 link->resource[0]->start = 0xA24;
231 ret = pcmcia_request_io(link, &link->io); 229 ret = pcmcia_request_io(link);
232 if (ret) 230 if (ret)
233 goto failed; 231 goto failed;
234 } 232 }
235 dev->base_addr = link->io.BasePort1; 233 dev->base_addr = link->resource[0]->start;
236 234
237 ret = pcmcia_request_exclusive_irq(link, ibmtr_interrupt); 235 ret = pcmcia_request_exclusive_irq(link, ibmtr_interrupt);
238 if (ret) 236 if (ret)
@@ -251,9 +249,7 @@ static int __devinit ibmtr_config(struct pcmcia_device *link)
251 if (ret) 249 if (ret)
252 goto failed; 250 goto failed;
253 251
254 mem.CardOffset = mmiobase; 252 ret = pcmcia_map_mem_page(link, link->win, mmiobase);
255 mem.Page = 0;
256 ret = pcmcia_map_mem_page(link, link->win, &mem);
257 if (ret) 253 if (ret)
258 goto failed; 254 goto failed;
259 ti->mmio = ioremap(req.Base, req.Size); 255 ti->mmio = ioremap(req.Base, req.Size);
@@ -268,13 +264,11 @@ static int __devinit ibmtr_config(struct pcmcia_device *link)
268 if (ret) 264 if (ret)
269 goto failed; 265 goto failed;
270 266
271 mem.CardOffset = srambase; 267 ret = pcmcia_map_mem_page(link, info->sram_win_handle, srambase);
272 mem.Page = 0;
273 ret = pcmcia_map_mem_page(link, info->sram_win_handle, &mem);
274 if (ret) 268 if (ret)
275 goto failed; 269 goto failed;
276 270
277 ti->sram_base = mem.CardOffset >> 12; 271 ti->sram_base = srambase >> 12;
278 ti->sram_virt = ioremap(req.Base, req.Size); 272 ti->sram_virt = ioremap(req.Base, req.Size);
279 ti->sram_phys = req.Base; 273 ti->sram_phys = req.Base;
280 274
@@ -325,7 +319,6 @@ static void ibmtr_release(struct pcmcia_device *link)
325 if (link->win) { 319 if (link->win) {
326 struct tok_info *ti = netdev_priv(dev); 320 struct tok_info *ti = netdev_priv(dev);
327 iounmap(ti->mmio); 321 iounmap(ti->mmio);
328 pcmcia_release_window(link, info->sram_win_handle);
329 } 322 }
330 pcmcia_disable_device(link); 323 pcmcia_disable_device(link);
331} 324}
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 9b63dec549cb..68f2deeb3ade 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -146,7 +146,6 @@ Include Files
146#include <linux/ioport.h> 146#include <linux/ioport.h>
147#include <linux/bitops.h> 147#include <linux/bitops.h>
148 148
149#include <pcmcia/cs_types.h>
150#include <pcmcia/cs.h> 149#include <pcmcia/cs.h>
151#include <pcmcia/cisreg.h> 150#include <pcmcia/cisreg.h>
152#include <pcmcia/cistpl.h> 151#include <pcmcia/cistpl.h>
@@ -459,9 +458,8 @@ static int nmclan_probe(struct pcmcia_device *link)
459 link->priv = dev; 458 link->priv = dev;
460 459
461 spin_lock_init(&lp->bank_lock); 460 spin_lock_init(&lp->bank_lock);
462 link->io.NumPorts1 = 32; 461 link->resource[0]->end = 32;
463 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 462 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
464 link->io.IOAddrLines = 5;
465 link->conf.Attributes = CONF_ENABLE_IRQ; 463 link->conf.Attributes = CONF_ENABLE_IRQ;
466 link->conf.IntType = INT_MEMORY_AND_IO; 464 link->conf.IntType = INT_MEMORY_AND_IO;
467 link->conf.ConfigIndex = 1; 465 link->conf.ConfigIndex = 1;
@@ -645,7 +643,8 @@ static int nmclan_config(struct pcmcia_device *link)
645 643
646 dev_dbg(&link->dev, "nmclan_config\n"); 644 dev_dbg(&link->dev, "nmclan_config\n");
647 645
648 ret = pcmcia_request_io(link, &link->io); 646 link->io_lines = 5;
647 ret = pcmcia_request_io(link);
649 if (ret) 648 if (ret)
650 goto failed; 649 goto failed;
651 ret = pcmcia_request_exclusive_irq(link, mace_interrupt); 650 ret = pcmcia_request_exclusive_irq(link, mace_interrupt);
@@ -656,7 +655,7 @@ static int nmclan_config(struct pcmcia_device *link)
656 goto failed; 655 goto failed;
657 656
658 dev->irq = link->irq; 657 dev->irq = link->irq;
659 dev->base_addr = link->io.BasePort1; 658 dev->base_addr = link->resource[0]->start;
660 659
661 ioaddr = dev->base_addr; 660 ioaddr = dev->base_addr;
662 661
@@ -758,29 +757,20 @@ static void nmclan_reset(struct net_device *dev)
758 757
759#if RESET_XILINX 758#if RESET_XILINX
760 struct pcmcia_device *link = &lp->link; 759 struct pcmcia_device *link = &lp->link;
761 conf_reg_t reg; 760 u8 OrigCorValue;
762 u_long OrigCorValue;
763 761
764 /* Save original COR value */ 762 /* Save original COR value */
765 reg.Function = 0; 763 pcmcia_read_config_byte(link, CISREG_COR, &OrigCorValue);
766 reg.Action = CS_READ;
767 reg.Offset = CISREG_COR;
768 reg.Value = 0;
769 pcmcia_access_configuration_register(link, &reg);
770 OrigCorValue = reg.Value;
771 764
772 /* Reset Xilinx */ 765 /* Reset Xilinx */
773 reg.Action = CS_WRITE; 766 dev_dbg(&link->dev, "nmclan_reset: OrigCorValue=0x%x, resetting...\n",
774 reg.Offset = CISREG_COR;
775 dev_dbg(&link->dev, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n",
776 OrigCorValue); 767 OrigCorValue);
777 reg.Value = COR_SOFT_RESET; 768 pcmcia_write_config_byte(link, CISREG_COR, COR_SOFT_RESET);
778 pcmcia_access_configuration_register(link, &reg);
779 /* Need to wait for 20 ms for PCMCIA to finish reset. */ 769 /* Need to wait for 20 ms for PCMCIA to finish reset. */
780 770
781 /* Restore original COR configuration index */ 771 /* Restore original COR configuration index */
782 reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK); 772 pcmcia_write_config_byte(link, CISREG_COR,
783 pcmcia_access_configuration_register(link, &reg); 773 (COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK)));
784 /* Xilinx is now completely reset along with the MACE chip. */ 774 /* Xilinx is now completely reset along with the MACE chip. */
785 lp->tx_free_frames=AM2150_MAX_TX_FRAMES; 775 lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
786 776
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index bfdef72c5d5e..c3edfe4c2651 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -42,7 +42,6 @@
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include "../8390.h" 43#include "../8390.h"
44 44
45#include <pcmcia/cs_types.h>
46#include <pcmcia/cs.h> 45#include <pcmcia/cs.h>
47#include <pcmcia/cistpl.h> 46#include <pcmcia/cistpl.h>
48#include <pcmcia/ciscode.h> 47#include <pcmcia/ciscode.h>
@@ -113,8 +112,6 @@ static int setup_dma_config(struct pcmcia_device *link, int start_pg,
113 112
114static void pcnet_detach(struct pcmcia_device *p_dev); 113static void pcnet_detach(struct pcmcia_device *p_dev);
115 114
116static dev_info_t dev_info = "pcnet_cs";
117
118/*====================================================================*/ 115/*====================================================================*/
119 116
120typedef struct hw_info_t { 117typedef struct hw_info_t {
@@ -304,7 +301,6 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
304{ 301{
305 struct net_device *dev = link->priv; 302 struct net_device *dev = link->priv;
306 win_req_t req; 303 win_req_t req;
307 memreq_t mem;
308 u_char __iomem *base, *virt; 304 u_char __iomem *base, *virt;
309 int i, j; 305 int i, j;
310 306
@@ -317,10 +313,8 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
317 return NULL; 313 return NULL;
318 314
319 virt = ioremap(req.Base, req.Size); 315 virt = ioremap(req.Base, req.Size);
320 mem.Page = 0;
321 for (i = 0; i < NR_INFO; i++) { 316 for (i = 0; i < NR_INFO; i++) {
322 mem.CardOffset = hw_info[i].offset & ~(req.Size-1); 317 pcmcia_map_mem_page(link, link->win, hw_info[i].offset & ~(req.Size-1));
323 pcmcia_map_mem_page(link, link->win, &mem);
324 base = &virt[hw_info[i].offset & (req.Size-1)]; 318 base = &virt[hw_info[i].offset & (req.Size-1)];
325 if ((readb(base+0) == hw_info[i].a0) && 319 if ((readb(base+0) == hw_info[i].a0) &&
326 (readb(base+2) == hw_info[i].a1) && 320 (readb(base+2) == hw_info[i].a1) &&
@@ -480,29 +474,31 @@ static hw_info_t *get_hwired(struct pcmcia_device *link)
480static int try_io_port(struct pcmcia_device *link) 474static int try_io_port(struct pcmcia_device *link)
481{ 475{
482 int j, ret; 476 int j, ret;
483 if (link->io.NumPorts1 == 32) { 477 link->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
484 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 478 link->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
485 if (link->io.NumPorts2 > 0) { 479 if (link->resource[0]->end == 32) {
480 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
481 if (link->resource[1]->end > 0) {
486 /* for master/slave multifunction cards */ 482 /* for master/slave multifunction cards */
487 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 483 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
488 } 484 }
489 } else { 485 } else {
490 /* This should be two 16-port windows */ 486 /* This should be two 16-port windows */
491 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 487 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
492 link->io.Attributes2 = IO_DATA_PATH_WIDTH_16; 488 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_16;
493 } 489 }
494 if (link->io.BasePort1 == 0) { 490 if (link->resource[0]->start == 0) {
495 link->io.IOAddrLines = 16;
496 for (j = 0; j < 0x400; j += 0x20) { 491 for (j = 0; j < 0x400; j += 0x20) {
497 link->io.BasePort1 = j ^ 0x300; 492 link->resource[0]->start = j ^ 0x300;
498 link->io.BasePort2 = (j ^ 0x300) + 0x10; 493 link->resource[1]->start = (j ^ 0x300) + 0x10;
499 ret = pcmcia_request_io(link, &link->io); 494 link->io_lines = 16;
495 ret = pcmcia_request_io(link);
500 if (ret == 0) 496 if (ret == 0)
501 return ret; 497 return ret;
502 } 498 }
503 return ret; 499 return ret;
504 } else { 500 } else {
505 return pcmcia_request_io(link, &link->io); 501 return pcmcia_request_io(link);
506 } 502 }
507} 503}
508 504
@@ -523,18 +519,18 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev,
523 network function with window 0, and serial with window 1 */ 519 network function with window 0, and serial with window 1 */
524 if (io->nwin > 1) { 520 if (io->nwin > 1) {
525 i = (io->win[1].len > io->win[0].len); 521 i = (io->win[1].len > io->win[0].len);
526 p_dev->io.BasePort2 = io->win[1-i].base; 522 p_dev->resource[1]->start = io->win[1-i].base;
527 p_dev->io.NumPorts2 = io->win[1-i].len; 523 p_dev->resource[1]->end = io->win[1-i].len;
528 } else { 524 } else {
529 i = p_dev->io.NumPorts2 = 0; 525 i = p_dev->resource[1]->end = 0;
530 } 526 }
531 527
532 *has_shmem = ((cfg->mem.nwin == 1) && 528 *has_shmem = ((cfg->mem.nwin == 1) &&
533 (cfg->mem.win[0].len >= 0x4000)); 529 (cfg->mem.win[0].len >= 0x4000));
534 p_dev->io.BasePort1 = io->win[i].base; 530 p_dev->resource[0]->start = io->win[i].base;
535 p_dev->io.NumPorts1 = io->win[i].len; 531 p_dev->resource[0]->end = io->win[i].len;
536 p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 532 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
537 if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) 533 if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32)
538 return try_io_port(p_dev); 534 return try_io_port(p_dev);
539 535
540 return 0; 536 return 0;
@@ -557,7 +553,7 @@ static int pcnet_config(struct pcmcia_device *link)
557 if (!link->irq) 553 if (!link->irq)
558 goto failed; 554 goto failed;
559 555
560 if (link->io.NumPorts2 == 8) { 556 if (resource_size(link->resource[1]) == 8) {
561 link->conf.Attributes |= CONF_ENABLE_SPKR; 557 link->conf.Attributes |= CONF_ENABLE_SPKR;
562 link->conf.Status = CCSR_AUDIO_ENA; 558 link->conf.Status = CCSR_AUDIO_ENA;
563 } 559 }
@@ -569,7 +565,7 @@ static int pcnet_config(struct pcmcia_device *link)
569 if (ret) 565 if (ret)
570 goto failed; 566 goto failed;
571 dev->irq = link->irq; 567 dev->irq = link->irq;
572 dev->base_addr = link->io.BasePort1; 568 dev->base_addr = link->resource[0]->start;
573 if (info->flags & HAS_MISC_REG) { 569 if (info->flags & HAS_MISC_REG) {
574 if ((if_port == 1) || (if_port == 2)) 570 if ((if_port == 1) || (if_port == 2))
575 dev->if_port = if_port; 571 dev->if_port = if_port;
@@ -956,7 +952,7 @@ static int pcnet_open(struct net_device *dev)
956 set_misc_reg(dev); 952 set_misc_reg(dev);
957 953
958 outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */ 954 outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */
959 ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev_info, dev); 955 ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev->name, dev);
960 if (ret) 956 if (ret)
961 return ret; 957 return ret;
962 958
@@ -1464,7 +1460,6 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1464 struct net_device *dev = link->priv; 1460 struct net_device *dev = link->priv;
1465 pcnet_dev_t *info = PRIV(dev); 1461 pcnet_dev_t *info = PRIV(dev);
1466 win_req_t req; 1462 win_req_t req;
1467 memreq_t mem;
1468 int i, window_size, offset, ret; 1463 int i, window_size, offset, ret;
1469 1464
1470 window_size = (stop_pg - start_pg) << 8; 1465 window_size = (stop_pg - start_pg) << 8;
@@ -1483,11 +1478,9 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1483 if (ret) 1478 if (ret)
1484 goto failed; 1479 goto failed;
1485 1480
1486 mem.CardOffset = (start_pg << 8) + cm_offset; 1481 offset = (start_pg << 8) + cm_offset;
1487 offset = mem.CardOffset % window_size; 1482 offset -= offset % window_size;
1488 mem.CardOffset -= offset; 1483 ret = pcmcia_map_mem_page(link, link->win, offset);
1489 mem.Page = 0;
1490 ret = pcmcia_map_mem_page(link, link->win, &mem);
1491 if (ret) 1484 if (ret)
1492 goto failed; 1485 goto failed;
1493 1486
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 307cd1721e91..377367d03b41 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -44,7 +44,6 @@
44#include <linux/jiffies.h> 44#include <linux/jiffies.h>
45#include <linux/firmware.h> 45#include <linux/firmware.h>
46 46
47#include <pcmcia/cs_types.h>
48#include <pcmcia/cs.h> 47#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
50#include <pcmcia/cisreg.h> 49#include <pcmcia/cisreg.h>
@@ -325,9 +324,8 @@ static int smc91c92_probe(struct pcmcia_device *link)
325 link->priv = dev; 324 link->priv = dev;
326 325
327 spin_lock_init(&smc->lock); 326 spin_lock_init(&smc->lock);
328 link->io.NumPorts1 = 16; 327 link->resource[0]->end = 16;
329 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 328 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
330 link->io.IOAddrLines = 4;
331 link->conf.Attributes = CONF_ENABLE_IRQ; 329 link->conf.Attributes = CONF_ENABLE_IRQ;
332 link->conf.IntType = INT_MEMORY_AND_IO; 330 link->conf.IntType = INT_MEMORY_AND_IO;
333 331
@@ -428,12 +426,13 @@ static int mhz_mfc_config_check(struct pcmcia_device *p_dev,
428 void *priv_data) 426 void *priv_data)
429{ 427{
430 int k; 428 int k;
431 p_dev->io.BasePort2 = cf->io.win[0].base; 429 p_dev->resource[1]->start = cf->io.win[0].base;
432 for (k = 0; k < 0x400; k += 0x10) { 430 for (k = 0; k < 0x400; k += 0x10) {
433 if (k & 0x80) 431 if (k & 0x80)
434 continue; 432 continue;
435 p_dev->io.BasePort1 = k ^ 0x300; 433 p_dev->resource[0]->start = k ^ 0x300;
436 if (!pcmcia_request_io(p_dev, &p_dev->io)) 434 p_dev->io_lines = 16;
435 if (!pcmcia_request_io(p_dev))
437 return 0; 436 return 0;
438 } 437 }
439 return -ENODEV; 438 return -ENODEV;
@@ -444,21 +443,20 @@ static int mhz_mfc_config(struct pcmcia_device *link)
444 struct net_device *dev = link->priv; 443 struct net_device *dev = link->priv;
445 struct smc_private *smc = netdev_priv(dev); 444 struct smc_private *smc = netdev_priv(dev);
446 win_req_t req; 445 win_req_t req;
447 memreq_t mem; 446 unsigned int offset;
448 int i; 447 int i;
449 448
450 link->conf.Attributes |= CONF_ENABLE_SPKR; 449 link->conf.Attributes |= CONF_ENABLE_SPKR;
451 link->conf.Status = CCSR_AUDIO_ENA; 450 link->conf.Status = CCSR_AUDIO_ENA;
452 link->io.IOAddrLines = 16; 451 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
453 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 452 link->resource[1]->end = 8;
454 link->io.NumPorts2 = 8;
455 453
456 /* The Megahertz combo cards have modem-like CIS entries, so 454 /* The Megahertz combo cards have modem-like CIS entries, so
457 we have to explicitly try a bunch of port combinations. */ 455 we have to explicitly try a bunch of port combinations. */
458 if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL)) 456 if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL))
459 return -ENODEV; 457 return -ENODEV;
460 458
461 dev->base_addr = link->io.BasePort1; 459 dev->base_addr = link->resource[0]->start;
462 460
463 /* Allocate a memory window, for accessing the ISR */ 461 /* Allocate a memory window, for accessing the ISR */
464 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 462 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
@@ -469,11 +467,8 @@ static int mhz_mfc_config(struct pcmcia_device *link)
469 return -ENODEV; 467 return -ENODEV;
470 468
471 smc->base = ioremap(req.Base, req.Size); 469 smc->base = ioremap(req.Base, req.Size);
472 mem.CardOffset = mem.Page = 0; 470 offset = (smc->manfid == MANFID_MOTOROLA) ? link->conf.ConfigBase : 0;
473 if (smc->manfid == MANFID_MOTOROLA) 471 i = pcmcia_map_mem_page(link, link->win, offset);
474 mem.CardOffset = link->conf.ConfigBase;
475 i = pcmcia_map_mem_page(link, link->win, &mem);
476
477 if ((i == 0) && 472 if ((i == 0) &&
478 (smc->manfid == MANFID_MEGAHERTZ) && 473 (smc->manfid == MANFID_MEGAHERTZ) &&
479 (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 474 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
@@ -546,7 +541,7 @@ static void mot_config(struct pcmcia_device *link)
546 struct net_device *dev = link->priv; 541 struct net_device *dev = link->priv;
547 struct smc_private *smc = netdev_priv(dev); 542 struct smc_private *smc = netdev_priv(dev);
548 unsigned int ioaddr = dev->base_addr; 543 unsigned int ioaddr = dev->base_addr;
549 unsigned int iouart = link->io.BasePort2; 544 unsigned int iouart = link->resource[1]->start;
550 545
551 /* Set UART base address and force map with COR bit 1 */ 546 /* Set UART base address and force map with COR bit 1 */
552 writeb(iouart & 0xff, smc->base + MOT_UART + CISREG_IOBASE_0); 547 writeb(iouart & 0xff, smc->base + MOT_UART + CISREG_IOBASE_0);
@@ -602,9 +597,9 @@ static int smc_configcheck(struct pcmcia_device *p_dev,
602 unsigned int vcc, 597 unsigned int vcc,
603 void *priv_data) 598 void *priv_data)
604{ 599{
605 p_dev->io.BasePort1 = cf->io.win[0].base; 600 p_dev->resource[0]->start = cf->io.win[0].base;
606 p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 601 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK;
607 return pcmcia_request_io(p_dev, &p_dev->io); 602 return pcmcia_request_io(p_dev);
608} 603}
609 604
610static int smc_config(struct pcmcia_device *link) 605static int smc_config(struct pcmcia_device *link)
@@ -612,10 +607,10 @@ static int smc_config(struct pcmcia_device *link)
612 struct net_device *dev = link->priv; 607 struct net_device *dev = link->priv;
613 int i; 608 int i;
614 609
615 link->io.NumPorts1 = 16; 610 link->resource[0]->end = 16;
616 i = pcmcia_loop_config(link, smc_configcheck, NULL); 611 i = pcmcia_loop_config(link, smc_configcheck, NULL);
617 if (!i) 612 if (!i)
618 dev->base_addr = link->io.BasePort1; 613 dev->base_addr = link->resource[0]->start;
619 614
620 return i; 615 return i;
621} 616}
@@ -647,27 +642,27 @@ static int osi_config(struct pcmcia_device *link)
647 642
648 link->conf.Attributes |= CONF_ENABLE_SPKR; 643 link->conf.Attributes |= CONF_ENABLE_SPKR;
649 link->conf.Status = CCSR_AUDIO_ENA; 644 link->conf.Status = CCSR_AUDIO_ENA;
650 link->io.NumPorts1 = 64; 645 link->resource[0]->end = 64;
651 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 646 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
652 link->io.NumPorts2 = 8; 647 link->resource[1]->end = 8;
653 link->io.IOAddrLines = 16;
654 648
655 /* Enable Hard Decode, LAN, Modem */ 649 /* Enable Hard Decode, LAN, Modem */
656 link->conf.ConfigIndex = 0x23; 650 link->conf.ConfigIndex = 0x23;
651 link->io_lines = 16;
657 652
658 for (i = j = 0; j < 4; j++) { 653 for (i = j = 0; j < 4; j++) {
659 link->io.BasePort2 = com[j]; 654 link->resource[1]->start = com[j];
660 i = pcmcia_request_io(link, &link->io); 655 i = pcmcia_request_io(link);
661 if (i == 0) 656 if (i == 0)
662 break; 657 break;
663 } 658 }
664 if (i != 0) { 659 if (i != 0) {
665 /* Fallback: turn off hard decode */ 660 /* Fallback: turn off hard decode */
666 link->conf.ConfigIndex = 0x03; 661 link->conf.ConfigIndex = 0x03;
667 link->io.NumPorts2 = 0; 662 link->resource[1]->end = 0;
668 i = pcmcia_request_io(link, &link->io); 663 i = pcmcia_request_io(link);
669 } 664 }
670 dev->base_addr = link->io.BasePort1 + 0x10; 665 dev->base_addr = link->resource[0]->start + 0x10;
671 return i; 666 return i;
672} 667}
673 668
@@ -684,7 +679,7 @@ static int osi_load_firmware(struct pcmcia_device *link)
684 679
685 /* Download the Seven of Diamonds firmware */ 680 /* Download the Seven of Diamonds firmware */
686 for (i = 0; i < fw->size; i++) { 681 for (i = 0; i < fw->size; i++) {
687 outb(fw->data[i], link->io.BasePort1 + 2); 682 outb(fw->data[i], link->resource[0]->start + 2);
688 udelay(50); 683 udelay(50);
689 } 684 }
690 release_firmware(fw); 685 release_firmware(fw);
@@ -726,12 +721,12 @@ static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid)
726 return rc; 721 return rc;
727 } else if (manfid == MANFID_OSITECH) { 722 } else if (manfid == MANFID_OSITECH) {
728 /* Make sure both functions are powered up */ 723 /* Make sure both functions are powered up */
729 set_bits(0x300, link->io.BasePort1 + OSITECH_AUI_PWR); 724 set_bits(0x300, link->resource[0]->start + OSITECH_AUI_PWR);
730 /* Now, turn on the interrupt for both card functions */ 725 /* Now, turn on the interrupt for both card functions */
731 set_bits(0x300, link->io.BasePort1 + OSITECH_RESET_ISR); 726 set_bits(0x300, link->resource[0]->start + OSITECH_RESET_ISR);
732 dev_dbg(&link->dev, "AUI/PWR: %4.4x RESET/ISR: %4.4x\n", 727 dev_dbg(&link->dev, "AUI/PWR: %4.4x RESET/ISR: %4.4x\n",
733 inw(link->io.BasePort1 + OSITECH_AUI_PWR), 728 inw(link->resource[0]->start + OSITECH_AUI_PWR),
734 inw(link->io.BasePort1 + OSITECH_RESET_ISR)); 729 inw(link->resource[0]->start + OSITECH_RESET_ISR));
735 } 730 }
736 return 0; 731 return 0;
737} 732}
@@ -804,7 +799,7 @@ static int check_sig(struct pcmcia_device *link)
804 } 799 }
805 800
806 /* Try setting bus width */ 801 /* Try setting bus width */
807 width = (link->io.Attributes1 == IO_DATA_PATH_WIDTH_AUTO); 802 width = (link->resource[0]->flags == IO_DATA_PATH_WIDTH_AUTO);
808 s = inb(ioaddr + CONFIG); 803 s = inb(ioaddr + CONFIG);
809 if (width) 804 if (width)
810 s |= CFG_16BIT; 805 s |= CFG_16BIT;
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index b6c3644888cd..4eb6f986703b 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -82,7 +82,6 @@
82#include <linux/bitops.h> 82#include <linux/bitops.h>
83#include <linux/mii.h> 83#include <linux/mii.h>
84 84
85#include <pcmcia/cs_types.h>
86#include <pcmcia/cs.h> 85#include <pcmcia/cs.h>
87#include <pcmcia/cistpl.h> 86#include <pcmcia/cistpl.h>
88#include <pcmcia/cisreg.h> 87#include <pcmcia/cisreg.h>
@@ -678,9 +677,9 @@ xirc2ps_config_modem(struct pcmcia_device *p_dev,
678 677
679 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 678 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) {
680 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 679 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
681 p_dev->io.BasePort2 = cf->io.win[0].base; 680 p_dev->resource[1]->start = cf->io.win[0].base;
682 p_dev->io.BasePort1 = ioaddr; 681 p_dev->resource[0]->start = ioaddr;
683 if (!pcmcia_request_io(p_dev, &p_dev->io)) 682 if (!pcmcia_request_io(p_dev))
684 return 0; 683 return 0;
685 } 684 }
686 } 685 }
@@ -697,11 +696,11 @@ xirc2ps_config_check(struct pcmcia_device *p_dev,
697 int *pass = priv_data; 696 int *pass = priv_data;
698 697
699 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 698 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) {
700 p_dev->io.BasePort2 = cf->io.win[0].base; 699 p_dev->resource[1]->start = cf->io.win[0].base;
701 p_dev->io.BasePort1 = p_dev->io.BasePort2 700 p_dev->resource[0]->start = p_dev->resource[1]->start
702 + (*pass ? (cf->index & 0x20 ? -24:8) 701 + (*pass ? (cf->index & 0x20 ? -24:8)
703 : (cf->index & 0x20 ? 8:-24)); 702 : (cf->index & 0x20 ? 8:-24));
704 if (!pcmcia_request_io(p_dev, &p_dev->io)) 703 if (!pcmcia_request_io(p_dev))
705 return 0; 704 return 0;
706 } 705 }
707 return -ENODEV; 706 return -ENODEV;
@@ -808,8 +807,7 @@ xirc2ps_config(struct pcmcia_device * link)
808 goto failure; 807 goto failure;
809 } 808 }
810 809
811 link->io.IOAddrLines =10; 810 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
812 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
813 if (local->modem) { 811 if (local->modem) {
814 int pass; 812 int pass;
815 813
@@ -817,16 +815,16 @@ xirc2ps_config(struct pcmcia_device * link)
817 link->conf.Attributes |= CONF_ENABLE_SPKR; 815 link->conf.Attributes |= CONF_ENABLE_SPKR;
818 link->conf.Status |= CCSR_AUDIO_ENA; 816 link->conf.Status |= CCSR_AUDIO_ENA;
819 } 817 }
820 link->io.NumPorts2 = 8; 818 link->resource[1]->end = 8;
821 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 819 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
822 if (local->dingo) { 820 if (local->dingo) {
823 /* Take the Modem IO port from the CIS and scan for a free 821 /* Take the Modem IO port from the CIS and scan for a free
824 * Ethernet port */ 822 * Ethernet port */
825 link->io.NumPorts1 = 16; /* no Mako stuff anymore */ 823 link->resource[0]->end = 16; /* no Mako stuff anymore */
826 if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL)) 824 if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL))
827 goto port_found; 825 goto port_found;
828 } else { 826 } else {
829 link->io.NumPorts1 = 18; 827 link->resource[0]->end = 18;
830 /* We do 2 passes here: The first one uses the regular mapping and 828 /* We do 2 passes here: The first one uses the regular mapping and
831 * the second tries again, thereby considering that the 32 ports are 829 * the second tries again, thereby considering that the 32 ports are
832 * mirrored every 32 bytes. Actually we use a mirrored port for 830 * mirrored every 32 bytes. Actually we use a mirrored port for
@@ -841,14 +839,15 @@ xirc2ps_config(struct pcmcia_device * link)
841 } 839 }
842 printk(KNOT_XIRC "no ports available\n"); 840 printk(KNOT_XIRC "no ports available\n");
843 } else { 841 } else {
844 link->io.NumPorts1 = 16; 842 link->io_lines = 10;
843 link->resource[0]->end = 16;
845 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 844 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
846 link->io.BasePort1 = ioaddr; 845 link->resource[0]->start = ioaddr;
847 if (!(err=pcmcia_request_io(link, &link->io))) 846 if (!(err = pcmcia_request_io(link)))
848 goto port_found; 847 goto port_found;
849 } 848 }
850 link->io.BasePort1 = 0; /* let CS decide */ 849 link->resource[0]->start = 0; /* let CS decide */
851 if ((err=pcmcia_request_io(link, &link->io))) 850 if ((err = pcmcia_request_io(link)))
852 goto config_error; 851 goto config_error;
853 } 852 }
854 port_found: 853 port_found:
@@ -870,24 +869,21 @@ xirc2ps_config(struct pcmcia_device * link)
870 goto config_error; 869 goto config_error;
871 870
872 if (local->dingo) { 871 if (local->dingo) {
873 conf_reg_t reg;
874 win_req_t req; 872 win_req_t req;
875 memreq_t mem;
876 873
877 /* Reset the modem's BAR to the correct value 874 /* Reset the modem's BAR to the correct value
878 * This is necessary because in the RequestConfiguration call, 875 * This is necessary because in the RequestConfiguration call,
879 * the base address of the ethernet port (BasePort1) is written 876 * the base address of the ethernet port (BasePort1) is written
880 * to the BAR registers of the modem. 877 * to the BAR registers of the modem.
881 */ 878 */
882 reg.Action = CS_WRITE; 879 err = pcmcia_write_config_byte(link, CISREG_IOBASE_0, (u8)
883 reg.Offset = CISREG_IOBASE_0; 880 link->resource[1]->start & 0xff);
884 reg.Value = link->io.BasePort2 & 0xff; 881 if (err)
885 if ((err = pcmcia_access_configuration_register(link, &reg)))
886 goto config_error; 882 goto config_error;
887 reg.Action = CS_WRITE; 883
888 reg.Offset = CISREG_IOBASE_1; 884 err = pcmcia_write_config_byte(link, CISREG_IOBASE_1,
889 reg.Value = (link->io.BasePort2 >> 8) & 0xff; 885 (link->resource[1]->start >> 8) & 0xff);
890 if ((err = pcmcia_access_configuration_register(link, &reg))) 886 if (err)
891 goto config_error; 887 goto config_error;
892 888
893 /* There is no config entry for the Ethernet part which 889 /* There is no config entry for the Ethernet part which
@@ -901,16 +897,14 @@ xirc2ps_config(struct pcmcia_device * link)
901 goto config_error; 897 goto config_error;
902 898
903 local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800; 899 local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800;
904 mem.CardOffset = 0x0; 900 if ((err = pcmcia_map_mem_page(link, link->win, 0)))
905 mem.Page = 0;
906 if ((err = pcmcia_map_mem_page(link, link->win, &mem)))
907 goto config_error; 901 goto config_error;
908 902
909 /* Setup the CCRs; there are no infos in the CIS about the Ethernet 903 /* Setup the CCRs; there are no infos in the CIS about the Ethernet
910 * part. 904 * part.
911 */ 905 */
912 writeb(0x47, local->dingo_ccr + CISREG_COR); 906 writeb(0x47, local->dingo_ccr + CISREG_COR);
913 ioaddr = link->io.BasePort1; 907 ioaddr = link->resource[0]->start;
914 writeb(ioaddr & 0xff , local->dingo_ccr + CISREG_IOBASE_0); 908 writeb(ioaddr & 0xff , local->dingo_ccr + CISREG_IOBASE_0);
915 writeb((ioaddr >> 8)&0xff , local->dingo_ccr + CISREG_IOBASE_1); 909 writeb((ioaddr >> 8)&0xff , local->dingo_ccr + CISREG_IOBASE_1);
916 910
@@ -957,7 +951,7 @@ xirc2ps_config(struct pcmcia_device * link)
957 951
958 /* we can now register the device with the net subsystem */ 952 /* we can now register the device with the net subsystem */
959 dev->irq = link->irq; 953 dev->irq = link->irq;
960 dev->base_addr = link->io.BasePort1; 954 dev->base_addr = link->resource[0]->start;
961 955
962 if (local->dingo) 956 if (local->dingo)
963 do_reset(dev, 1); /* a kludge to make the cem56 work */ 957 do_reset(dev, 1); /* a kludge to make the cem56 work */
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 6c2e8fa0ca31..af50a530daee 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -108,9 +108,9 @@ static void ppp_async_process(unsigned long arg);
108static void async_lcp_peek(struct asyncppp *ap, unsigned char *data, 108static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,
109 int len, int inbound); 109 int len, int inbound);
110 110
111static struct ppp_channel_ops async_ops = { 111static const struct ppp_channel_ops async_ops = {
112 ppp_async_send, 112 .start_xmit = ppp_async_send,
113 ppp_async_ioctl 113 .ioctl = ppp_async_ioctl,
114}; 114};
115 115
116/* 116/*
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index 52938da1e542..4c95ec3fb8d4 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -97,9 +97,9 @@ static void ppp_sync_flush_output(struct syncppp *ap);
97static void ppp_sync_input(struct syncppp *ap, const unsigned char *buf, 97static void ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
98 char *flags, int count); 98 char *flags, int count);
99 99
100static struct ppp_channel_ops sync_ops = { 100static const struct ppp_channel_ops sync_ops = {
101 ppp_sync_send, 101 .start_xmit = ppp_sync_send,
102 ppp_sync_ioctl 102 .ioctl = ppp_sync_ioctl,
103}; 103};
104 104
105/* 105/*
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 344ef330e123..c07de359dc07 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -92,7 +92,7 @@
92static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb); 92static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb);
93 93
94static const struct proto_ops pppoe_ops; 94static const struct proto_ops pppoe_ops;
95static struct ppp_channel_ops pppoe_chan_ops; 95static const struct ppp_channel_ops pppoe_chan_ops;
96 96
97/* per-net private data for this module */ 97/* per-net private data for this module */
98static int pppoe_net_id __read_mostly; 98static int pppoe_net_id __read_mostly;
@@ -963,7 +963,7 @@ static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb)
963 return __pppoe_xmit(sk, skb); 963 return __pppoe_xmit(sk, skb);
964} 964}
965 965
966static struct ppp_channel_ops pppoe_chan_ops = { 966static const struct ppp_channel_ops pppoe_chan_ops = {
967 .start_xmit = pppoe_xmit, 967 .start_xmit = pppoe_xmit,
968}; 968};
969 969
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 35540411990d..078bbf4e6f19 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -3219,11 +3219,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3219 3219
3220 device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); 3220 device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL);
3221 3221
3222 if (pci_dev_run_wake(pdev)) { 3222 if (pci_dev_run_wake(pdev))
3223 pm_runtime_set_active(&pdev->dev); 3223 pm_runtime_put_noidle(&pdev->dev);
3224 pm_runtime_enable(&pdev->dev);
3225 }
3226 pm_runtime_idle(&pdev->dev);
3227 3224
3228out: 3225out:
3229 return rc; 3226 return rc;
@@ -3246,17 +3243,12 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
3246 struct net_device *dev = pci_get_drvdata(pdev); 3243 struct net_device *dev = pci_get_drvdata(pdev);
3247 struct rtl8169_private *tp = netdev_priv(dev); 3244 struct rtl8169_private *tp = netdev_priv(dev);
3248 3245
3249 pm_runtime_get_sync(&pdev->dev);
3250
3251 flush_scheduled_work(); 3246 flush_scheduled_work();
3252 3247
3253 unregister_netdev(dev); 3248 unregister_netdev(dev);
3254 3249
3255 if (pci_dev_run_wake(pdev)) { 3250 if (pci_dev_run_wake(pdev))
3256 pm_runtime_disable(&pdev->dev); 3251 pm_runtime_get_noresume(&pdev->dev);
3257 pm_runtime_set_suspended(&pdev->dev);
3258 }
3259 pm_runtime_put_noidle(&pdev->dev);
3260 3252
3261 /* restore original MAC address */ 3253 /* restore original MAC address */
3262 rtl_rar_set(tp, dev->perm_addr); 3254 rtl_rar_set(tp, dev->perm_addr);
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 8d2772cc42f2..ee747919a766 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -83,43 +83,6 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg)
83 } 83 }
84} 84}
85 85
86#elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6)
87
88/* We can only do 16-bit reads and writes in the static memory space. */
89#define SMC_CAN_USE_8BIT 0
90#define SMC_CAN_USE_16BIT 1
91#define SMC_CAN_USE_32BIT 0
92#define SMC_NOWAIT 1
93
94#define SMC_IO_SHIFT 0
95
96#define SMC_inw(a, r) in_be16((volatile u16 *)((a) + (r)))
97#define SMC_outw(v, a, r) out_be16((volatile u16 *)((a) + (r)), v)
98#define SMC_insw(a, r, p, l) \
99 do { \
100 unsigned long __port = (a) + (r); \
101 u16 *__p = (u16 *)(p); \
102 int __l = (l); \
103 insw(__port, __p, __l); \
104 while (__l > 0) { \
105 *__p = swab16(*__p); \
106 __p++; \
107 __l--; \
108 } \
109 } while (0)
110#define SMC_outsw(a, r, p, l) \
111 do { \
112 unsigned long __port = (a) + (r); \
113 u16 *__p = (u16 *)(p); \
114 int __l = (l); \
115 while (__l > 0) { \
116 /* Believe it or not, the swab isn't needed. */ \
117 outw( /* swab16 */ (*__p++), __port); \
118 __l--; \
119 } \
120 } while (0)
121#define SMC_IRQ_FLAGS (0)
122
123#elif defined(CONFIG_SA1100_PLEB) 86#elif defined(CONFIG_SA1100_PLEB)
124/* We can only do 16-bit reads and writes in the static memory space. */ 87/* We can only do 16-bit reads and writes in the static memory space. */
125#define SMC_CAN_USE_8BIT 1 88#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 367e96f317d4..09c071bd6ad4 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -1201,7 +1201,7 @@ static int __devinit bigmac_ether_init(struct of_device *op,
1201 dev->watchdog_timeo = 5*HZ; 1201 dev->watchdog_timeo = 5*HZ;
1202 1202
1203 /* Finish net device registration. */ 1203 /* Finish net device registration. */
1204 dev->irq = bp->bigmac_op->irqs[0]; 1204 dev->irq = bp->bigmac_op->archdata.irqs[0];
1205 dev->dma = 0; 1205 dev->dma = 0;
1206 1206
1207 if (register_netdev(dev)) { 1207 if (register_netdev(dev)) {
@@ -1301,12 +1301,12 @@ static struct of_platform_driver bigmac_sbus_driver = {
1301 1301
1302static int __init bigmac_init(void) 1302static int __init bigmac_init(void)
1303{ 1303{
1304 return of_register_driver(&bigmac_sbus_driver, &of_bus_type); 1304 return of_register_platform_driver(&bigmac_sbus_driver);
1305} 1305}
1306 1306
1307static void __exit bigmac_exit(void) 1307static void __exit bigmac_exit(void)
1308{ 1308{
1309 of_unregister_driver(&bigmac_sbus_driver); 1309 of_unregister_platform_driver(&bigmac_sbus_driver);
1310} 1310}
1311 1311
1312module_init(bigmac_init); 1312module_init(bigmac_init);
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index 3d9650b8d38f..eec443f64079 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2561,7 +2561,7 @@ static int __init quattro_sbus_register_irqs(void)
2561 if (skip) 2561 if (skip)
2562 continue; 2562 continue;
2563 2563
2564 err = request_irq(op->irqs[0], 2564 err = request_irq(op->archdata.irqs[0],
2565 quattro_sbus_interrupt, 2565 quattro_sbus_interrupt,
2566 IRQF_SHARED, "Quattro", 2566 IRQF_SHARED, "Quattro",
2567 qp); 2567 qp);
@@ -2590,7 +2590,7 @@ static void quattro_sbus_free_irqs(void)
2590 if (skip) 2590 if (skip)
2591 continue; 2591 continue;
2592 2592
2593 free_irq(op->irqs[0], qp); 2593 free_irq(op->archdata.irqs[0], qp);
2594 } 2594 }
2595} 2595}
2596#endif /* CONFIG_SBUS */ 2596#endif /* CONFIG_SBUS */
@@ -2790,7 +2790,7 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2790 /* Happy Meal can do it all... */ 2790 /* Happy Meal can do it all... */
2791 dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; 2791 dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
2792 2792
2793 dev->irq = op->irqs[0]; 2793 dev->irq = op->archdata.irqs[0];
2794 2794
2795#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) 2795#if defined(CONFIG_SBUS) && defined(CONFIG_PCI)
2796 /* Hook up SBUS register/descriptor accessors. */ 2796 /* Hook up SBUS register/descriptor accessors. */
@@ -3304,7 +3304,7 @@ static int __init happy_meal_sbus_init(void)
3304{ 3304{
3305 int err; 3305 int err;
3306 3306
3307 err = of_register_driver(&hme_sbus_driver, &of_bus_type); 3307 err = of_register_platform_driver(&hme_sbus_driver);
3308 if (!err) 3308 if (!err)
3309 err = quattro_sbus_register_irqs(); 3309 err = quattro_sbus_register_irqs();
3310 3310
@@ -3313,7 +3313,7 @@ static int __init happy_meal_sbus_init(void)
3313 3313
3314static void happy_meal_sbus_exit(void) 3314static void happy_meal_sbus_exit(void)
3315{ 3315{
3316 of_unregister_driver(&hme_sbus_driver); 3316 of_unregister_platform_driver(&hme_sbus_driver);
3317 quattro_sbus_free_irqs(); 3317 quattro_sbus_free_irqs();
3318 3318
3319 while (qfe_sbus_list) { 3319 while (qfe_sbus_list) {
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 7d9c33dd9d1a..ee364fa75634 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -1474,7 +1474,7 @@ no_link_test:
1474 dev->ethtool_ops = &sparc_lance_ethtool_ops; 1474 dev->ethtool_ops = &sparc_lance_ethtool_ops;
1475 dev->netdev_ops = &sparc_lance_ops; 1475 dev->netdev_ops = &sparc_lance_ops;
1476 1476
1477 dev->irq = op->irqs[0]; 1477 dev->irq = op->archdata.irqs[0];
1478 1478
1479 /* We cannot sleep if the chip is busy during a 1479 /* We cannot sleep if the chip is busy during a
1480 * multicast list update event, because such events 1480 * multicast list update event, because such events
@@ -1558,12 +1558,12 @@ static struct of_platform_driver sunlance_sbus_driver = {
1558/* Find all the lance cards on the system and initialize them */ 1558/* Find all the lance cards on the system and initialize them */
1559static int __init sparc_lance_init(void) 1559static int __init sparc_lance_init(void)
1560{ 1560{
1561 return of_register_driver(&sunlance_sbus_driver, &of_bus_type); 1561 return of_register_platform_driver(&sunlance_sbus_driver);
1562} 1562}
1563 1563
1564static void __exit sparc_lance_exit(void) 1564static void __exit sparc_lance_exit(void)
1565{ 1565{
1566 of_unregister_driver(&sunlance_sbus_driver); 1566 of_unregister_platform_driver(&sunlance_sbus_driver);
1567} 1567}
1568 1568
1569module_init(sparc_lance_init); 1569module_init(sparc_lance_init);
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index 72b579c8d812..5f84a5dadedd 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -803,7 +803,7 @@ static struct sunqec * __devinit get_qec(struct of_device *child)
803 803
804 qec_init_once(qecp, op); 804 qec_init_once(qecp, op);
805 805
806 if (request_irq(op->irqs[0], qec_interrupt, 806 if (request_irq(op->archdata.irqs[0], qec_interrupt,
807 IRQF_SHARED, "qec", (void *) qecp)) { 807 IRQF_SHARED, "qec", (void *) qecp)) {
808 printk(KERN_ERR "qec: Can't register irq.\n"); 808 printk(KERN_ERR "qec: Can't register irq.\n");
809 goto fail; 809 goto fail;
@@ -901,7 +901,7 @@ static int __devinit qec_ether_init(struct of_device *op)
901 SET_NETDEV_DEV(dev, &op->dev); 901 SET_NETDEV_DEV(dev, &op->dev);
902 902
903 dev->watchdog_timeo = 5*HZ; 903 dev->watchdog_timeo = 5*HZ;
904 dev->irq = op->irqs[0]; 904 dev->irq = op->archdata.irqs[0];
905 dev->dma = 0; 905 dev->dma = 0;
906 dev->ethtool_ops = &qe_ethtool_ops; 906 dev->ethtool_ops = &qe_ethtool_ops;
907 dev->netdev_ops = &qec_ops; 907 dev->netdev_ops = &qec_ops;
@@ -988,18 +988,18 @@ static struct of_platform_driver qec_sbus_driver = {
988 988
989static int __init qec_init(void) 989static int __init qec_init(void)
990{ 990{
991 return of_register_driver(&qec_sbus_driver, &of_bus_type); 991 return of_register_platform_driver(&qec_sbus_driver);
992} 992}
993 993
994static void __exit qec_exit(void) 994static void __exit qec_exit(void)
995{ 995{
996 of_unregister_driver(&qec_sbus_driver); 996 of_unregister_platform_driver(&qec_sbus_driver);
997 997
998 while (root_qec_dev) { 998 while (root_qec_dev) {
999 struct sunqec *next = root_qec_dev->next_module; 999 struct sunqec *next = root_qec_dev->next_module;
1000 struct of_device *op = root_qec_dev->op; 1000 struct of_device *op = root_qec_dev->op;
1001 1001
1002 free_irq(op->irqs[0], (void *) root_qec_dev); 1002 free_irq(op->archdata.irqs[0], (void *) root_qec_dev);
1003 of_iounmap(&op->resource[0], root_qec_dev->gregs, 1003 of_iounmap(&op->resource[0], root_qec_dev->gregs,
1004 GLOB_REG_SIZE); 1004 GLOB_REG_SIZE);
1005 kfree(root_qec_dev); 1005 kfree(root_qec_dev);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 3b03794ac3f5..7f62e2dea28f 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1457,7 +1457,6 @@ int usbnet_resume (struct usb_interface *intf)
1457 spin_lock_irq(&dev->txq.lock); 1457 spin_lock_irq(&dev->txq.lock);
1458 while ((res = usb_get_from_anchor(&dev->deferred))) { 1458 while ((res = usb_get_from_anchor(&dev->deferred))) {
1459 1459
1460 printk(KERN_INFO"%s has delayed data\n", __func__);
1461 skb = (struct sk_buff *)res->context; 1460 skb = (struct sk_buff *)res->context;
1462 retval = usb_submit_urb(res, GFP_ATOMIC); 1461 retval = usb_submit_urb(res, GFP_ATOMIC);
1463 if (retval < 0) { 1462 if (retval < 0) {
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 42dffd3e5795..fd69095ef6e3 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -2763,12 +2763,12 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
2763 2763
2764 vptr->dev = dev; 2764 vptr->dev = dev;
2765 2765
2766 dev->irq = pdev->irq;
2767
2768 ret = pci_enable_device(pdev); 2766 ret = pci_enable_device(pdev);
2769 if (ret < 0) 2767 if (ret < 0)
2770 goto err_free_dev; 2768 goto err_free_dev;
2771 2769
2770 dev->irq = pdev->irq;
2771
2772 ret = velocity_get_pci_info(vptr, pdev); 2772 ret = velocity_get_pci_info(vptr, pdev);
2773 if (ret < 0) { 2773 if (ret < 0) {
2774 /* error message already printed */ 2774 /* error message already printed */
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index bb6b67f6b0cc..4598e9d2608f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -705,6 +705,19 @@ static int virtnet_close(struct net_device *dev)
705 return 0; 705 return 0;
706} 706}
707 707
708static void virtnet_get_drvinfo(struct net_device *dev,
709 struct ethtool_drvinfo *drvinfo)
710{
711 struct virtnet_info *vi = netdev_priv(dev);
712 struct virtio_device *vdev = vi->vdev;
713
714 strncpy(drvinfo->driver, KBUILD_MODNAME, ARRAY_SIZE(drvinfo->driver));
715 strncpy(drvinfo->version, "N/A", ARRAY_SIZE(drvinfo->version));
716 strncpy(drvinfo->fw_version, "N/A", ARRAY_SIZE(drvinfo->fw_version));
717 strncpy(drvinfo->bus_info, dev_name(&vdev->dev),
718 ARRAY_SIZE(drvinfo->bus_info));
719}
720
708static int virtnet_set_tx_csum(struct net_device *dev, u32 data) 721static int virtnet_set_tx_csum(struct net_device *dev, u32 data)
709{ 722{
710 struct virtnet_info *vi = netdev_priv(dev); 723 struct virtnet_info *vi = netdev_priv(dev);
@@ -817,6 +830,7 @@ static void virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
817} 830}
818 831
819static const struct ethtool_ops virtnet_ethtool_ops = { 832static const struct ethtool_ops virtnet_ethtool_ops = {
833 .get_drvinfo = virtnet_get_drvinfo,
820 .set_tx_csum = virtnet_set_tx_csum, 834 .set_tx_csum = virtnet_set_tx_csum,
821 .set_sg = ethtool_op_set_sg, 835 .set_sg = ethtool_op_set_sg,
822 .set_tso = ethtool_op_set_tso, 836 .set_tso = ethtool_op_set_tso,
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 33bdc6a84e81..9a121a5b787c 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -32,7 +32,6 @@
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/netdevice.h> 33#include <linux/netdevice.h>
34 34
35#include <pcmcia/cs_types.h>
36#include <pcmcia/cs.h> 35#include <pcmcia/cs.h>
37#include <pcmcia/cistpl.h> 36#include <pcmcia/cistpl.h>
38#include <pcmcia/cisreg.h> 37#include <pcmcia/cisreg.h>
@@ -155,8 +154,6 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev,
155 unsigned int vcc, 154 unsigned int vcc,
156 void *priv_data) 155 void *priv_data)
157{ 156{
158 win_req_t *req = priv_data;
159
160 if (cfg->index == 0) 157 if (cfg->index == 0)
161 return -ENODEV; 158 return -ENODEV;
162 159
@@ -176,52 +173,25 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev,
176 p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 173 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
177 174
178 /* IO window settings */ 175 /* IO window settings */
179 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 176 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
180 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 177 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
181 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 178 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
182 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 179 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
183 if (!(io->flags & CISTPL_IO_8BIT)) 180 p_dev->resource[0]->flags |=
184 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 181 pcmcia_io_cfg_data_width(io->flags);
185 if (!(io->flags & CISTPL_IO_16BIT)) 182 p_dev->resource[0]->start = io->win[0].base;
186 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 183 p_dev->resource[0]->end = io->win[0].len;
187 p_dev->io.BasePort1 = io->win[0].base;
188 p_dev->io.NumPorts1 = io->win[0].len;
189 if (io->nwin > 1) { 184 if (io->nwin > 1) {
190 p_dev->io.Attributes2 = p_dev->io.Attributes1; 185 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
191 p_dev->io.BasePort2 = io->win[1].base; 186 p_dev->resource[1]->start = io->win[1].base;
192 p_dev->io.NumPorts2 = io->win[1].len; 187 p_dev->resource[1]->end = io->win[1].len;
193 } 188 }
194 } 189 }
195 190
196 /* This reserves IO space but doesn't actually enable it */ 191 /* This reserves IO space but doesn't actually enable it */
197 if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 192 if (pcmcia_request_io(p_dev) != 0)
198 return -ENODEV; 193 return -ENODEV;
199 194
200 /*
201 Now set up a common memory window, if needed. There is room
202 in the struct pcmcia_device structure for one memory window handle,
203 but if the base addresses need to be saved, or if multiple
204 windows are needed, the info should go in the private data
205 structure for this device.
206
207 Note that the memory window base is a physical address, and
208 needs to be mapped to virtual space with ioremap() before it
209 is used.
210 */
211 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
212 cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
213 memreq_t map;
214 req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
215 req->Base = mem->win[0].host_addr;
216 req->Size = mem->win[0].len;
217 req->AccessSpeed = 0;
218 if (pcmcia_request_window(p_dev, req, &p_dev->win) != 0)
219 return -ENODEV;
220 map.Page = 0;
221 map.CardOffset = mem->win[0].card_addr;
222 if (pcmcia_map_mem_page(p_dev, p_dev->win, &map) != 0)
223 return -ENODEV;
224 }
225 /* If we got this far, we're cool! */ 195 /* If we got this far, we're cool! */
226 return 0; 196 return 0;
227} 197}
@@ -230,17 +200,12 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev,
230static int airo_config(struct pcmcia_device *link) 200static int airo_config(struct pcmcia_device *link)
231{ 201{
232 local_info_t *dev; 202 local_info_t *dev;
233 win_req_t *req;
234 int ret; 203 int ret;
235 204
236 dev = link->priv; 205 dev = link->priv;
237 206
238 dev_dbg(&link->dev, "airo_config\n"); 207 dev_dbg(&link->dev, "airo_config\n");
239 208
240 req = kzalloc(sizeof(win_req_t), GFP_KERNEL);
241 if (!req)
242 return -ENOMEM;
243
244 /* 209 /*
245 * In this loop, we scan the CIS for configuration table 210 * In this loop, we scan the CIS for configuration table
246 * entries, each of which describes a valid card 211 * entries, each of which describes a valid card
@@ -255,7 +220,7 @@ static int airo_config(struct pcmcia_device *link)
255 * and most client drivers will only use the CIS to fill in 220 * and most client drivers will only use the CIS to fill in
256 * implementation-defined details. 221 * implementation-defined details.
257 */ 222 */
258 ret = pcmcia_loop_config(link, airo_cs_config_check, req); 223 ret = pcmcia_loop_config(link, airo_cs_config_check, NULL);
259 if (ret) 224 if (ret)
260 goto failed; 225 goto failed;
261 226
@@ -272,7 +237,7 @@ static int airo_config(struct pcmcia_device *link)
272 goto failed; 237 goto failed;
273 ((local_info_t *)link->priv)->eth_dev = 238 ((local_info_t *)link->priv)->eth_dev =
274 init_airo_card(link->irq, 239 init_airo_card(link->irq,
275 link->io.BasePort1, 1, &link->dev); 240 link->resource[0]->start, 1, &link->dev);
276 if (!((local_info_t *)link->priv)->eth_dev) 241 if (!((local_info_t *)link->priv)->eth_dev)
277 goto failed; 242 goto failed;
278 243
@@ -282,22 +247,15 @@ static int airo_config(struct pcmcia_device *link)
282 if (link->conf.Vpp) 247 if (link->conf.Vpp)
283 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10); 248 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
284 printk(", irq %d", link->irq); 249 printk(", irq %d", link->irq);
285 if (link->io.NumPorts1) 250 if (link->resource[0])
286 printk(", io 0x%04x-0x%04x", link->io.BasePort1, 251 printk(" & %pR", link->resource[0]);
287 link->io.BasePort1+link->io.NumPorts1-1); 252 if (link->resource[1])
288 if (link->io.NumPorts2) 253 printk(" & %pR", link->resource[1]);
289 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
290 link->io.BasePort2+link->io.NumPorts2-1);
291 if (link->win)
292 printk(", mem 0x%06lx-0x%06lx", req->Base,
293 req->Base+req->Size-1);
294 printk("\n"); 254 printk("\n");
295 kfree(req);
296 return 0; 255 return 0;
297 256
298 failed: 257 failed:
299 airo_release(link); 258 airo_release(link);
300 kfree(req);
301 return -ENODEV; 259 return -ENODEV;
302} /* airo_config */ 260} /* airo_config */
303 261
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
index dabafb874c36..fe7418aefc4a 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
@@ -63,6 +63,7 @@ static bool ar9002_hw_per_calibration(struct ath_hw *ah,
63 u8 rxchainmask, 63 u8 rxchainmask,
64 struct ath9k_cal_list *currCal) 64 struct ath9k_cal_list *currCal)
65{ 65{
66 struct ath9k_hw_cal_data *caldata = ah->caldata;
66 bool iscaldone = false; 67 bool iscaldone = false;
67 68
68 if (currCal->calState == CAL_RUNNING) { 69 if (currCal->calState == CAL_RUNNING) {
@@ -81,14 +82,14 @@ static bool ar9002_hw_per_calibration(struct ath_hw *ah,
81 } 82 }
82 83
83 currCal->calData->calPostProc(ah, numChains); 84 currCal->calData->calPostProc(ah, numChains);
84 ichan->CalValid |= currCal->calData->calType; 85 caldata->CalValid |= currCal->calData->calType;
85 currCal->calState = CAL_DONE; 86 currCal->calState = CAL_DONE;
86 iscaldone = true; 87 iscaldone = true;
87 } else { 88 } else {
88 ar9002_hw_setup_calibration(ah, currCal); 89 ar9002_hw_setup_calibration(ah, currCal);
89 } 90 }
90 } 91 }
91 } else if (!(ichan->CalValid & currCal->calData->calType)) { 92 } else if (!(caldata->CalValid & currCal->calData->calType)) {
92 ath9k_hw_reset_calibration(ah, currCal); 93 ath9k_hw_reset_calibration(ah, currCal);
93 } 94 }
94 95
@@ -686,8 +687,13 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
686{ 687{
687 bool iscaldone = true; 688 bool iscaldone = true;
688 struct ath9k_cal_list *currCal = ah->cal_list_curr; 689 struct ath9k_cal_list *currCal = ah->cal_list_curr;
690 bool nfcal, nfcal_pending = false;
689 691
690 if (currCal && 692 nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF);
693 if (ah->caldata)
694 nfcal_pending = ah->caldata->nfcal_pending;
695
696 if (currCal && !nfcal &&
691 (currCal->calState == CAL_RUNNING || 697 (currCal->calState == CAL_RUNNING ||
692 currCal->calState == CAL_WAITING)) { 698 currCal->calState == CAL_WAITING)) {
693 iscaldone = ar9002_hw_per_calibration(ah, chan, 699 iscaldone = ar9002_hw_per_calibration(ah, chan,
@@ -703,7 +709,7 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
703 } 709 }
704 710
705 /* Do NF cal only at longer intervals */ 711 /* Do NF cal only at longer intervals */
706 if (longcal) { 712 if (longcal || nfcal_pending) {
707 /* Do periodic PAOffset Cal */ 713 /* Do periodic PAOffset Cal */
708 ar9002_hw_pa_cal(ah, false); 714 ar9002_hw_pa_cal(ah, false);
709 ar9002_hw_olc_temp_compensation(ah); 715 ar9002_hw_olc_temp_compensation(ah);
@@ -712,16 +718,18 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
712 * Get the value from the previous NF cal and update 718 * Get the value from the previous NF cal and update
713 * history buffer. 719 * history buffer.
714 */ 720 */
715 ath9k_hw_getnf(ah, chan); 721 if (ath9k_hw_getnf(ah, chan)) {
716 722 /*
717 /* 723 * Load the NF from history buffer of the current
718 * Load the NF from history buffer of the current channel. 724 * channel.
719 * NF is slow time-variant, so it is OK to use a historical 725 * NF is slow time-variant, so it is OK to use a
720 * value. 726 * historical value.
721 */ 727 */
722 ath9k_hw_loadnf(ah, ah->curchan); 728 ath9k_hw_loadnf(ah, ah->curchan);
729 }
723 730
724 ath9k_hw_start_nfcal(ah); 731 if (longcal)
732 ath9k_hw_start_nfcal(ah, false);
725 } 733 }
726 734
727 return iscaldone; 735 return iscaldone;
@@ -869,8 +877,10 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
869 ar9002_hw_pa_cal(ah, true); 877 ar9002_hw_pa_cal(ah, true);
870 878
871 /* Do NF Calibration after DC offset and other calibrations */ 879 /* Do NF Calibration after DC offset and other calibrations */
872 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 880 ath9k_hw_start_nfcal(ah, true);
873 REG_READ(ah, AR_PHY_AGC_CONTROL) | AR_PHY_AGC_CONTROL_NF); 881
882 if (ah->caldata)
883 ah->caldata->nfcal_pending = true;
874 884
875 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; 885 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
876 886
@@ -901,7 +911,8 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
901 ath9k_hw_reset_calibration(ah, ah->cal_list_curr); 911 ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
902 } 912 }
903 913
904 chan->CalValid = 0; 914 if (ah->caldata)
915 ah->caldata->CalValid = 0;
905 916
906 return true; 917 return true;
907} 918}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 5a0650399136..4674ea8c9c99 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -68,6 +68,7 @@ static bool ar9003_hw_per_calibration(struct ath_hw *ah,
68 u8 rxchainmask, 68 u8 rxchainmask,
69 struct ath9k_cal_list *currCal) 69 struct ath9k_cal_list *currCal)
70{ 70{
71 struct ath9k_hw_cal_data *caldata = ah->caldata;
71 /* Cal is assumed not done until explicitly set below */ 72 /* Cal is assumed not done until explicitly set below */
72 bool iscaldone = false; 73 bool iscaldone = false;
73 74
@@ -95,7 +96,7 @@ static bool ar9003_hw_per_calibration(struct ath_hw *ah,
95 currCal->calData->calPostProc(ah, numChains); 96 currCal->calData->calPostProc(ah, numChains);
96 97
97 /* Calibration has finished. */ 98 /* Calibration has finished. */
98 ichan->CalValid |= currCal->calData->calType; 99 caldata->CalValid |= currCal->calData->calType;
99 currCal->calState = CAL_DONE; 100 currCal->calState = CAL_DONE;
100 iscaldone = true; 101 iscaldone = true;
101 } else { 102 } else {
@@ -106,7 +107,7 @@ static bool ar9003_hw_per_calibration(struct ath_hw *ah,
106 ar9003_hw_setup_calibration(ah, currCal); 107 ar9003_hw_setup_calibration(ah, currCal);
107 } 108 }
108 } 109 }
109 } else if (!(ichan->CalValid & currCal->calData->calType)) { 110 } else if (!(caldata->CalValid & currCal->calData->calType)) {
110 /* If current cal is marked invalid in channel, kick it off */ 111 /* If current cal is marked invalid in channel, kick it off */
111 ath9k_hw_reset_calibration(ah, currCal); 112 ath9k_hw_reset_calibration(ah, currCal);
112 } 113 }
@@ -149,6 +150,12 @@ static bool ar9003_hw_calibrate(struct ath_hw *ah,
149 /* Do NF cal only at longer intervals */ 150 /* Do NF cal only at longer intervals */
150 if (longcal) { 151 if (longcal) {
151 /* 152 /*
153 * Get the value from the previous NF cal and update
154 * history buffer.
155 */
156 ath9k_hw_getnf(ah, chan);
157
158 /*
152 * Load the NF from history buffer of the current channel. 159 * Load the NF from history buffer of the current channel.
153 * NF is slow time-variant, so it is OK to use a historical 160 * NF is slow time-variant, so it is OK to use a historical
154 * value. 161 * value.
@@ -156,7 +163,7 @@ static bool ar9003_hw_calibrate(struct ath_hw *ah,
156 ath9k_hw_loadnf(ah, ah->curchan); 163 ath9k_hw_loadnf(ah, ah->curchan);
157 164
158 /* start NF calibration, without updating BB NF register */ 165 /* start NF calibration, without updating BB NF register */
159 ath9k_hw_start_nfcal(ah); 166 ath9k_hw_start_nfcal(ah, false);
160 } 167 }
161 168
162 return iscaldone; 169 return iscaldone;
@@ -762,6 +769,8 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
762 /* Revert chainmasks to their original values before NF cal */ 769 /* Revert chainmasks to their original values before NF cal */
763 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask); 770 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
764 771
772 ath9k_hw_start_nfcal(ah, true);
773
765 /* Initialize list pointers */ 774 /* Initialize list pointers */
766 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; 775 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
767 776
@@ -785,7 +794,8 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
785 if (ah->cal_list_curr) 794 if (ah->cal_list_curr)
786 ath9k_hw_reset_calibration(ah, ah->cal_list_curr); 795 ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
787 796
788 chan->CalValid = 0; 797 if (ah->caldata)
798 ah->caldata->CalValid = 0;
789 799
790 return true; 800 return true;
791} 801}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index ace8d2678b18..b883b174385b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -41,6 +41,20 @@
41#define LE16(x) __constant_cpu_to_le16(x) 41#define LE16(x) __constant_cpu_to_le16(x)
42#define LE32(x) __constant_cpu_to_le32(x) 42#define LE32(x) __constant_cpu_to_le32(x)
43 43
44/* Local defines to distinguish between extension and control CTL's */
45#define EXT_ADDITIVE (0x8000)
46#define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
47#define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
48#define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
49#define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
50#define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 /* 10*log10(3)*2 */
51#define PWRINCR_3_TO_1_CHAIN 9 /* 10*log(3)*2 */
52#define PWRINCR_3_TO_2_CHAIN 3 /* floor(10*log(3/2)*2) */
53#define PWRINCR_2_TO_1_CHAIN 6 /* 10*log(2)*2 */
54
55#define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */
56#define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */
57
44static const struct ar9300_eeprom ar9300_default = { 58static const struct ar9300_eeprom ar9300_default = {
45 .eepromVersion = 2, 59 .eepromVersion = 2,
46 .templateVersion = 2, 60 .templateVersion = 2,
@@ -609,6 +623,14 @@ static const struct ar9300_eeprom ar9300_default = {
609 } 623 }
610}; 624};
611 625
626static u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz)
627{
628 if (fbin == AR9300_BCHAN_UNUSED)
629 return fbin;
630
631 return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
632}
633
612static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah) 634static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah)
613{ 635{
614 return 0; 636 return 0;
@@ -1417,9 +1439,9 @@ static int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray)
1417#undef POW_SM 1439#undef POW_SM
1418} 1440}
1419 1441
1420static void ar9003_hw_set_target_power_eeprom(struct ath_hw *ah, u16 freq) 1442static void ar9003_hw_set_target_power_eeprom(struct ath_hw *ah, u16 freq,
1443 u8 *targetPowerValT2)
1421{ 1444{
1422 u8 targetPowerValT2[ar9300RateSize];
1423 /* XXX: hard code for now, need to get from eeprom struct */ 1445 /* XXX: hard code for now, need to get from eeprom struct */
1424 u8 ht40PowerIncForPdadc = 0; 1446 u8 ht40PowerIncForPdadc = 0;
1425 bool is2GHz = false; 1447 bool is2GHz = false;
@@ -1553,9 +1575,6 @@ static void ar9003_hw_set_target_power_eeprom(struct ath_hw *ah, u16 freq)
1553 "TPC[%02d] 0x%08x\n", i, targetPowerValT2[i]); 1575 "TPC[%02d] 0x%08x\n", i, targetPowerValT2[i]);
1554 i++; 1576 i++;
1555 } 1577 }
1556
1557 /* Write target power array to registers */
1558 ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
1559} 1578}
1560 1579
1561static int ar9003_hw_cal_pier_get(struct ath_hw *ah, 1580static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
@@ -1799,14 +1818,369 @@ static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
1799 return 0; 1818 return 0;
1800} 1819}
1801 1820
1821static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
1822 int idx,
1823 int edge,
1824 bool is2GHz)
1825{
1826 struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
1827 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
1828
1829 if (is2GHz)
1830 return ctl_2g[idx].ctlEdges[edge].tPower;
1831 else
1832 return ctl_5g[idx].ctlEdges[edge].tPower;
1833}
1834
1835static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
1836 int idx,
1837 unsigned int edge,
1838 u16 freq,
1839 bool is2GHz)
1840{
1841 struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
1842 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
1843
1844 u8 *ctl_freqbin = is2GHz ?
1845 &eep->ctl_freqbin_2G[idx][0] :
1846 &eep->ctl_freqbin_5G[idx][0];
1847
1848 if (is2GHz) {
1849 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
1850 ctl_2g[idx].ctlEdges[edge - 1].flag)
1851 return ctl_2g[idx].ctlEdges[edge - 1].tPower;
1852 } else {
1853 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
1854 ctl_5g[idx].ctlEdges[edge - 1].flag)
1855 return ctl_5g[idx].ctlEdges[edge - 1].tPower;
1856 }
1857
1858 return AR9300_MAX_RATE_POWER;
1859}
1860
1861/*
1862 * Find the maximum conformance test limit for the given channel and CTL info
1863 */
1864static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
1865 u16 freq, int idx, bool is2GHz)
1866{
1867 u16 twiceMaxEdgePower = AR9300_MAX_RATE_POWER;
1868 u8 *ctl_freqbin = is2GHz ?
1869 &eep->ctl_freqbin_2G[idx][0] :
1870 &eep->ctl_freqbin_5G[idx][0];
1871 u16 num_edges = is2GHz ?
1872 AR9300_NUM_BAND_EDGES_2G : AR9300_NUM_BAND_EDGES_5G;
1873 unsigned int edge;
1874
1875 /* Get the edge power */
1876 for (edge = 0;
1877 (edge < num_edges) && (ctl_freqbin[edge] != AR9300_BCHAN_UNUSED);
1878 edge++) {
1879 /*
1880 * If there's an exact channel match or an inband flag set
1881 * on the lower channel use the given rdEdgePower
1882 */
1883 if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) {
1884 twiceMaxEdgePower =
1885 ar9003_hw_get_direct_edge_power(eep, idx,
1886 edge, is2GHz);
1887 break;
1888 } else if ((edge > 0) &&
1889 (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge],
1890 is2GHz))) {
1891 twiceMaxEdgePower =
1892 ar9003_hw_get_indirect_edge_power(eep, idx,
1893 edge, freq,
1894 is2GHz);
1895 /*
1896 * Leave loop - no more affecting edges possible in
1897 * this monotonic increasing list
1898 */
1899 break;
1900 }
1901 }
1902 return twiceMaxEdgePower;
1903}
1904
1905static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
1906 struct ath9k_channel *chan,
1907 u8 *pPwrArray, u16 cfgCtl,
1908 u8 twiceAntennaReduction,
1909 u8 twiceMaxRegulatoryPower,
1910 u16 powerLimit)
1911{
1912 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1913 struct ath_common *common = ath9k_hw_common(ah);
1914 struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
1915 u16 twiceMaxEdgePower = AR9300_MAX_RATE_POWER;
1916 static const u16 tpScaleReductionTable[5] = {
1917 0, 3, 6, 9, AR9300_MAX_RATE_POWER
1918 };
1919 int i;
1920 int16_t twiceLargestAntenna;
1921 u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
1922 u16 ctlModesFor11a[] = {
1923 CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
1924 };
1925 u16 ctlModesFor11g[] = {
1926 CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT,
1927 CTL_11G_EXT, CTL_2GHT40
1928 };
1929 u16 numCtlModes, *pCtlMode, ctlMode, freq;
1930 struct chan_centers centers;
1931 u8 *ctlIndex;
1932 u8 ctlNum;
1933 u16 twiceMinEdgePower;
1934 bool is2ghz = IS_CHAN_2GHZ(chan);
1935
1936 ath9k_hw_get_channel_centers(ah, chan, &centers);
1937
1938 /* Compute TxPower reduction due to Antenna Gain */
1939 if (is2ghz)
1940 twiceLargestAntenna = pEepData->modalHeader2G.antennaGain;
1941 else
1942 twiceLargestAntenna = pEepData->modalHeader5G.antennaGain;
1943
1944 twiceLargestAntenna = (int16_t)min((twiceAntennaReduction) -
1945 twiceLargestAntenna, 0);
1946
1947 /*
1948 * scaledPower is the minimum of the user input power level
1949 * and the regulatory allowed power level
1950 */
1951 maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
1952
1953 if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
1954 maxRegAllowedPower -=
1955 (tpScaleReductionTable[(regulatory->tp_scale)] * 2);
1956 }
1957
1958 scaledPower = min(powerLimit, maxRegAllowedPower);
1959
1960 /*
1961 * Reduce scaled Power by number of chains active to get
1962 * to per chain tx power level
1963 */
1964 switch (ar5416_get_ntxchains(ah->txchainmask)) {
1965 case 1:
1966 break;
1967 case 2:
1968 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
1969 break;
1970 case 3:
1971 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
1972 break;
1973 }
1974
1975 scaledPower = max((u16)0, scaledPower);
1976
1977 /*
1978 * Get target powers from EEPROM - our baseline for TX Power
1979 */
1980 if (is2ghz) {
1981 /* Setup for CTL modes */
1982 /* CTL_11B, CTL_11G, CTL_2GHT20 */
1983 numCtlModes =
1984 ARRAY_SIZE(ctlModesFor11g) -
1985 SUB_NUM_CTL_MODES_AT_2G_40;
1986 pCtlMode = ctlModesFor11g;
1987 if (IS_CHAN_HT40(chan))
1988 /* All 2G CTL's */
1989 numCtlModes = ARRAY_SIZE(ctlModesFor11g);
1990 } else {
1991 /* Setup for CTL modes */
1992 /* CTL_11A, CTL_5GHT20 */
1993 numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
1994 SUB_NUM_CTL_MODES_AT_5G_40;
1995 pCtlMode = ctlModesFor11a;
1996 if (IS_CHAN_HT40(chan))
1997 /* All 5G CTL's */
1998 numCtlModes = ARRAY_SIZE(ctlModesFor11a);
1999 }
2000
2001 /*
2002 * For MIMO, need to apply regulatory caps individually across
2003 * dynamically running modes: CCK, OFDM, HT20, HT40
2004 *
2005 * The outer loop walks through each possible applicable runtime mode.
2006 * The inner loop walks through each ctlIndex entry in EEPROM.
2007 * The ctl value is encoded as [7:4] == test group, [3:0] == test mode.
2008 */
2009 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
2010 bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
2011 (pCtlMode[ctlMode] == CTL_2GHT40);
2012 if (isHt40CtlMode)
2013 freq = centers.synth_center;
2014 else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
2015 freq = centers.ext_center;
2016 else
2017 freq = centers.ctl_center;
2018
2019 ath_print(common, ATH_DBG_REGULATORY,
2020 "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, "
2021 "EXT_ADDITIVE %d\n",
2022 ctlMode, numCtlModes, isHt40CtlMode,
2023 (pCtlMode[ctlMode] & EXT_ADDITIVE));
2024
2025 /* walk through each CTL index stored in EEPROM */
2026 if (is2ghz) {
2027 ctlIndex = pEepData->ctlIndex_2G;
2028 ctlNum = AR9300_NUM_CTLS_2G;
2029 } else {
2030 ctlIndex = pEepData->ctlIndex_5G;
2031 ctlNum = AR9300_NUM_CTLS_5G;
2032 }
2033
2034 for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) {
2035 ath_print(common, ATH_DBG_REGULATORY,
2036 "LOOP-Ctlidx %d: cfgCtl 0x%2.2x "
2037 "pCtlMode 0x%2.2x ctlIndex 0x%2.2x "
2038 "chan %dn",
2039 i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i],
2040 chan->channel);
2041
2042 /*
2043 * compare test group from regulatory
2044 * channel list with test mode from pCtlMode
2045 * list
2046 */
2047 if ((((cfgCtl & ~CTL_MODE_M) |
2048 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
2049 ctlIndex[i]) ||
2050 (((cfgCtl & ~CTL_MODE_M) |
2051 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
2052 ((ctlIndex[i] & CTL_MODE_M) |
2053 SD_NO_CTL))) {
2054 twiceMinEdgePower =
2055 ar9003_hw_get_max_edge_power(pEepData,
2056 freq, i,
2057 is2ghz);
2058
2059 if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL)
2060 /*
2061 * Find the minimum of all CTL
2062 * edge powers that apply to
2063 * this channel
2064 */
2065 twiceMaxEdgePower =
2066 min(twiceMaxEdgePower,
2067 twiceMinEdgePower);
2068 else {
2069 /* specific */
2070 twiceMaxEdgePower =
2071 twiceMinEdgePower;
2072 break;
2073 }
2074 }
2075 }
2076
2077 minCtlPower = (u8)min(twiceMaxEdgePower, scaledPower);
2078
2079 ath_print(common, ATH_DBG_REGULATORY,
2080 "SEL-Min ctlMode %d pCtlMode %d 2xMaxEdge %d "
2081 "sP %d minCtlPwr %d\n",
2082 ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
2083 scaledPower, minCtlPower);
2084
2085 /* Apply ctl mode to correct target power set */
2086 switch (pCtlMode[ctlMode]) {
2087 case CTL_11B:
2088 for (i = ALL_TARGET_LEGACY_1L_5L;
2089 i <= ALL_TARGET_LEGACY_11S; i++)
2090 pPwrArray[i] =
2091 (u8)min((u16)pPwrArray[i],
2092 minCtlPower);
2093 break;
2094 case CTL_11A:
2095 case CTL_11G:
2096 for (i = ALL_TARGET_LEGACY_6_24;
2097 i <= ALL_TARGET_LEGACY_54; i++)
2098 pPwrArray[i] =
2099 (u8)min((u16)pPwrArray[i],
2100 minCtlPower);
2101 break;
2102 case CTL_5GHT20:
2103 case CTL_2GHT20:
2104 for (i = ALL_TARGET_HT20_0_8_16;
2105 i <= ALL_TARGET_HT20_21; i++)
2106 pPwrArray[i] =
2107 (u8)min((u16)pPwrArray[i],
2108 minCtlPower);
2109 pPwrArray[ALL_TARGET_HT20_22] =
2110 (u8)min((u16)pPwrArray[ALL_TARGET_HT20_22],
2111 minCtlPower);
2112 pPwrArray[ALL_TARGET_HT20_23] =
2113 (u8)min((u16)pPwrArray[ALL_TARGET_HT20_23],
2114 minCtlPower);
2115 break;
2116 case CTL_5GHT40:
2117 case CTL_2GHT40:
2118 for (i = ALL_TARGET_HT40_0_8_16;
2119 i <= ALL_TARGET_HT40_23; i++)
2120 pPwrArray[i] =
2121 (u8)min((u16)pPwrArray[i],
2122 minCtlPower);
2123 break;
2124 default:
2125 break;
2126 }
2127 } /* end ctl mode checking */
2128}
2129
1802static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, 2130static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
1803 struct ath9k_channel *chan, u16 cfgCtl, 2131 struct ath9k_channel *chan, u16 cfgCtl,
1804 u8 twiceAntennaReduction, 2132 u8 twiceAntennaReduction,
1805 u8 twiceMaxRegulatoryPower, 2133 u8 twiceMaxRegulatoryPower,
1806 u8 powerLimit) 2134 u8 powerLimit)
1807{ 2135{
1808 ah->txpower_limit = powerLimit; 2136 struct ath_common *common = ath9k_hw_common(ah);
1809 ar9003_hw_set_target_power_eeprom(ah, chan->channel); 2137 u8 targetPowerValT2[ar9300RateSize];
2138 unsigned int i = 0;
2139
2140 ar9003_hw_set_target_power_eeprom(ah, chan->channel, targetPowerValT2);
2141 ar9003_hw_set_power_per_rate_table(ah, chan,
2142 targetPowerValT2, cfgCtl,
2143 twiceAntennaReduction,
2144 twiceMaxRegulatoryPower,
2145 powerLimit);
2146
2147 while (i < ar9300RateSize) {
2148 ath_print(common, ATH_DBG_EEPROM,
2149 "TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
2150 i++;
2151 ath_print(common, ATH_DBG_EEPROM,
2152 "TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
2153 i++;
2154 ath_print(common, ATH_DBG_EEPROM,
2155 "TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
2156 i++;
2157 ath_print(common, ATH_DBG_EEPROM,
2158 "TPC[%02d] 0x%08x\n\n", i, targetPowerValT2[i]);
2159 i++;
2160 }
2161
2162 /* Write target power array to registers */
2163 ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
2164
2165 /*
2166 * This is the TX power we send back to driver core,
2167 * and it can use to pass to userspace to display our
2168 * currently configured TX power setting.
2169 *
2170 * Since power is rate dependent, use one of the indices
2171 * from the AR9300_Rates enum to select an entry from
2172 * targetPowerValT2[] to report. Currently returns the
2173 * power for HT40 MCS 0, HT20 MCS 0, or OFDM 6 Mbps
2174 * as CCK power is less interesting (?).
2175 */
2176 i = ALL_TARGET_LEGACY_6_24; /* legacy */
2177 if (IS_CHAN_HT40(chan))
2178 i = ALL_TARGET_HT40_0_8_16; /* ht40 */
2179 else if (IS_CHAN_HT20(chan))
2180 i = ALL_TARGET_HT20_0_8_16; /* ht20 */
2181
2182 ah->txpower_limit = targetPowerValT2[i];
2183
1810 ar9003_hw_calibration_apply(ah, chan->channel); 2184 ar9003_hw_calibration_apply(ah, chan->channel);
1811} 2185}
1812 2186
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index 49e0c865ce5c..7c38229ba670 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -577,10 +577,11 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
577} 577}
578 578
579void ar9003_paprd_populate_single_table(struct ath_hw *ah, 579void ar9003_paprd_populate_single_table(struct ath_hw *ah,
580 struct ath9k_channel *chan, int chain) 580 struct ath9k_hw_cal_data *caldata,
581 int chain)
581{ 582{
582 u32 *paprd_table_val = chan->pa_table[chain]; 583 u32 *paprd_table_val = caldata->pa_table[chain];
583 u32 small_signal_gain = chan->small_signal_gain[chain]; 584 u32 small_signal_gain = caldata->small_signal_gain[chain];
584 u32 training_power; 585 u32 training_power;
585 u32 reg = 0; 586 u32 reg = 0;
586 int i; 587 int i;
@@ -654,17 +655,17 @@ int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain)
654} 655}
655EXPORT_SYMBOL(ar9003_paprd_setup_gain_table); 656EXPORT_SYMBOL(ar9003_paprd_setup_gain_table);
656 657
657int ar9003_paprd_create_curve(struct ath_hw *ah, struct ath9k_channel *chan, 658int ar9003_paprd_create_curve(struct ath_hw *ah,
658 int chain) 659 struct ath9k_hw_cal_data *caldata, int chain)
659{ 660{
660 u16 *small_signal_gain = &chan->small_signal_gain[chain]; 661 u16 *small_signal_gain = &caldata->small_signal_gain[chain];
661 u32 *pa_table = chan->pa_table[chain]; 662 u32 *pa_table = caldata->pa_table[chain];
662 u32 *data_L, *data_U; 663 u32 *data_L, *data_U;
663 int i, status = 0; 664 int i, status = 0;
664 u32 *buf; 665 u32 *buf;
665 u32 reg; 666 u32 reg;
666 667
667 memset(chan->pa_table[chain], 0, sizeof(chan->pa_table[chain])); 668 memset(caldata->pa_table[chain], 0, sizeof(caldata->pa_table[chain]));
668 669
669 buf = kmalloc(2 * 48 * sizeof(u32), GFP_ATOMIC); 670 buf = kmalloc(2 * 48 * sizeof(u32), GFP_ATOMIC);
670 if (!buf) 671 if (!buf)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index a753a431bb13..a491854fa38a 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -542,7 +542,11 @@ static void ar9003_hw_prog_ini(struct ath_hw *ah,
542 u32 reg = INI_RA(iniArr, i, 0); 542 u32 reg = INI_RA(iniArr, i, 0);
543 u32 val = INI_RA(iniArr, i, column); 543 u32 val = INI_RA(iniArr, i, column);
544 544
545 REG_WRITE(ah, reg, val); 545 if (reg >= 0x16000 && reg < 0x17000)
546 ath9k_hw_analog_shift_regwrite(ah, reg, val);
547 else
548 REG_WRITE(ah, reg, val);
549
546 DO_DELAY(regWrites); 550 DO_DELAY(regWrites);
547 } 551 }
548} 552}
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 998ae2c49ed2..07f26ee7a723 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -510,7 +510,7 @@ void ath_deinit_leds(struct ath_softc *sc);
510#define SC_OP_BEACONS BIT(1) 510#define SC_OP_BEACONS BIT(1)
511#define SC_OP_RXAGGR BIT(2) 511#define SC_OP_RXAGGR BIT(2)
512#define SC_OP_TXAGGR BIT(3) 512#define SC_OP_TXAGGR BIT(3)
513#define SC_OP_FULL_RESET BIT(4) 513#define SC_OP_OFFCHANNEL BIT(4)
514#define SC_OP_PREAMBLE_SHORT BIT(5) 514#define SC_OP_PREAMBLE_SHORT BIT(5)
515#define SC_OP_PROTECT_ENABLE BIT(6) 515#define SC_OP_PROTECT_ENABLE BIT(6)
516#define SC_OP_RXFLUSH BIT(7) 516#define SC_OP_RXFLUSH BIT(7)
@@ -609,6 +609,7 @@ struct ath_softc {
609struct ath_wiphy { 609struct ath_wiphy {
610 struct ath_softc *sc; /* shared for all virtual wiphys */ 610 struct ath_softc *sc; /* shared for all virtual wiphys */
611 struct ieee80211_hw *hw; 611 struct ieee80211_hw *hw;
612 struct ath9k_hw_cal_data caldata;
612 enum ath_wiphy_state { 613 enum ath_wiphy_state {
613 ATH_WIPHY_INACTIVE, 614 ATH_WIPHY_INACTIVE,
614 ATH_WIPHY_ACTIVE, 615 ATH_WIPHY_ACTIVE,
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 139289e4e933..45208690c0ec 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -22,23 +22,6 @@
22/* We can tune this as we go by monitoring really low values */ 22/* We can tune this as we go by monitoring really low values */
23#define ATH9K_NF_TOO_LOW -60 23#define ATH9K_NF_TOO_LOW -60
24 24
25/* AR5416 may return very high value (like -31 dBm), in those cases the nf
26 * is incorrect and we should use the static NF value. Later we can try to
27 * find out why they are reporting these values */
28
29static bool ath9k_hw_nf_in_range(struct ath_hw *ah, s16 nf)
30{
31 if (nf > ATH9K_NF_TOO_LOW) {
32 ath_print(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
33 "noise floor value detected (%d) is "
34 "lower than what we think is a "
35 "reasonable value (%d)\n",
36 nf, ATH9K_NF_TOO_LOW);
37 return false;
38 }
39 return true;
40}
41
42static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer) 25static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
43{ 26{
44 int16_t nfval; 27 int16_t nfval;
@@ -121,6 +104,19 @@ void ath9k_hw_reset_calibration(struct ath_hw *ah,
121 ah->cal_samples = 0; 104 ah->cal_samples = 0;
122} 105}
123 106
107static s16 ath9k_hw_get_default_nf(struct ath_hw *ah,
108 struct ath9k_channel *chan)
109{
110 struct ath_nf_limits *limit;
111
112 if (!chan || IS_CHAN_2GHZ(chan))
113 limit = &ah->nf_2g;
114 else
115 limit = &ah->nf_5g;
116
117 return limit->nominal;
118}
119
124/* This is done for the currently configured channel */ 120/* This is done for the currently configured channel */
125bool ath9k_hw_reset_calvalid(struct ath_hw *ah) 121bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
126{ 122{
@@ -128,7 +124,7 @@ bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
128 struct ieee80211_conf *conf = &common->hw->conf; 124 struct ieee80211_conf *conf = &common->hw->conf;
129 struct ath9k_cal_list *currCal = ah->cal_list_curr; 125 struct ath9k_cal_list *currCal = ah->cal_list_curr;
130 126
131 if (!ah->curchan) 127 if (!ah->caldata)
132 return true; 128 return true;
133 129
134 if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah)) 130 if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah))
@@ -151,37 +147,55 @@ bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
151 "Resetting Cal %d state for channel %u\n", 147 "Resetting Cal %d state for channel %u\n",
152 currCal->calData->calType, conf->channel->center_freq); 148 currCal->calData->calType, conf->channel->center_freq);
153 149
154 ah->curchan->CalValid &= ~currCal->calData->calType; 150 ah->caldata->CalValid &= ~currCal->calData->calType;
155 currCal->calState = CAL_WAITING; 151 currCal->calState = CAL_WAITING;
156 152
157 return false; 153 return false;
158} 154}
159EXPORT_SYMBOL(ath9k_hw_reset_calvalid); 155EXPORT_SYMBOL(ath9k_hw_reset_calvalid);
160 156
161void ath9k_hw_start_nfcal(struct ath_hw *ah) 157void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update)
162{ 158{
159 if (ah->caldata)
160 ah->caldata->nfcal_pending = true;
161
163 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, 162 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
164 AR_PHY_AGC_CONTROL_ENABLE_NF); 163 AR_PHY_AGC_CONTROL_ENABLE_NF);
165 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, 164
165 if (update)
166 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
167 AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
168 else
169 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
166 AR_PHY_AGC_CONTROL_NO_UPDATE_NF); 170 AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
171
167 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); 172 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
168} 173}
169 174
170void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan) 175void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
171{ 176{
172 struct ath9k_nfcal_hist *h; 177 struct ath9k_nfcal_hist *h = NULL;
173 unsigned i, j; 178 unsigned i, j;
174 int32_t val; 179 int32_t val;
175 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; 180 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
176 struct ath_common *common = ath9k_hw_common(ah); 181 struct ath_common *common = ath9k_hw_common(ah);
182 s16 default_nf = ath9k_hw_get_default_nf(ah, chan);
177 183
178 h = ah->nfCalHist; 184 if (ah->caldata)
185 h = ah->caldata->nfCalHist;
179 186
180 for (i = 0; i < NUM_NF_READINGS; i++) { 187 for (i = 0; i < NUM_NF_READINGS; i++) {
181 if (chainmask & (1 << i)) { 188 if (chainmask & (1 << i)) {
189 s16 nfval;
190
191 if (h)
192 nfval = h[i].privNF;
193 else
194 nfval = default_nf;
195
182 val = REG_READ(ah, ah->nf_regs[i]); 196 val = REG_READ(ah, ah->nf_regs[i]);
183 val &= 0xFFFFFE00; 197 val &= 0xFFFFFE00;
184 val |= (((u32) (h[i].privNF) << 1) & 0x1ff); 198 val |= (((u32) nfval << 1) & 0x1ff);
185 REG_WRITE(ah, ah->nf_regs[i], val); 199 REG_WRITE(ah, ah->nf_regs[i], val);
186 } 200 }
187 } 201 }
@@ -277,22 +291,25 @@ static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
277 } 291 }
278} 292}
279 293
280int16_t ath9k_hw_getnf(struct ath_hw *ah, 294bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan)
281 struct ath9k_channel *chan)
282{ 295{
283 struct ath_common *common = ath9k_hw_common(ah); 296 struct ath_common *common = ath9k_hw_common(ah);
284 int16_t nf, nfThresh; 297 int16_t nf, nfThresh;
285 int16_t nfarray[NUM_NF_READINGS] = { 0 }; 298 int16_t nfarray[NUM_NF_READINGS] = { 0 };
286 struct ath9k_nfcal_hist *h; 299 struct ath9k_nfcal_hist *h;
287 struct ieee80211_channel *c = chan->chan; 300 struct ieee80211_channel *c = chan->chan;
301 struct ath9k_hw_cal_data *caldata = ah->caldata;
302
303 if (!caldata)
304 return false;
288 305
289 chan->channelFlags &= (~CHANNEL_CW_INT); 306 chan->channelFlags &= (~CHANNEL_CW_INT);
290 if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) { 307 if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) {
291 ath_print(common, ATH_DBG_CALIBRATE, 308 ath_print(common, ATH_DBG_CALIBRATE,
292 "NF did not complete in calibration window\n"); 309 "NF did not complete in calibration window\n");
293 nf = 0; 310 nf = 0;
294 chan->rawNoiseFloor = nf; 311 caldata->rawNoiseFloor = nf;
295 return chan->rawNoiseFloor; 312 return false;
296 } else { 313 } else {
297 ath9k_hw_do_getnf(ah, nfarray); 314 ath9k_hw_do_getnf(ah, nfarray);
298 ath9k_hw_nf_sanitize(ah, nfarray); 315 ath9k_hw_nf_sanitize(ah, nfarray);
@@ -307,47 +324,40 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah,
307 } 324 }
308 } 325 }
309 326
310 h = ah->nfCalHist; 327 h = caldata->nfCalHist;
311 328 caldata->nfcal_pending = false;
312 ath9k_hw_update_nfcal_hist_buffer(h, nfarray); 329 ath9k_hw_update_nfcal_hist_buffer(h, nfarray);
313 chan->rawNoiseFloor = h[0].privNF; 330 caldata->rawNoiseFloor = h[0].privNF;
314 331 return true;
315 return chan->rawNoiseFloor;
316} 332}
317 333
318void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah) 334void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
335 struct ath9k_channel *chan)
319{ 336{
320 struct ath_nf_limits *limit; 337 struct ath9k_nfcal_hist *h;
338 s16 default_nf;
321 int i, j; 339 int i, j;
322 340
323 if (!ah->curchan || IS_CHAN_2GHZ(ah->curchan)) 341 if (!ah->caldata)
324 limit = &ah->nf_2g; 342 return;
325 else
326 limit = &ah->nf_5g;
327 343
344 h = ah->caldata->nfCalHist;
345 default_nf = ath9k_hw_get_default_nf(ah, chan);
328 for (i = 0; i < NUM_NF_READINGS; i++) { 346 for (i = 0; i < NUM_NF_READINGS; i++) {
329 ah->nfCalHist[i].currIndex = 0; 347 h[i].currIndex = 0;
330 ah->nfCalHist[i].privNF = limit->nominal; 348 h[i].privNF = default_nf;
331 ah->nfCalHist[i].invalidNFcount = 349 h[i].invalidNFcount = AR_PHY_CCA_FILTERWINDOW_LENGTH;
332 AR_PHY_CCA_FILTERWINDOW_LENGTH;
333 for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) { 350 for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) {
334 ah->nfCalHist[i].nfCalBuffer[j] = limit->nominal; 351 h[i].nfCalBuffer[j] = default_nf;
335 } 352 }
336 } 353 }
337} 354}
338 355
339s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan) 356s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan)
340{ 357{
341 s16 nf; 358 if (!ah->caldata || !ah->caldata->rawNoiseFloor)
342 359 return ath9k_hw_get_default_nf(ah, chan);
343 if (chan->rawNoiseFloor == 0)
344 nf = -96;
345 else
346 nf = chan->rawNoiseFloor;
347
348 if (!ath9k_hw_nf_in_range(ah, nf))
349 nf = ATH_DEFAULT_NOISE_FLOOR;
350 360
351 return nf; 361 return ah->caldata->rawNoiseFloor;
352} 362}
353EXPORT_SYMBOL(ath9k_hw_getchan_noise); 363EXPORT_SYMBOL(ath9k_hw_getchan_noise);
diff --git a/drivers/net/wireless/ath/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
index cd60d09cdda7..0a304b3eeeb6 100644
--- a/drivers/net/wireless/ath/ath9k/calib.h
+++ b/drivers/net/wireless/ath/ath9k/calib.h
@@ -108,11 +108,11 @@ struct ath9k_pacal_info{
108}; 108};
109 109
110bool ath9k_hw_reset_calvalid(struct ath_hw *ah); 110bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
111void ath9k_hw_start_nfcal(struct ath_hw *ah); 111void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update);
112void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan); 112void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
113int16_t ath9k_hw_getnf(struct ath_hw *ah, 113bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan);
114 struct ath9k_channel *chan); 114void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
115void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah); 115 struct ath9k_channel *chan);
116s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan); 116s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan);
117void ath9k_hw_reset_calibration(struct ath_hw *ah, 117void ath9k_hw_reset_calibration(struct ath_hw *ah,
118 struct ath9k_cal_list *currCal); 118 struct ath9k_cal_list *currCal);
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 3756400e6bf9..43b9e21bc562 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -353,6 +353,8 @@ struct ath9k_htc_priv {
353 u16 seq_no; 353 u16 seq_no;
354 u32 bmiss_cnt; 354 u32 bmiss_cnt;
355 355
356 struct ath9k_hw_cal_data caldata[38];
357
356 spinlock_t beacon_lock; 358 spinlock_t beacon_lock;
357 359
358 bool tx_queues_stop; 360 bool tx_queues_stop;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index cf9bcc67ade2..ebed9d1691a5 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -125,6 +125,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
125 struct ieee80211_conf *conf = &common->hw->conf; 125 struct ieee80211_conf *conf = &common->hw->conf;
126 bool fastcc = true; 126 bool fastcc = true;
127 struct ieee80211_channel *channel = hw->conf.channel; 127 struct ieee80211_channel *channel = hw->conf.channel;
128 struct ath9k_hw_cal_data *caldata;
128 enum htc_phymode mode; 129 enum htc_phymode mode;
129 __be16 htc_mode; 130 __be16 htc_mode;
130 u8 cmd_rsp; 131 u8 cmd_rsp;
@@ -149,7 +150,8 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
149 priv->ah->curchan->channel, 150 priv->ah->curchan->channel,
150 channel->center_freq, conf_is_ht(conf), conf_is_ht40(conf)); 151 channel->center_freq, conf_is_ht(conf), conf_is_ht40(conf));
151 152
152 ret = ath9k_hw_reset(ah, hchan, fastcc); 153 caldata = &priv->caldata[channel->hw_value];
154 ret = ath9k_hw_reset(ah, hchan, caldata, fastcc);
153 if (ret) { 155 if (ret) {
154 ath_print(common, ATH_DBG_FATAL, 156 ath_print(common, ATH_DBG_FATAL,
155 "Unable to reset channel (%u Mhz) " 157 "Unable to reset channel (%u Mhz) "
@@ -1028,7 +1030,7 @@ static void ath9k_htc_radio_enable(struct ieee80211_hw *hw)
1028 ah->curchan = ath9k_cmn_get_curchannel(hw, ah); 1030 ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
1029 1031
1030 /* Reset the HW */ 1032 /* Reset the HW */
1031 ret = ath9k_hw_reset(ah, ah->curchan, false); 1033 ret = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
1032 if (ret) { 1034 if (ret) {
1033 ath_print(common, ATH_DBG_FATAL, 1035 ath_print(common, ATH_DBG_FATAL,
1034 "Unable to reset hardware; reset status %d " 1036 "Unable to reset hardware; reset status %d "
@@ -1091,7 +1093,7 @@ static void ath9k_htc_radio_disable(struct ieee80211_hw *hw)
1091 ah->curchan = ath9k_cmn_get_curchannel(hw, ah); 1093 ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
1092 1094
1093 /* Reset the HW */ 1095 /* Reset the HW */
1094 ret = ath9k_hw_reset(ah, ah->curchan, false); 1096 ret = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
1095 if (ret) { 1097 if (ret) {
1096 ath_print(common, ATH_DBG_FATAL, 1098 ath_print(common, ATH_DBG_FATAL,
1097 "Unable to reset hardware; reset status %d " 1099 "Unable to reset hardware; reset status %d "
@@ -1179,7 +1181,7 @@ static int ath9k_htc_start(struct ieee80211_hw *hw)
1179 ath9k_hw_configpcipowersave(ah, 0, 0); 1181 ath9k_hw_configpcipowersave(ah, 0, 0);
1180 1182
1181 ath9k_hw_htc_resetinit(ah); 1183 ath9k_hw_htc_resetinit(ah);
1182 ret = ath9k_hw_reset(ah, init_channel, false); 1184 ret = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
1183 if (ret) { 1185 if (ret) {
1184 ath_print(common, ATH_DBG_FATAL, 1186 ath_print(common, ATH_DBG_FATAL,
1185 "Unable to reset hardware; reset status %d " 1187 "Unable to reset hardware; reset status %d "
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 8d291ccf5c88..3384ca164562 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -610,7 +610,6 @@ static int __ath9k_hw_init(struct ath_hw *ah)
610 else 610 else
611 ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S); 611 ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S);
612 612
613 ath9k_init_nfcal_hist_buffer(ah);
614 ah->bb_watchdog_timeout_ms = 25; 613 ah->bb_watchdog_timeout_ms = 25;
615 614
616 common->state = ATH_HW_INITIALIZED; 615 common->state = ATH_HW_INITIALIZED;
@@ -1183,9 +1182,6 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
1183 1182
1184 ath9k_hw_spur_mitigate_freq(ah, chan); 1183 ath9k_hw_spur_mitigate_freq(ah, chan);
1185 1184
1186 if (!chan->oneTimeCalsDone)
1187 chan->oneTimeCalsDone = true;
1188
1189 return true; 1185 return true;
1190} 1186}
1191 1187
@@ -1218,7 +1214,7 @@ bool ath9k_hw_check_alive(struct ath_hw *ah)
1218EXPORT_SYMBOL(ath9k_hw_check_alive); 1214EXPORT_SYMBOL(ath9k_hw_check_alive);
1219 1215
1220int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, 1216int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1221 bool bChannelChange) 1217 struct ath9k_hw_cal_data *caldata, bool bChannelChange)
1222{ 1218{
1223 struct ath_common *common = ath9k_hw_common(ah); 1219 struct ath_common *common = ath9k_hw_common(ah);
1224 u32 saveLedState; 1220 u32 saveLedState;
@@ -1243,9 +1239,19 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1243 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) 1239 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1244 return -EIO; 1240 return -EIO;
1245 1241
1246 if (curchan && !ah->chip_fullsleep) 1242 if (curchan && !ah->chip_fullsleep && ah->caldata)
1247 ath9k_hw_getnf(ah, curchan); 1243 ath9k_hw_getnf(ah, curchan);
1248 1244
1245 ah->caldata = caldata;
1246 if (caldata &&
1247 (chan->channel != caldata->channel ||
1248 (chan->channelFlags & ~CHANNEL_CW_INT) !=
1249 (caldata->channelFlags & ~CHANNEL_CW_INT))) {
1250 /* Operating channel changed, reset channel calibration data */
1251 memset(caldata, 0, sizeof(*caldata));
1252 ath9k_init_nfcal_hist_buffer(ah, chan);
1253 }
1254
1249 if (bChannelChange && 1255 if (bChannelChange &&
1250 (ah->chip_fullsleep != true) && 1256 (ah->chip_fullsleep != true) &&
1251 (ah->curchan != NULL) && 1257 (ah->curchan != NULL) &&
@@ -1256,7 +1262,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1256 1262
1257 if (ath9k_hw_channel_change(ah, chan)) { 1263 if (ath9k_hw_channel_change(ah, chan)) {
1258 ath9k_hw_loadnf(ah, ah->curchan); 1264 ath9k_hw_loadnf(ah, ah->curchan);
1259 ath9k_hw_start_nfcal(ah); 1265 ath9k_hw_start_nfcal(ah, true);
1260 return 0; 1266 return 0;
1261 } 1267 }
1262 } 1268 }
@@ -1461,11 +1467,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1461 if (ah->btcoex_hw.enabled) 1467 if (ah->btcoex_hw.enabled)
1462 ath9k_hw_btcoex_enable(ah); 1468 ath9k_hw_btcoex_enable(ah);
1463 1469
1464 if (AR_SREV_9300_20_OR_LATER(ah)) { 1470 if (AR_SREV_9300_20_OR_LATER(ah))
1465 ath9k_hw_loadnf(ah, curchan);
1466 ath9k_hw_start_nfcal(ah);
1467 ar9003_hw_bb_watchdog_config(ah); 1471 ar9003_hw_bb_watchdog_config(ah);
1468 }
1469 1472
1470 return 0; 1473 return 0;
1471} 1474}
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 2d30efc0b94f..399f7c1283cd 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -346,19 +346,25 @@ enum ath9k_int {
346 CHANNEL_HT40PLUS | \ 346 CHANNEL_HT40PLUS | \
347 CHANNEL_HT40MINUS) 347 CHANNEL_HT40MINUS)
348 348
349struct ath9k_channel { 349struct ath9k_hw_cal_data {
350 struct ieee80211_channel *chan;
351 u16 channel; 350 u16 channel;
352 u32 channelFlags; 351 u32 channelFlags;
353 u32 chanmode;
354 int32_t CalValid; 352 int32_t CalValid;
355 bool oneTimeCalsDone;
356 int8_t iCoff; 353 int8_t iCoff;
357 int8_t qCoff; 354 int8_t qCoff;
358 int16_t rawNoiseFloor; 355 int16_t rawNoiseFloor;
359 bool paprd_done; 356 bool paprd_done;
357 bool nfcal_pending;
360 u16 small_signal_gain[AR9300_MAX_CHAINS]; 358 u16 small_signal_gain[AR9300_MAX_CHAINS];
361 u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; 359 u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ];
360 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
361};
362
363struct ath9k_channel {
364 struct ieee80211_channel *chan;
365 u16 channel;
366 u32 channelFlags;
367 u32 chanmode;
362}; 368};
363 369
364#define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \ 370#define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \
@@ -669,7 +675,7 @@ struct ath_hw {
669 enum nl80211_iftype opmode; 675 enum nl80211_iftype opmode;
670 enum ath9k_power_mode power_mode; 676 enum ath9k_power_mode power_mode;
671 677
672 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; 678 struct ath9k_hw_cal_data *caldata;
673 struct ath9k_pacal_info pacal_info; 679 struct ath9k_pacal_info pacal_info;
674 struct ar5416Stats stats; 680 struct ar5416Stats stats;
675 struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES]; 681 struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES];
@@ -863,7 +869,7 @@ const char *ath9k_hw_probe(u16 vendorid, u16 devid);
863void ath9k_hw_deinit(struct ath_hw *ah); 869void ath9k_hw_deinit(struct ath_hw *ah);
864int ath9k_hw_init(struct ath_hw *ah); 870int ath9k_hw_init(struct ath_hw *ah);
865int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, 871int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
866 bool bChannelChange); 872 struct ath9k_hw_cal_data *caldata, bool bChannelChange);
867int ath9k_hw_fill_cap_info(struct ath_hw *ah); 873int ath9k_hw_fill_cap_info(struct ath_hw *ah);
868u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); 874u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan);
869 875
@@ -958,9 +964,10 @@ void ar9003_hw_bb_watchdog_read(struct ath_hw *ah);
958void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); 964void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah);
959void ar9003_paprd_enable(struct ath_hw *ah, bool val); 965void ar9003_paprd_enable(struct ath_hw *ah, bool val);
960void ar9003_paprd_populate_single_table(struct ath_hw *ah, 966void ar9003_paprd_populate_single_table(struct ath_hw *ah,
961 struct ath9k_channel *chan, int chain); 967 struct ath9k_hw_cal_data *caldata,
962int ar9003_paprd_create_curve(struct ath_hw *ah, struct ath9k_channel *chan, 968 int chain);
963 int chain); 969int ar9003_paprd_create_curve(struct ath_hw *ah,
970 struct ath9k_hw_cal_data *caldata, int chain);
964int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain); 971int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain);
965int ar9003_paprd_init_table(struct ath_hw *ah); 972int ar9003_paprd_init_table(struct ath_hw *ah);
966bool ar9003_paprd_is_done(struct ath_hw *ah); 973bool ar9003_paprd_is_done(struct ath_hw *ah);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 0429dda0961f..3caa32316e7b 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -154,6 +154,27 @@ void ath9k_ps_restore(struct ath_softc *sc)
154 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); 154 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
155} 155}
156 156
157static void ath_start_ani(struct ath_common *common)
158{
159 struct ath_hw *ah = common->ah;
160 unsigned long timestamp = jiffies_to_msecs(jiffies);
161 struct ath_softc *sc = (struct ath_softc *) common->priv;
162
163 if (!(sc->sc_flags & SC_OP_ANI_RUN))
164 return;
165
166 if (sc->sc_flags & SC_OP_OFFCHANNEL)
167 return;
168
169 common->ani.longcal_timer = timestamp;
170 common->ani.shortcal_timer = timestamp;
171 common->ani.checkani_timer = timestamp;
172
173 mod_timer(&common->ani.timer,
174 jiffies +
175 msecs_to_jiffies((u32)ah->config.ani_poll_interval));
176}
177
157/* 178/*
158 * Set/change channels. If the channel is really being changed, it's done 179 * Set/change channels. If the channel is really being changed, it's done
159 * by reseting the chip. To accomplish this we must first cleanup any pending 180 * by reseting the chip. To accomplish this we must first cleanup any pending
@@ -162,16 +183,23 @@ void ath9k_ps_restore(struct ath_softc *sc)
162int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw, 183int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
163 struct ath9k_channel *hchan) 184 struct ath9k_channel *hchan)
164{ 185{
186 struct ath_wiphy *aphy = hw->priv;
165 struct ath_hw *ah = sc->sc_ah; 187 struct ath_hw *ah = sc->sc_ah;
166 struct ath_common *common = ath9k_hw_common(ah); 188 struct ath_common *common = ath9k_hw_common(ah);
167 struct ieee80211_conf *conf = &common->hw->conf; 189 struct ieee80211_conf *conf = &common->hw->conf;
168 bool fastcc = true, stopped; 190 bool fastcc = true, stopped;
169 struct ieee80211_channel *channel = hw->conf.channel; 191 struct ieee80211_channel *channel = hw->conf.channel;
192 struct ath9k_hw_cal_data *caldata = NULL;
170 int r; 193 int r;
171 194
172 if (sc->sc_flags & SC_OP_INVALID) 195 if (sc->sc_flags & SC_OP_INVALID)
173 return -EIO; 196 return -EIO;
174 197
198 del_timer_sync(&common->ani.timer);
199 cancel_work_sync(&sc->paprd_work);
200 cancel_work_sync(&sc->hw_check_work);
201 cancel_delayed_work_sync(&sc->tx_complete_work);
202
175 ath9k_ps_wakeup(sc); 203 ath9k_ps_wakeup(sc);
176 204
177 /* 205 /*
@@ -191,9 +219,12 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
191 * to flush data frames already in queue because of 219 * to flush data frames already in queue because of
192 * changing channel. */ 220 * changing channel. */
193 221
194 if (!stopped || (sc->sc_flags & SC_OP_FULL_RESET)) 222 if (!stopped || !(sc->sc_flags & SC_OP_OFFCHANNEL))
195 fastcc = false; 223 fastcc = false;
196 224
225 if (!(sc->sc_flags & SC_OP_OFFCHANNEL))
226 caldata = &aphy->caldata;
227
197 ath_print(common, ATH_DBG_CONFIG, 228 ath_print(common, ATH_DBG_CONFIG,
198 "(%u MHz) -> (%u MHz), conf_is_ht40: %d\n", 229 "(%u MHz) -> (%u MHz), conf_is_ht40: %d\n",
199 sc->sc_ah->curchan->channel, 230 sc->sc_ah->curchan->channel,
@@ -201,7 +232,7 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
201 232
202 spin_lock_bh(&sc->sc_resetlock); 233 spin_lock_bh(&sc->sc_resetlock);
203 234
204 r = ath9k_hw_reset(ah, hchan, fastcc); 235 r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
205 if (r) { 236 if (r) {
206 ath_print(common, ATH_DBG_FATAL, 237 ath_print(common, ATH_DBG_FATAL,
207 "Unable to reset channel (%u MHz), " 238 "Unable to reset channel (%u MHz), "
@@ -212,8 +243,6 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
212 } 243 }
213 spin_unlock_bh(&sc->sc_resetlock); 244 spin_unlock_bh(&sc->sc_resetlock);
214 245
215 sc->sc_flags &= ~SC_OP_FULL_RESET;
216
217 if (ath_startrecv(sc) != 0) { 246 if (ath_startrecv(sc) != 0) {
218 ath_print(common, ATH_DBG_FATAL, 247 ath_print(common, ATH_DBG_FATAL,
219 "Unable to restart recv logic\n"); 248 "Unable to restart recv logic\n");
@@ -225,6 +254,12 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
225 ath_update_txpow(sc); 254 ath_update_txpow(sc);
226 ath9k_hw_set_interrupts(ah, ah->imask); 255 ath9k_hw_set_interrupts(ah, ah->imask);
227 256
257 if (!(sc->sc_flags & (SC_OP_OFFCHANNEL | SC_OP_SCANNING))) {
258 ath_start_ani(common);
259 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
260 ath_beacon_config(sc, NULL);
261 }
262
228 ps_restore: 263 ps_restore:
229 ath9k_ps_restore(sc); 264 ath9k_ps_restore(sc);
230 return r; 265 return r;
@@ -233,17 +268,19 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
233static void ath_paprd_activate(struct ath_softc *sc) 268static void ath_paprd_activate(struct ath_softc *sc)
234{ 269{
235 struct ath_hw *ah = sc->sc_ah; 270 struct ath_hw *ah = sc->sc_ah;
271 struct ath9k_hw_cal_data *caldata = ah->caldata;
236 int chain; 272 int chain;
237 273
238 if (!ah->curchan->paprd_done) 274 if (!caldata || !caldata->paprd_done)
239 return; 275 return;
240 276
241 ath9k_ps_wakeup(sc); 277 ath9k_ps_wakeup(sc);
278 ar9003_paprd_enable(ah, false);
242 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) { 279 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
243 if (!(ah->caps.tx_chainmask & BIT(chain))) 280 if (!(ah->caps.tx_chainmask & BIT(chain)))
244 continue; 281 continue;
245 282
246 ar9003_paprd_populate_single_table(ah, ah->curchan, chain); 283 ar9003_paprd_populate_single_table(ah, caldata, chain);
247 } 284 }
248 285
249 ar9003_paprd_enable(ah, true); 286 ar9003_paprd_enable(ah, true);
@@ -261,6 +298,7 @@ void ath_paprd_calibrate(struct work_struct *work)
261 int band = hw->conf.channel->band; 298 int band = hw->conf.channel->band;
262 struct ieee80211_supported_band *sband = &sc->sbands[band]; 299 struct ieee80211_supported_band *sband = &sc->sbands[band];
263 struct ath_tx_control txctl; 300 struct ath_tx_control txctl;
301 struct ath9k_hw_cal_data *caldata = ah->caldata;
264 int qnum, ftype; 302 int qnum, ftype;
265 int chain_ok = 0; 303 int chain_ok = 0;
266 int chain; 304 int chain;
@@ -268,6 +306,9 @@ void ath_paprd_calibrate(struct work_struct *work)
268 int time_left; 306 int time_left;
269 int i; 307 int i;
270 308
309 if (!caldata)
310 return;
311
271 skb = alloc_skb(len, GFP_KERNEL); 312 skb = alloc_skb(len, GFP_KERNEL);
272 if (!skb) 313 if (!skb)
273 return; 314 return;
@@ -322,7 +363,7 @@ void ath_paprd_calibrate(struct work_struct *work)
322 if (!ar9003_paprd_is_done(ah)) 363 if (!ar9003_paprd_is_done(ah))
323 break; 364 break;
324 365
325 if (ar9003_paprd_create_curve(ah, ah->curchan, chain) != 0) 366 if (ar9003_paprd_create_curve(ah, caldata, chain) != 0)
326 break; 367 break;
327 368
328 chain_ok = 1; 369 chain_ok = 1;
@@ -330,7 +371,7 @@ void ath_paprd_calibrate(struct work_struct *work)
330 kfree_skb(skb); 371 kfree_skb(skb);
331 372
332 if (chain_ok) { 373 if (chain_ok) {
333 ah->curchan->paprd_done = true; 374 caldata->paprd_done = true;
334 ath_paprd_activate(sc); 375 ath_paprd_activate(sc);
335 } 376 }
336 377
@@ -439,33 +480,14 @@ set_timer:
439 cal_interval = min(cal_interval, (u32)short_cal_interval); 480 cal_interval = min(cal_interval, (u32)short_cal_interval);
440 481
441 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); 482 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
442 if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && 483 if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) {
443 !(sc->sc_flags & SC_OP_SCANNING)) { 484 if (!ah->caldata->paprd_done)
444 if (!sc->sc_ah->curchan->paprd_done)
445 ieee80211_queue_work(sc->hw, &sc->paprd_work); 485 ieee80211_queue_work(sc->hw, &sc->paprd_work);
446 else 486 else
447 ath_paprd_activate(sc); 487 ath_paprd_activate(sc);
448 } 488 }
449} 489}
450 490
451static void ath_start_ani(struct ath_common *common)
452{
453 struct ath_hw *ah = common->ah;
454 unsigned long timestamp = jiffies_to_msecs(jiffies);
455 struct ath_softc *sc = (struct ath_softc *) common->priv;
456
457 if (!(sc->sc_flags & SC_OP_ANI_RUN))
458 return;
459
460 common->ani.longcal_timer = timestamp;
461 common->ani.shortcal_timer = timestamp;
462 common->ani.checkani_timer = timestamp;
463
464 mod_timer(&common->ani.timer,
465 jiffies +
466 msecs_to_jiffies((u32)ah->config.ani_poll_interval));
467}
468
469/* 491/*
470 * Update tx/rx chainmask. For legacy association, 492 * Update tx/rx chainmask. For legacy association,
471 * hard code chainmask to 1x1, for 11n association, use 493 * hard code chainmask to 1x1, for 11n association, use
@@ -477,7 +499,7 @@ void ath_update_chainmask(struct ath_softc *sc, int is_ht)
477 struct ath_hw *ah = sc->sc_ah; 499 struct ath_hw *ah = sc->sc_ah;
478 struct ath_common *common = ath9k_hw_common(ah); 500 struct ath_common *common = ath9k_hw_common(ah);
479 501
480 if ((sc->sc_flags & SC_OP_SCANNING) || is_ht || 502 if ((sc->sc_flags & SC_OP_OFFCHANNEL) || is_ht ||
481 (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE)) { 503 (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE)) {
482 common->tx_chainmask = ah->caps.tx_chainmask; 504 common->tx_chainmask = ah->caps.tx_chainmask;
483 common->rx_chainmask = ah->caps.rx_chainmask; 505 common->rx_chainmask = ah->caps.rx_chainmask;
@@ -817,7 +839,7 @@ void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
817 ah->curchan = ath_get_curchannel(sc, sc->hw); 839 ah->curchan = ath_get_curchannel(sc, sc->hw);
818 840
819 spin_lock_bh(&sc->sc_resetlock); 841 spin_lock_bh(&sc->sc_resetlock);
820 r = ath9k_hw_reset(ah, ah->curchan, false); 842 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
821 if (r) { 843 if (r) {
822 ath_print(common, ATH_DBG_FATAL, 844 ath_print(common, ATH_DBG_FATAL,
823 "Unable to reset channel (%u MHz), " 845 "Unable to reset channel (%u MHz), "
@@ -877,7 +899,7 @@ void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
877 ah->curchan = ath_get_curchannel(sc, hw); 899 ah->curchan = ath_get_curchannel(sc, hw);
878 900
879 spin_lock_bh(&sc->sc_resetlock); 901 spin_lock_bh(&sc->sc_resetlock);
880 r = ath9k_hw_reset(ah, ah->curchan, false); 902 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
881 if (r) { 903 if (r) {
882 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, 904 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
883 "Unable to reset channel (%u MHz), " 905 "Unable to reset channel (%u MHz), "
@@ -910,7 +932,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
910 ath_flushrecv(sc); 932 ath_flushrecv(sc);
911 933
912 spin_lock_bh(&sc->sc_resetlock); 934 spin_lock_bh(&sc->sc_resetlock);
913 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false); 935 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
914 if (r) 936 if (r)
915 ath_print(common, ATH_DBG_FATAL, 937 ath_print(common, ATH_DBG_FATAL,
916 "Unable to reset hardware; reset status %d\n", r); 938 "Unable to reset hardware; reset status %d\n", r);
@@ -1085,7 +1107,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
1085 * and then setup of the interrupt mask. 1107 * and then setup of the interrupt mask.
1086 */ 1108 */
1087 spin_lock_bh(&sc->sc_resetlock); 1109 spin_lock_bh(&sc->sc_resetlock);
1088 r = ath9k_hw_reset(ah, init_channel, false); 1110 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
1089 if (r) { 1111 if (r) {
1090 ath_print(common, ATH_DBG_FATAL, 1112 ath_print(common, ATH_DBG_FATAL,
1091 "Unable to reset hardware; reset status %d " 1113 "Unable to reset hardware; reset status %d "
@@ -1579,6 +1601,10 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1579 1601
1580 aphy->chan_idx = pos; 1602 aphy->chan_idx = pos;
1581 aphy->chan_is_ht = conf_is_ht(conf); 1603 aphy->chan_is_ht = conf_is_ht(conf);
1604 if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
1605 sc->sc_flags |= SC_OP_OFFCHANNEL;
1606 else
1607 sc->sc_flags &= ~SC_OP_OFFCHANNEL;
1582 1608
1583 if (aphy->state == ATH_WIPHY_SCAN || 1609 if (aphy->state == ATH_WIPHY_SCAN ||
1584 aphy->state == ATH_WIPHY_ACTIVE) 1610 aphy->state == ATH_WIPHY_ACTIVE)
@@ -1990,7 +2016,6 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
1990{ 2016{
1991 struct ath_wiphy *aphy = hw->priv; 2017 struct ath_wiphy *aphy = hw->priv;
1992 struct ath_softc *sc = aphy->sc; 2018 struct ath_softc *sc = aphy->sc;
1993 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1994 2019
1995 mutex_lock(&sc->mutex); 2020 mutex_lock(&sc->mutex);
1996 if (ath9k_wiphy_scanning(sc)) { 2021 if (ath9k_wiphy_scanning(sc)) {
@@ -2008,10 +2033,6 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2008 aphy->state = ATH_WIPHY_SCAN; 2033 aphy->state = ATH_WIPHY_SCAN;
2009 ath9k_wiphy_pause_all_forced(sc, aphy); 2034 ath9k_wiphy_pause_all_forced(sc, aphy);
2010 sc->sc_flags |= SC_OP_SCANNING; 2035 sc->sc_flags |= SC_OP_SCANNING;
2011 del_timer_sync(&common->ani.timer);
2012 cancel_work_sync(&sc->paprd_work);
2013 cancel_work_sync(&sc->hw_check_work);
2014 cancel_delayed_work_sync(&sc->tx_complete_work);
2015 mutex_unlock(&sc->mutex); 2036 mutex_unlock(&sc->mutex);
2016} 2037}
2017 2038
@@ -2023,15 +2044,10 @@ static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
2023{ 2044{
2024 struct ath_wiphy *aphy = hw->priv; 2045 struct ath_wiphy *aphy = hw->priv;
2025 struct ath_softc *sc = aphy->sc; 2046 struct ath_softc *sc = aphy->sc;
2026 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2027 2047
2028 mutex_lock(&sc->mutex); 2048 mutex_lock(&sc->mutex);
2029 aphy->state = ATH_WIPHY_ACTIVE; 2049 aphy->state = ATH_WIPHY_ACTIVE;
2030 sc->sc_flags &= ~SC_OP_SCANNING; 2050 sc->sc_flags &= ~SC_OP_SCANNING;
2031 sc->sc_flags |= SC_OP_FULL_RESET;
2032 ath_start_ani(common);
2033 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
2034 ath_beacon_config(sc, NULL);
2035 mutex_unlock(&sc->mutex); 2051 mutex_unlock(&sc->mutex);
2036} 2052}
2037 2053
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index da0cfe90c38a..a3fc987ebab0 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1140,6 +1140,11 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1140 if (flush) 1140 if (flush)
1141 goto requeue; 1141 goto requeue;
1142 1142
1143 retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
1144 rxs, &decrypt_error);
1145 if (retval)
1146 goto requeue;
1147
1143 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; 1148 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
1144 if (rs.rs_tstamp > tsf_lower && 1149 if (rs.rs_tstamp > tsf_lower &&
1145 unlikely(rs.rs_tstamp - tsf_lower > 0x10000000)) 1150 unlikely(rs.rs_tstamp - tsf_lower > 0x10000000))
@@ -1149,11 +1154,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1149 unlikely(tsf_lower - rs.rs_tstamp > 0x10000000)) 1154 unlikely(tsf_lower - rs.rs_tstamp > 0x10000000))
1150 rxs->mactime += 0x100000000ULL; 1155 rxs->mactime += 0x100000000ULL;
1151 1156
1152 retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
1153 rxs, &decrypt_error);
1154 if (retval)
1155 goto requeue;
1156
1157 /* Ensure we always have an skb to requeue once we are done 1157 /* Ensure we always have an skb to requeue once we are done
1158 * processing the current buffer's skb */ 1158 * processing the current buffer's skb */
1159 requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC); 1159 requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC);
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 501b72821b4d..4dda14e36227 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -120,26 +120,14 @@ static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid)
120 list_add_tail(&ac->list, &txq->axq_acq); 120 list_add_tail(&ac->list, &txq->axq_acq);
121} 121}
122 122
123static void ath_tx_pause_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
124{
125 struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum];
126
127 spin_lock_bh(&txq->axq_lock);
128 tid->paused++;
129 spin_unlock_bh(&txq->axq_lock);
130}
131
132static void ath_tx_resume_tid(struct ath_softc *sc, struct ath_atx_tid *tid) 123static void ath_tx_resume_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
133{ 124{
134 struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum]; 125 struct ath_txq *txq = &sc->tx.txq[tid->ac->qnum];
135 126
136 BUG_ON(tid->paused <= 0); 127 WARN_ON(!tid->paused);
137 spin_lock_bh(&txq->axq_lock);
138
139 tid->paused--;
140 128
141 if (tid->paused > 0) 129 spin_lock_bh(&txq->axq_lock);
142 goto unlock; 130 tid->paused = false;
143 131
144 if (list_empty(&tid->buf_q)) 132 if (list_empty(&tid->buf_q))
145 goto unlock; 133 goto unlock;
@@ -157,15 +145,10 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
157 struct list_head bf_head; 145 struct list_head bf_head;
158 INIT_LIST_HEAD(&bf_head); 146 INIT_LIST_HEAD(&bf_head);
159 147
160 BUG_ON(tid->paused <= 0); 148 WARN_ON(!tid->paused);
161 spin_lock_bh(&txq->axq_lock);
162 149
163 tid->paused--; 150 spin_lock_bh(&txq->axq_lock);
164 151 tid->paused = false;
165 if (tid->paused > 0) {
166 spin_unlock_bh(&txq->axq_lock);
167 return;
168 }
169 152
170 while (!list_empty(&tid->buf_q)) { 153 while (!list_empty(&tid->buf_q)) {
171 bf = list_first_entry(&tid->buf_q, struct ath_buf, list); 154 bf = list_first_entry(&tid->buf_q, struct ath_buf, list);
@@ -811,7 +794,7 @@ void ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
811 an = (struct ath_node *)sta->drv_priv; 794 an = (struct ath_node *)sta->drv_priv;
812 txtid = ATH_AN_2_TID(an, tid); 795 txtid = ATH_AN_2_TID(an, tid);
813 txtid->state |= AGGR_ADDBA_PROGRESS; 796 txtid->state |= AGGR_ADDBA_PROGRESS;
814 ath_tx_pause_tid(sc, txtid); 797 txtid->paused = true;
815 *ssn = txtid->seq_start; 798 *ssn = txtid->seq_start;
816} 799}
817 800
@@ -835,10 +818,9 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
835 return; 818 return;
836 } 819 }
837 820
838 ath_tx_pause_tid(sc, txtid);
839
840 /* drop all software retried frames and mark this TID */ 821 /* drop all software retried frames and mark this TID */
841 spin_lock_bh(&txq->axq_lock); 822 spin_lock_bh(&txq->axq_lock);
823 txtid->paused = true;
842 while (!list_empty(&txtid->buf_q)) { 824 while (!list_empty(&txtid->buf_q)) {
843 bf = list_first_entry(&txtid->buf_q, struct ath_buf, list); 825 bf = list_first_entry(&txtid->buf_q, struct ath_buf, list);
844 if (!bf_isretried(bf)) { 826 if (!bf_isretried(bf)) {
@@ -1181,7 +1163,7 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
1181 "Failed to stop TX DMA. Resetting hardware!\n"); 1163 "Failed to stop TX DMA. Resetting hardware!\n");
1182 1164
1183 spin_lock_bh(&sc->sc_resetlock); 1165 spin_lock_bh(&sc->sc_resetlock);
1184 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false); 1166 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
1185 if (r) 1167 if (r)
1186 ath_print(common, ATH_DBG_FATAL, 1168 ath_print(common, ATH_DBG_FATAL,
1187 "Unable to reset hardware; reset status %d\n", 1169 "Unable to reset hardware; reset status %d\n",
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index c2746fc7f2be..3b632161c106 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -42,7 +42,6 @@
42#include <linux/moduleparam.h> 42#include <linux/moduleparam.h>
43#include <linux/device.h> 43#include <linux/device.h>
44 44
45#include <pcmcia/cs_types.h>
46#include <pcmcia/cs.h> 45#include <pcmcia/cs.h>
47#include <pcmcia/cistpl.h> 46#include <pcmcia/cistpl.h>
48#include <pcmcia/cisreg.h> 47#include <pcmcia/cisreg.h>
@@ -191,25 +190,23 @@ static int atmel_config_check(struct pcmcia_device *p_dev,
191 p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 190 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
192 191
193 /* IO window settings */ 192 /* IO window settings */
194 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 193 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
195 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 194 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
196 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 195 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
197 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 196 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
198 if (!(io->flags & CISTPL_IO_8BIT)) 197 p_dev->resource[0]->flags |=
199 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 198 pcmcia_io_cfg_data_width(io->flags);
200 if (!(io->flags & CISTPL_IO_16BIT)) 199 p_dev->resource[0]->start = io->win[0].base;
201 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 200 p_dev->resource[0]->end = io->win[0].len;
202 p_dev->io.BasePort1 = io->win[0].base;
203 p_dev->io.NumPorts1 = io->win[0].len;
204 if (io->nwin > 1) { 201 if (io->nwin > 1) {
205 p_dev->io.Attributes2 = p_dev->io.Attributes1; 202 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
206 p_dev->io.BasePort2 = io->win[1].base; 203 p_dev->resource[1]->start = io->win[1].base;
207 p_dev->io.NumPorts2 = io->win[1].len; 204 p_dev->resource[1]->end = io->win[1].len;
208 } 205 }
209 } 206 }
210 207
211 /* This reserves IO space but doesn't actually enable it */ 208 /* This reserves IO space but doesn't actually enable it */
212 return pcmcia_request_io(p_dev, &p_dev->io); 209 return pcmcia_request_io(p_dev);
213} 210}
214 211
215static int atmel_config(struct pcmcia_device *link) 212static int atmel_config(struct pcmcia_device *link)
@@ -254,7 +251,7 @@ static int atmel_config(struct pcmcia_device *link)
254 251
255 ((local_info_t*)link->priv)->eth_dev = 252 ((local_info_t*)link->priv)->eth_dev =
256 init_atmel_card(link->irq, 253 init_atmel_card(link->irq,
257 link->io.BasePort1, 254 link->resource[0]->start,
258 did ? did->driver_info : ATMEL_FW_TYPE_NONE, 255 did ? did->driver_info : ATMEL_FW_TYPE_NONE,
259 &link->dev, 256 &link->dev,
260 card_present, 257 card_present,
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c
index 0e99b634267c..dfbc41d431ff 100644
--- a/drivers/net/wireless/b43/pcmcia.c
+++ b/drivers/net/wireless/b43/pcmcia.c
@@ -26,7 +26,6 @@
26#include <linux/ssb/ssb.h> 26#include <linux/ssb/ssb.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28 28
29#include <pcmcia/cs_types.h>
30#include <pcmcia/cs.h> 29#include <pcmcia/cs.h>
31#include <pcmcia/cistpl.h> 30#include <pcmcia/cistpl.h>
32#include <pcmcia/ciscode.h> 31#include <pcmcia/ciscode.h>
@@ -65,7 +64,6 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
65{ 64{
66 struct ssb_bus *ssb; 65 struct ssb_bus *ssb;
67 win_req_t win; 66 win_req_t win;
68 memreq_t mem;
69 int err = -ENOMEM; 67 int err = -ENOMEM;
70 int res = 0; 68 int res = 0;
71 69
@@ -78,12 +76,7 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
78 dev->conf.Attributes = CONF_ENABLE_IRQ; 76 dev->conf.Attributes = CONF_ENABLE_IRQ;
79 dev->conf.IntType = INT_MEMORY_AND_IO; 77 dev->conf.IntType = INT_MEMORY_AND_IO;
80 78
81 dev->io.BasePort2 = 0; 79 win.Attributes = WIN_ENABLE | WIN_DATA_WIDTH_16 |
82 dev->io.NumPorts2 = 0;
83 dev->io.Attributes2 = 0;
84
85 win.Attributes = WIN_ADDR_SPACE_MEM | WIN_MEMORY_TYPE_CM |
86 WIN_ENABLE | WIN_DATA_WIDTH_16 |
87 WIN_USE_WAIT; 80 WIN_USE_WAIT;
88 win.Base = 0; 81 win.Base = 0;
89 win.Size = SSB_CORE_SIZE; 82 win.Size = SSB_CORE_SIZE;
@@ -92,9 +85,7 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
92 if (res != 0) 85 if (res != 0)
93 goto err_kfree_ssb; 86 goto err_kfree_ssb;
94 87
95 mem.CardOffset = 0; 88 res = pcmcia_map_mem_page(dev, dev->win, 0);
96 mem.Page = 0;
97 res = pcmcia_map_mem_page(dev, dev->win, &mem);
98 if (res != 0) 89 if (res != 0)
99 goto err_disable; 90 goto err_disable;
100 91
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 29b31a694b59..ba54d1b04d22 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -12,7 +12,6 @@
12#include <linux/wireless.h> 12#include <linux/wireless.h>
13#include <net/iw_handler.h> 13#include <net/iw_handler.h>
14 14
15#include <pcmcia/cs_types.h>
16#include <pcmcia/cs.h> 15#include <pcmcia/cs.h>
17#include <pcmcia/cistpl.h> 16#include <pcmcia/cistpl.h>
18#include <pcmcia/cisreg.h> 17#include <pcmcia/cisreg.h>
@@ -23,7 +22,7 @@
23#include "hostap_wlan.h" 22#include "hostap_wlan.h"
24 23
25 24
26static dev_info_t dev_info = "hostap_cs"; 25static char *dev_info = "hostap_cs";
27 26
28MODULE_AUTHOR("Jouni Malinen"); 27MODULE_AUTHOR("Jouni Malinen");
29MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN " 28MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
@@ -225,27 +224,18 @@ static int prism2_pccard_card_present(local_info_t *local)
225static void sandisk_set_iobase(local_info_t *local) 224static void sandisk_set_iobase(local_info_t *local)
226{ 225{
227 int res; 226 int res;
228 conf_reg_t reg;
229 struct hostap_cs_priv *hw_priv = local->hw_priv; 227 struct hostap_cs_priv *hw_priv = local->hw_priv;
230 228
231 reg.Function = 0; 229 res = pcmcia_write_config_byte(hw_priv->link, 0x10,
232 reg.Action = CS_WRITE; 230 hw_priv->link->resource[0]->start & 0x00ff);
233 reg.Offset = 0x10; /* 0x3f0 IO base 1 */
234 reg.Value = hw_priv->link->io.BasePort1 & 0x00ff;
235 res = pcmcia_access_configuration_register(hw_priv->link,
236 &reg);
237 if (res != 0) { 231 if (res != 0) {
238 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" 232 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
239 " res=%d\n", res); 233 " res=%d\n", res);
240 } 234 }
241 udelay(10); 235 udelay(10);
242 236
243 reg.Function = 0; 237 res = pcmcia_write_config_byte(hw_priv->link, 0x12,
244 reg.Action = CS_WRITE; 238 (hw_priv->link->resource[0]->start >> 8) & 0x00ff);
245 reg.Offset = 0x12; /* 0x3f2 IO base 2 */
246 reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8;
247 res = pcmcia_access_configuration_register(hw_priv->link,
248 &reg);
249 if (res != 0) { 239 if (res != 0) {
250 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" 240 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
251 " res=%d\n", res); 241 " res=%d\n", res);
@@ -271,12 +261,11 @@ static void sandisk_write_hcr(local_info_t *local, int hcr)
271static int sandisk_enable_wireless(struct net_device *dev) 261static int sandisk_enable_wireless(struct net_device *dev)
272{ 262{
273 int res, ret = 0; 263 int res, ret = 0;
274 conf_reg_t reg;
275 struct hostap_interface *iface = netdev_priv(dev); 264 struct hostap_interface *iface = netdev_priv(dev);
276 local_info_t *local = iface->local; 265 local_info_t *local = iface->local;
277 struct hostap_cs_priv *hw_priv = local->hw_priv; 266 struct hostap_cs_priv *hw_priv = local->hw_priv;
278 267
279 if (hw_priv->link->io.NumPorts1 < 0x42) { 268 if (resource_size(hw_priv->link->resource[0]) < 0x42) {
280 /* Not enough ports to be SanDisk multi-function card */ 269 /* Not enough ports to be SanDisk multi-function card */
281 ret = -ENODEV; 270 ret = -ENODEV;
282 goto done; 271 goto done;
@@ -298,12 +287,8 @@ static int sandisk_enable_wireless(struct net_device *dev)
298 " - using vendor-specific initialization\n", dev->name); 287 " - using vendor-specific initialization\n", dev->name);
299 hw_priv->sandisk_connectplus = 1; 288 hw_priv->sandisk_connectplus = 1;
300 289
301 reg.Function = 0; 290 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
302 reg.Action = CS_WRITE; 291 COR_SOFT_RESET);
303 reg.Offset = CISREG_COR;
304 reg.Value = COR_SOFT_RESET;
305 res = pcmcia_access_configuration_register(hw_priv->link,
306 &reg);
307 if (res != 0) { 292 if (res != 0) {
308 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 293 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
309 dev->name, res); 294 dev->name, res);
@@ -311,16 +296,13 @@ static int sandisk_enable_wireless(struct net_device *dev)
311 } 296 }
312 mdelay(5); 297 mdelay(5);
313 298
314 reg.Function = 0;
315 reg.Action = CS_WRITE;
316 reg.Offset = CISREG_COR;
317 /* 299 /*
318 * Do not enable interrupts here to avoid some bogus events. Interrupts 300 * Do not enable interrupts here to avoid some bogus events. Interrupts
319 * will be enabled during the first cor_sreset call. 301 * will be enabled during the first cor_sreset call.
320 */ 302 */
321 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; 303 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
322 res = pcmcia_access_configuration_register(hw_priv->link, 304 (COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE |
323 &reg); 305 COR_FUNC_ENA));
324 if (res != 0) { 306 if (res != 0) {
325 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 307 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
326 dev->name, res); 308 dev->name, res);
@@ -343,30 +325,23 @@ done:
343static void prism2_pccard_cor_sreset(local_info_t *local) 325static void prism2_pccard_cor_sreset(local_info_t *local)
344{ 326{
345 int res; 327 int res;
346 conf_reg_t reg; 328 u8 val;
347 struct hostap_cs_priv *hw_priv = local->hw_priv; 329 struct hostap_cs_priv *hw_priv = local->hw_priv;
348 330
349 if (!prism2_pccard_card_present(local)) 331 if (!prism2_pccard_card_present(local))
350 return; 332 return;
351 333
352 reg.Function = 0; 334 res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &val);
353 reg.Action = CS_READ;
354 reg.Offset = CISREG_COR;
355 reg.Value = 0;
356 res = pcmcia_access_configuration_register(hw_priv->link,
357 &reg);
358 if (res != 0) { 335 if (res != 0) {
359 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", 336 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
360 res); 337 res);
361 return; 338 return;
362 } 339 }
363 printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n", 340 printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
364 reg.Value); 341 val);
365 342
366 reg.Action = CS_WRITE; 343 val |= COR_SOFT_RESET;
367 reg.Value |= COR_SOFT_RESET; 344 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
368 res = pcmcia_access_configuration_register(hw_priv->link,
369 &reg);
370 if (res != 0) { 345 if (res != 0) {
371 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", 346 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
372 res); 347 res);
@@ -375,11 +350,10 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
375 350
376 mdelay(hw_priv->sandisk_connectplus ? 5 : 2); 351 mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
377 352
378 reg.Value &= ~COR_SOFT_RESET; 353 val &= ~COR_SOFT_RESET;
379 if (hw_priv->sandisk_connectplus) 354 if (hw_priv->sandisk_connectplus)
380 reg.Value |= COR_IREQ_ENA; 355 val |= COR_IREQ_ENA;
381 res = pcmcia_access_configuration_register(hw_priv->link, 356 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
382 &reg);
383 if (res != 0) { 357 if (res != 0) {
384 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", 358 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
385 res); 359 res);
@@ -396,8 +370,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
396static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) 370static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
397{ 371{
398 int res; 372 int res;
399 conf_reg_t reg; 373 u8 old_cor;
400 int old_cor;
401 struct hostap_cs_priv *hw_priv = local->hw_priv; 374 struct hostap_cs_priv *hw_priv = local->hw_priv;
402 375
403 if (!prism2_pccard_card_present(local)) 376 if (!prism2_pccard_card_present(local))
@@ -408,25 +381,17 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
408 return; 381 return;
409 } 382 }
410 383
411 reg.Function = 0; 384 res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &old_cor);
412 reg.Action = CS_READ;
413 reg.Offset = CISREG_COR;
414 reg.Value = 0;
415 res = pcmcia_access_configuration_register(hw_priv->link,
416 &reg);
417 if (res != 0) { 385 if (res != 0) {
418 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " 386 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
419 "(%d)\n", res); 387 "(%d)\n", res);
420 return; 388 return;
421 } 389 }
422 printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n", 390 printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
423 reg.Value); 391 old_cor);
424 old_cor = reg.Value;
425 392
426 reg.Action = CS_WRITE; 393 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
427 reg.Value |= COR_SOFT_RESET; 394 old_cor | COR_SOFT_RESET);
428 res = pcmcia_access_configuration_register(hw_priv->link,
429 &reg);
430 if (res != 0) { 395 if (res != 0) {
431 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " 396 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
432 "(%d)\n", res); 397 "(%d)\n", res);
@@ -436,11 +401,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
436 mdelay(10); 401 mdelay(10);
437 402
438 /* Setup Genesis mode */ 403 /* Setup Genesis mode */
439 reg.Action = CS_WRITE; 404 res = pcmcia_write_config_byte(hw_priv->link, CISREG_CCSR, hcr);
440 reg.Value = hcr;
441 reg.Offset = CISREG_CCSR;
442 res = pcmcia_access_configuration_register(hw_priv->link,
443 &reg);
444 if (res != 0) { 405 if (res != 0) {
445 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " 406 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
446 "(%d)\n", res); 407 "(%d)\n", res);
@@ -448,11 +409,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
448 } 409 }
449 mdelay(10); 410 mdelay(10);
450 411
451 reg.Action = CS_WRITE; 412 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
452 reg.Offset = CISREG_COR; 413 old_cor & ~COR_SOFT_RESET);
453 reg.Value = old_cor & ~COR_SOFT_RESET;
454 res = pcmcia_access_configuration_register(hw_priv->link,
455 &reg);
456 if (res != 0) { 414 if (res != 0) {
457 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " 415 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
458 "(%d)\n", res); 416 "(%d)\n", res);
@@ -561,30 +519,24 @@ static int prism2_config_check(struct pcmcia_device *p_dev,
561 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " 519 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
562 "dflt->io.nwin=%d\n", 520 "dflt->io.nwin=%d\n",
563 cfg->io.nwin, dflt->io.nwin); 521 cfg->io.nwin, dflt->io.nwin);
564 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 522 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
565 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 523 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
566 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 524 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
567 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 525 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
568 PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " 526 p_dev->resource[0]->flags |=
569 "io.base=0x%04x, len=%d\n", io->flags, 527 pcmcia_io_cfg_data_width(io->flags);
570 io->win[0].base, io->win[0].len); 528 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
571 if (!(io->flags & CISTPL_IO_8BIT)) 529 p_dev->resource[0]->start = io->win[0].base;
572 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 530 p_dev->resource[0]->end = io->win[0].len;
573 if (!(io->flags & CISTPL_IO_16BIT))
574 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
575 p_dev->io.IOAddrLines = io->flags &
576 CISTPL_IO_LINES_MASK;
577 p_dev->io.BasePort1 = io->win[0].base;
578 p_dev->io.NumPorts1 = io->win[0].len;
579 if (io->nwin > 1) { 531 if (io->nwin > 1) {
580 p_dev->io.Attributes2 = p_dev->io.Attributes1; 532 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
581 p_dev->io.BasePort2 = io->win[1].base; 533 p_dev->resource[1]->start = io->win[1].base;
582 p_dev->io.NumPorts2 = io->win[1].len; 534 p_dev->resource[1]->end = io->win[1].len;
583 } 535 }
584 } 536 }
585 537
586 /* This reserves IO space but doesn't actually enable it */ 538 /* This reserves IO space but doesn't actually enable it */
587 return pcmcia_request_io(p_dev, &p_dev->io); 539 return pcmcia_request_io(p_dev);
588} 540}
589 541
590static int prism2_config(struct pcmcia_device *link) 542static int prism2_config(struct pcmcia_device *link)
@@ -646,7 +598,7 @@ static int prism2_config(struct pcmcia_device *link)
646 goto failed_unlock; 598 goto failed_unlock;
647 599
648 dev->irq = link->irq; 600 dev->irq = link->irq;
649 dev->base_addr = link->io.BasePort1; 601 dev->base_addr = link->resource[0]->start;
650 602
651 spin_unlock_irqrestore(&local->irq_init_lock, flags); 603 spin_unlock_irqrestore(&local->irq_init_lock, flags);
652 604
@@ -658,12 +610,10 @@ static int prism2_config(struct pcmcia_device *link)
658 link->conf.Vpp % 10); 610 link->conf.Vpp % 10);
659 if (link->conf.Attributes & CONF_ENABLE_IRQ) 611 if (link->conf.Attributes & CONF_ENABLE_IRQ)
660 printk(", irq %d", link->irq); 612 printk(", irq %d", link->irq);
661 if (link->io.NumPorts1) 613 if (link->resource[0])
662 printk(", io 0x%04x-0x%04x", link->io.BasePort1, 614 printk(" & %pR", link->resource[0]);
663 link->io.BasePort1+link->io.NumPorts1-1); 615 if (link->resource[1])
664 if (link->io.NumPorts2) 616 printk(" & %pR", link->resource[1]);
665 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
666 link->io.BasePort2+link->io.NumPorts2-1);
667 printk("\n"); 617 printk("\n");
668 618
669 local->shutdown = 0; 619 local->shutdown = 0;
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index c24c5efeae1f..16bbfa3189a5 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -1924,6 +1924,10 @@ static int ipw2100_net_init(struct net_device *dev)
1924 bg_band->channels = 1924 bg_band->channels =
1925 kzalloc(geo->bg_channels * 1925 kzalloc(geo->bg_channels *
1926 sizeof(struct ieee80211_channel), GFP_KERNEL); 1926 sizeof(struct ieee80211_channel), GFP_KERNEL);
1927 if (!bg_band->channels) {
1928 ipw2100_down(priv);
1929 return -ENOMEM;
1930 }
1927 /* translate geo->bg to bg_band.channels */ 1931 /* translate geo->bg to bg_band.channels */
1928 for (i = 0; i < geo->bg_channels; i++) { 1932 for (i = 0; i < geo->bg_channels; i++) {
1929 bg_band->channels[i].band = IEEE80211_BAND_2GHZ; 1933 bg_band->channels[i].band = IEEE80211_BAND_2GHZ;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
index f052c6d09b37..d706b8afbe5a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c
@@ -980,7 +980,7 @@ ssize_t iwl_ucode_bt_stats_read(struct file *file,
980 le32_to_cpu(bt->lo_priority_tx_req_cnt), 980 le32_to_cpu(bt->lo_priority_tx_req_cnt),
981 accum_bt->lo_priority_tx_req_cnt); 981 accum_bt->lo_priority_tx_req_cnt);
982 pos += scnprintf(buf + pos, bufsz - pos, 982 pos += scnprintf(buf + pos, bufsz - pos,
983 "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n", 983 "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
984 le32_to_cpu(bt->lo_priority_tx_denied_cnt), 984 le32_to_cpu(bt->lo_priority_tx_denied_cnt),
985 accum_bt->lo_priority_tx_denied_cnt); 985 accum_bt->lo_priority_tx_denied_cnt);
986 pos += scnprintf(buf + pos, bufsz - pos, 986 pos += scnprintf(buf + pos, bufsz - pos,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index a1b6d202d57c..9dd9e64c2b0b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -1429,7 +1429,7 @@ int iwlagn_manage_ibss_station(struct iwl_priv *priv,
1429void iwl_free_tfds_in_queue(struct iwl_priv *priv, 1429void iwl_free_tfds_in_queue(struct iwl_priv *priv,
1430 int sta_id, int tid, int freed) 1430 int sta_id, int tid, int freed)
1431{ 1431{
1432 WARN_ON(!spin_is_locked(&priv->sta_lock)); 1432 lockdep_assert_held(&priv->sta_lock);
1433 1433
1434 if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed) 1434 if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed)
1435 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 1435 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 35c86d22b14b..23e5c42e7d7e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -300,8 +300,9 @@ static int rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
300 struct ieee80211_sta *sta) 300 struct ieee80211_sta *sta)
301{ 301{
302 int ret = -EAGAIN; 302 int ret = -EAGAIN;
303 u32 load = rs_tl_get_load(lq_data, tid);
303 304
304 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { 305 if (load > IWL_AGG_LOAD_THRESHOLD) {
305 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", 306 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n",
306 sta->addr, tid); 307 sta->addr, tid);
307 ret = ieee80211_start_tx_ba_session(sta, tid); 308 ret = ieee80211_start_tx_ba_session(sta, tid);
@@ -311,12 +312,14 @@ static int rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
311 * this might be cause by reloading firmware 312 * this might be cause by reloading firmware
312 * stop the tx ba session here 313 * stop the tx ba session here
313 */ 314 */
314 IWL_DEBUG_HT(priv, "Fail start Tx agg on tid: %d\n", 315 IWL_ERR(priv, "Fail start Tx agg on tid: %d\n",
315 tid); 316 tid);
316 ieee80211_stop_tx_ba_session(sta, tid); 317 ieee80211_stop_tx_ba_session(sta, tid);
317 } 318 }
318 } else 319 } else {
319 IWL_ERR(priv, "Fail finding valid aggregation tid: %d\n", tid); 320 IWL_ERR(priv, "Aggregation not enabled for tid %d "
321 "because load = %u\n", tid, load);
322 }
320 return ret; 323 return ret;
321} 324}
322 325
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 55a1b31fd09a..d04502d54df3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -1117,7 +1117,7 @@ int iwlagn_txq_check_empty(struct iwl_priv *priv,
1117 u8 *addr = priv->stations[sta_id].sta.sta.addr; 1117 u8 *addr = priv->stations[sta_id].sta.sta.addr;
1118 struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; 1118 struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid];
1119 1119
1120 WARN_ON(!spin_is_locked(&priv->sta_lock)); 1120 lockdep_assert_held(&priv->sta_lock);
1121 1121
1122 switch (priv->stations[sta_id].tid[tid].agg.state) { 1122 switch (priv->stations[sta_id].tid[tid].agg.state) {
1123 case IWL_EMPTYING_HW_QUEUE_DELBA: 1123 case IWL_EMPTYING_HW_QUEUE_DELBA:
@@ -1331,7 +1331,14 @@ void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
1331 tid = ba_resp->tid; 1331 tid = ba_resp->tid;
1332 agg = &priv->stations[sta_id].tid[tid].agg; 1332 agg = &priv->stations[sta_id].tid[tid].agg;
1333 if (unlikely(agg->txq_id != scd_flow)) { 1333 if (unlikely(agg->txq_id != scd_flow)) {
1334 IWL_ERR(priv, "BA scd_flow %d does not match txq_id %d\n", 1334 /*
1335 * FIXME: this is a uCode bug which need to be addressed,
1336 * log the information and return for now!
1337 * since it is possible happen very often and in order
1338 * not to fill the syslog, don't enable the logging by default
1339 */
1340 IWL_DEBUG_TX_REPLY(priv,
1341 "BA scd_flow %d does not match txq_id %d\n",
1335 scd_flow, agg->txq_id); 1342 scd_flow, agg->txq_id);
1336 return; 1343 return;
1337 } 1344 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 8024d44ce4bb..8ccb6d205b6d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -2000,6 +2000,7 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2000 struct ieee80211_vif *vif) 2000 struct ieee80211_vif *vif)
2001{ 2001{
2002 struct iwl_priv *priv = hw->priv; 2002 struct iwl_priv *priv = hw->priv;
2003 bool scan_completed = false;
2003 2004
2004 IWL_DEBUG_MAC80211(priv, "enter\n"); 2005 IWL_DEBUG_MAC80211(priv, "enter\n");
2005 2006
@@ -2013,7 +2014,7 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2013 if (priv->vif == vif) { 2014 if (priv->vif == vif) {
2014 priv->vif = NULL; 2015 priv->vif = NULL;
2015 if (priv->scan_vif == vif) { 2016 if (priv->scan_vif == vif) {
2016 ieee80211_scan_completed(priv->hw, true); 2017 scan_completed = true;
2017 priv->scan_vif = NULL; 2018 priv->scan_vif = NULL;
2018 priv->scan_request = NULL; 2019 priv->scan_request = NULL;
2019 } 2020 }
@@ -2021,6 +2022,9 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2021 } 2022 }
2022 mutex_unlock(&priv->mutex); 2023 mutex_unlock(&priv->mutex);
2023 2024
2025 if (scan_completed)
2026 ieee80211_scan_completed(priv->hw, true);
2027
2024 IWL_DEBUG_MAC80211(priv, "leave\n"); 2028 IWL_DEBUG_MAC80211(priv, "leave\n");
2025 2029
2026} 2030}
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 5c2bcef5df0c..0b961a353ff6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -71,7 +71,7 @@ do { \
71#define IWL_DEBUG(__priv, level, fmt, args...) 71#define IWL_DEBUG(__priv, level, fmt, args...)
72#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...) 72#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...)
73static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level, 73static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
74 void *p, u32 len) 74 const void *p, u32 len)
75{} 75{}
76#endif /* CONFIG_IWLWIFI_DEBUG */ 76#endif /* CONFIG_IWLWIFI_DEBUG */
77 77
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
index ae7319bb3a99..4cf864c664ee 100644
--- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h
+++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
@@ -193,7 +193,7 @@ TRACE_EVENT(iwlwifi_dev_tx,
193 __entry->framelen = buf0_len + buf1_len; 193 __entry->framelen = buf0_len + buf1_len;
194 memcpy(__get_dynamic_array(tfd), tfd, tfdlen); 194 memcpy(__get_dynamic_array(tfd), tfd, tfdlen);
195 memcpy(__get_dynamic_array(buf0), buf0, buf0_len); 195 memcpy(__get_dynamic_array(buf0), buf0, buf0_len);
196 memcpy(__get_dynamic_array(buf1), buf1, buf0_len); 196 memcpy(__get_dynamic_array(buf1), buf1, buf1_len);
197 ), 197 ),
198 TP_printk("[%p] TX %.2x (%zu bytes)", 198 TP_printk("[%p] TX %.2x (%zu bytes)",
199 __entry->priv, 199 __entry->priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index b0c6b0473901..a4b3663a262f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -298,7 +298,7 @@ EXPORT_SYMBOL(iwl_init_scan_params);
298 298
299static int iwl_scan_initiate(struct iwl_priv *priv, struct ieee80211_vif *vif) 299static int iwl_scan_initiate(struct iwl_priv *priv, struct ieee80211_vif *vif)
300{ 300{
301 WARN_ON(!mutex_is_locked(&priv->mutex)); 301 lockdep_assert_held(&priv->mutex);
302 302
303 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 303 IWL_DEBUG_INFO(priv, "Starting scan...\n");
304 set_bit(STATUS_SCANNING, &priv->status); 304 set_bit(STATUS_SCANNING, &priv->status);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 9511f03f07e0..7e0829be5e78 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -773,7 +773,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
773 773
774int iwl_restore_default_wep_keys(struct iwl_priv *priv) 774int iwl_restore_default_wep_keys(struct iwl_priv *priv)
775{ 775{
776 WARN_ON(!mutex_is_locked(&priv->mutex)); 776 lockdep_assert_held(&priv->mutex);
777 777
778 return iwl_send_static_wepkey_cmd(priv, 0); 778 return iwl_send_static_wepkey_cmd(priv, 0);
779} 779}
@@ -784,7 +784,7 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
784{ 784{
785 int ret; 785 int ret;
786 786
787 WARN_ON(!mutex_is_locked(&priv->mutex)); 787 lockdep_assert_held(&priv->mutex);
788 788
789 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", 789 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
790 keyconf->keyidx); 790 keyconf->keyidx);
@@ -808,7 +808,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
808{ 808{
809 int ret; 809 int ret;
810 810
811 WARN_ON(!mutex_is_locked(&priv->mutex)); 811 lockdep_assert_held(&priv->mutex);
812 812
813 if (keyconf->keylen != WEP_KEY_LEN_128 && 813 if (keyconf->keylen != WEP_KEY_LEN_128 &&
814 keyconf->keylen != WEP_KEY_LEN_64) { 814 keyconf->keylen != WEP_KEY_LEN_64) {
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 25f902760980..8e9fbfd804b6 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -257,6 +257,29 @@ static int lbs_add_supported_rates_tlv(u8 *tlv)
257 return sizeof(rate_tlv->header) + i; 257 return sizeof(rate_tlv->header) + i;
258} 258}
259 259
260/* Add common rates from a TLV and return the new end of the TLV */
261static u8 *
262add_ie_rates(u8 *tlv, const u8 *ie, int *nrates)
263{
264 int hw, ap, ap_max = ie[1];
265 u8 hw_rate;
266
267 /* Advance past IE header */
268 ie += 2;
269
270 lbs_deb_hex(LBS_DEB_ASSOC, "AP IE Rates", (u8 *) ie, ap_max);
271
272 for (hw = 0; hw < ARRAY_SIZE(lbs_rates); hw++) {
273 hw_rate = lbs_rates[hw].bitrate / 5;
274 for (ap = 0; ap < ap_max; ap++) {
275 if (hw_rate == (ie[ap] & 0x7f)) {
276 *tlv++ = ie[ap];
277 *nrates = *nrates + 1;
278 }
279 }
280 }
281 return tlv;
282}
260 283
261/* 284/*
262 * Adds a TLV with all rates the hardware *and* BSS supports. 285 * Adds a TLV with all rates the hardware *and* BSS supports.
@@ -264,8 +287,11 @@ static int lbs_add_supported_rates_tlv(u8 *tlv)
264static int lbs_add_common_rates_tlv(u8 *tlv, struct cfg80211_bss *bss) 287static int lbs_add_common_rates_tlv(u8 *tlv, struct cfg80211_bss *bss)
265{ 288{
266 struct mrvl_ie_rates_param_set *rate_tlv = (void *)tlv; 289 struct mrvl_ie_rates_param_set *rate_tlv = (void *)tlv;
267 const u8 *rates_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SUPP_RATES); 290 const u8 *rates_eid, *ext_rates_eid;
268 int n; 291 int n = 0;
292
293 rates_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SUPP_RATES);
294 ext_rates_eid = ieee80211_bss_get_ie(bss, WLAN_EID_EXT_SUPP_RATES);
269 295
270 /* 296 /*
271 * 01 00 TLV_TYPE_RATES 297 * 01 00 TLV_TYPE_RATES
@@ -275,26 +301,21 @@ static int lbs_add_common_rates_tlv(u8 *tlv, struct cfg80211_bss *bss)
275 rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES); 301 rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES);
276 tlv += sizeof(rate_tlv->header); 302 tlv += sizeof(rate_tlv->header);
277 303
278 if (!rates_eid) { 304 /* Add basic rates */
305 if (rates_eid) {
306 tlv = add_ie_rates(tlv, rates_eid, &n);
307
308 /* Add extended rates, if any */
309 if (ext_rates_eid)
310 tlv = add_ie_rates(tlv, ext_rates_eid, &n);
311 } else {
312 lbs_deb_assoc("assoc: bss had no basic rate IE\n");
279 /* Fallback: add basic 802.11b rates */ 313 /* Fallback: add basic 802.11b rates */
280 *tlv++ = 0x82; 314 *tlv++ = 0x82;
281 *tlv++ = 0x84; 315 *tlv++ = 0x84;
282 *tlv++ = 0x8b; 316 *tlv++ = 0x8b;
283 *tlv++ = 0x96; 317 *tlv++ = 0x96;
284 n = 4; 318 n = 4;
285 } else {
286 int hw, ap;
287 u8 ap_max = rates_eid[1];
288 n = 0;
289 for (hw = 0; hw < ARRAY_SIZE(lbs_rates); hw++) {
290 u8 hw_rate = lbs_rates[hw].bitrate / 5;
291 for (ap = 0; ap < ap_max; ap++) {
292 if (hw_rate == (rates_eid[ap+2] & 0x7f)) {
293 *tlv++ = rates_eid[ap+2];
294 n++;
295 }
296 }
297 }
298 } 319 }
299 320
300 rate_tlv->header.len = cpu_to_le16(n); 321 rate_tlv->header.len = cpu_to_le16(n);
@@ -465,7 +486,15 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy,
465 lbs_deb_enter(LBS_DEB_CFG80211); 486 lbs_deb_enter(LBS_DEB_CFG80211);
466 487
467 bsssize = get_unaligned_le16(&scanresp->bssdescriptsize); 488 bsssize = get_unaligned_le16(&scanresp->bssdescriptsize);
468 nr_sets = le16_to_cpu(resp->size); 489 nr_sets = le16_to_cpu(scanresp->nr_sets);
490
491 lbs_deb_scan("scan response: %d BSSs (%d bytes); resp size %d bytes\n",
492 nr_sets, bsssize, le16_to_cpu(resp->size));
493
494 if (nr_sets == 0) {
495 ret = 0;
496 goto done;
497 }
469 498
470 /* 499 /*
471 * The general layout of the scan response is described in chapter 500 * The general layout of the scan response is described in chapter
@@ -670,8 +699,13 @@ static void lbs_scan_worker(struct work_struct *work)
670 699
671 if (priv->scan_channel >= priv->scan_req->n_channels) { 700 if (priv->scan_channel >= priv->scan_req->n_channels) {
672 /* Mark scan done */ 701 /* Mark scan done */
673 cfg80211_scan_done(priv->scan_req, false); 702 if (priv->internal_scan)
703 kfree(priv->scan_req);
704 else
705 cfg80211_scan_done(priv->scan_req, false);
706
674 priv->scan_req = NULL; 707 priv->scan_req = NULL;
708 priv->last_scan = jiffies;
675 } 709 }
676 710
677 /* Restart network */ 711 /* Restart network */
@@ -682,10 +716,33 @@ static void lbs_scan_worker(struct work_struct *work)
682 716
683 kfree(scan_cmd); 717 kfree(scan_cmd);
684 718
719 /* Wake up anything waiting on scan completion */
720 if (priv->scan_req == NULL) {
721 lbs_deb_scan("scan: waking up waiters\n");
722 wake_up_all(&priv->scan_q);
723 }
724
685 out_no_scan_cmd: 725 out_no_scan_cmd:
686 lbs_deb_leave(LBS_DEB_SCAN); 726 lbs_deb_leave(LBS_DEB_SCAN);
687} 727}
688 728
729static void _internal_start_scan(struct lbs_private *priv, bool internal,
730 struct cfg80211_scan_request *request)
731{
732 lbs_deb_enter(LBS_DEB_CFG80211);
733
734 lbs_deb_scan("scan: ssids %d, channels %d, ie_len %zd\n",
735 request->n_ssids, request->n_channels, request->ie_len);
736
737 priv->scan_channel = 0;
738 queue_delayed_work(priv->work_thread, &priv->scan_work,
739 msecs_to_jiffies(50));
740
741 priv->scan_req = request;
742 priv->internal_scan = internal;
743
744 lbs_deb_leave(LBS_DEB_CFG80211);
745}
689 746
690static int lbs_cfg_scan(struct wiphy *wiphy, 747static int lbs_cfg_scan(struct wiphy *wiphy,
691 struct net_device *dev, 748 struct net_device *dev,
@@ -702,18 +759,11 @@ static int lbs_cfg_scan(struct wiphy *wiphy,
702 goto out; 759 goto out;
703 } 760 }
704 761
705 lbs_deb_scan("scan: ssids %d, channels %d, ie_len %zd\n", 762 _internal_start_scan(priv, false, request);
706 request->n_ssids, request->n_channels, request->ie_len);
707
708 priv->scan_channel = 0;
709 queue_delayed_work(priv->work_thread, &priv->scan_work,
710 msecs_to_jiffies(50));
711 763
712 if (priv->surpriseremoved) 764 if (priv->surpriseremoved)
713 ret = -EIO; 765 ret = -EIO;
714 766
715 priv->scan_req = request;
716
717 out: 767 out:
718 lbs_deb_leave_args(LBS_DEB_CFG80211, "ret %d", ret); 768 lbs_deb_leave_args(LBS_DEB_CFG80211, "ret %d", ret);
719 return ret; 769 return ret;
@@ -1000,6 +1050,7 @@ static int lbs_associate(struct lbs_private *priv,
1000 int status; 1050 int status;
1001 int ret; 1051 int ret;
1002 u8 *pos = &(cmd->iebuf[0]); 1052 u8 *pos = &(cmd->iebuf[0]);
1053 u8 *tmp;
1003 1054
1004 lbs_deb_enter(LBS_DEB_CFG80211); 1055 lbs_deb_enter(LBS_DEB_CFG80211);
1005 1056
@@ -1044,7 +1095,9 @@ static int lbs_associate(struct lbs_private *priv,
1044 pos += lbs_add_cf_param_tlv(pos); 1095 pos += lbs_add_cf_param_tlv(pos);
1045 1096
1046 /* add rates TLV */ 1097 /* add rates TLV */
1098 tmp = pos + 4; /* skip Marvell IE header */
1047 pos += lbs_add_common_rates_tlv(pos, bss); 1099 pos += lbs_add_common_rates_tlv(pos, bss);
1100 lbs_deb_hex(LBS_DEB_ASSOC, "Common Rates", tmp, pos - tmp);
1048 1101
1049 /* add auth type TLV */ 1102 /* add auth type TLV */
1050 if (priv->fwrelease >= 0x09000000) 1103 if (priv->fwrelease >= 0x09000000)
@@ -1124,7 +1177,62 @@ done:
1124 return ret; 1177 return ret;
1125} 1178}
1126 1179
1180static struct cfg80211_scan_request *
1181_new_connect_scan_req(struct wiphy *wiphy, struct cfg80211_connect_params *sme)
1182{
1183 struct cfg80211_scan_request *creq = NULL;
1184 int i, n_channels = 0;
1185 enum ieee80211_band band;
1186
1187 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1188 if (wiphy->bands[band])
1189 n_channels += wiphy->bands[band]->n_channels;
1190 }
1191
1192 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
1193 n_channels * sizeof(void *),
1194 GFP_ATOMIC);
1195 if (!creq)
1196 return NULL;
1197
1198 /* SSIDs come after channels */
1199 creq->ssids = (void *)&creq->channels[n_channels];
1200 creq->n_channels = n_channels;
1201 creq->n_ssids = 1;
1202
1203 /* Scan all available channels */
1204 i = 0;
1205 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1206 int j;
1207
1208 if (!wiphy->bands[band])
1209 continue;
1210
1211 for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
1212 /* ignore disabled channels */
1213 if (wiphy->bands[band]->channels[j].flags &
1214 IEEE80211_CHAN_DISABLED)
1215 continue;
1216
1217 creq->channels[i] = &wiphy->bands[band]->channels[j];
1218 i++;
1219 }
1220 }
1221 if (i) {
1222 /* Set real number of channels specified in creq->channels[] */
1223 creq->n_channels = i;
1224
1225 /* Scan for the SSID we're going to connect to */
1226 memcpy(creq->ssids[0].ssid, sme->ssid, sme->ssid_len);
1227 creq->ssids[0].ssid_len = sme->ssid_len;
1228 } else {
1229 /* No channels found... */
1230 kfree(creq);
1231 creq = NULL;
1232 }
1127 1233
1234 return creq;
1235}
1128 1236
1129static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev, 1237static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
1130 struct cfg80211_connect_params *sme) 1238 struct cfg80211_connect_params *sme)
@@ -1136,37 +1244,43 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
1136 1244
1137 lbs_deb_enter(LBS_DEB_CFG80211); 1245 lbs_deb_enter(LBS_DEB_CFG80211);
1138 1246
1139 if (sme->bssid) { 1247 if (!sme->bssid) {
1140 bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, 1248 /* Run a scan if one isn't in-progress already and if the last
1141 sme->ssid, sme->ssid_len, 1249 * scan was done more than 2 seconds ago.
1142 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
1143 } else {
1144 /*
1145 * Here we have an impedance mismatch. The firmware command
1146 * CMD_802_11_ASSOCIATE always needs a BSSID, it cannot
1147 * connect otherwise. However, for the connect-API of
1148 * cfg80211 the bssid is purely optional. We don't get one,
1149 * except the user specifies one on the "iw" command line.
1150 *
1151 * If we don't got one, we could initiate a scan and look
1152 * for the best matching cfg80211_bss entry.
1153 *
1154 * Or, better yet, net/wireless/sme.c get's rewritten into
1155 * something more generally useful.
1156 */ 1250 */
1157 lbs_pr_err("TODO: no BSS specified\n"); 1251 if (priv->scan_req == NULL &&
1158 ret = -ENOTSUPP; 1252 time_after(jiffies, priv->last_scan + (2 * HZ))) {
1159 goto done; 1253 struct cfg80211_scan_request *creq;
1160 }
1161 1254
1255 creq = _new_connect_scan_req(wiphy, sme);
1256 if (!creq) {
1257 ret = -EINVAL;
1258 goto done;
1259 }
1260
1261 lbs_deb_assoc("assoc: scanning for compatible AP\n");
1262 _internal_start_scan(priv, true, creq);
1263 }
1264
1265 /* Wait for any in-progress scan to complete */
1266 lbs_deb_assoc("assoc: waiting for scan to complete\n");
1267 wait_event_interruptible_timeout(priv->scan_q,
1268 (priv->scan_req == NULL),
1269 (15 * HZ));
1270 lbs_deb_assoc("assoc: scanning competed\n");
1271 }
1162 1272
1273 /* Find the BSS we want using available scan results */
1274 bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid,
1275 sme->ssid, sme->ssid_len,
1276 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
1163 if (!bss) { 1277 if (!bss) {
1164 lbs_pr_err("assicate: bss %pM not in scan results\n", 1278 lbs_pr_err("assoc: bss %pM not in scan results\n",
1165 sme->bssid); 1279 sme->bssid);
1166 ret = -ENOENT; 1280 ret = -ENOENT;
1167 goto done; 1281 goto done;
1168 } 1282 }
1169 lbs_deb_assoc("trying %pM", sme->bssid); 1283 lbs_deb_assoc("trying %pM\n", bss->bssid);
1170 lbs_deb_assoc("cipher 0x%x, key index %d, key len %d\n", 1284 lbs_deb_assoc("cipher 0x%x, key index %d, key len %d\n",
1171 sme->crypto.cipher_group, 1285 sme->crypto.cipher_group,
1172 sme->key_idx, sme->key_len); 1286 sme->key_idx, sme->key_len);
@@ -1229,7 +1343,7 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
1229 lbs_set_radio(priv, preamble, 1); 1343 lbs_set_radio(priv, preamble, 1);
1230 1344
1231 /* Do the actual association */ 1345 /* Do the actual association */
1232 lbs_associate(priv, bss, sme); 1346 ret = lbs_associate(priv, bss, sme);
1233 1347
1234 done: 1348 done:
1235 if (bss) 1349 if (bss)
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 3c7e255e18c7..f062ed583901 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -161,6 +161,11 @@ struct lbs_private {
161 /** Scanning */ 161 /** Scanning */
162 struct delayed_work scan_work; 162 struct delayed_work scan_work;
163 int scan_channel; 163 int scan_channel;
164 /* Queue of things waiting for scan completion */
165 wait_queue_head_t scan_q;
166 /* Whether the scan was initiated internally and not by cfg80211 */
167 bool internal_scan;
168 unsigned long last_scan;
164}; 169};
165 170
166extern struct cmd_confirm_sleep confirm_sleep; 171extern struct cmd_confirm_sleep confirm_sleep;
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 08e4e3908003..9c298396be50 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -28,7 +28,6 @@
28#include <linux/firmware.h> 28#include <linux/firmware.h>
29#include <linux/netdevice.h> 29#include <linux/netdevice.h>
30 30
31#include <pcmcia/cs_types.h>
32#include <pcmcia/cs.h> 31#include <pcmcia/cs.h>
33#include <pcmcia/cistpl.h> 32#include <pcmcia/cistpl.h>
34#include <pcmcia/ds.h> 33#include <pcmcia/ds.h>
@@ -802,9 +801,9 @@ static int if_cs_ioprobe(struct pcmcia_device *p_dev,
802 unsigned int vcc, 801 unsigned int vcc,
803 void *priv_data) 802 void *priv_data)
804{ 803{
805 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 804 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
806 p_dev->io.BasePort1 = cfg->io.win[0].base; 805 p_dev->resource[0]->start = cfg->io.win[0].base;
807 p_dev->io.NumPorts1 = cfg->io.win[0].len; 806 p_dev->resource[0]->end = cfg->io.win[0].len;
808 807
809 /* Do we need to allocate an interrupt? */ 808 /* Do we need to allocate an interrupt? */
810 p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 809 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
@@ -816,7 +815,7 @@ static int if_cs_ioprobe(struct pcmcia_device *p_dev,
816 } 815 }
817 816
818 /* This reserves IO space but doesn't actually enable it */ 817 /* This reserves IO space but doesn't actually enable it */
819 return pcmcia_request_io(p_dev, &p_dev->io); 818 return pcmcia_request_io(p_dev);
820} 819}
821 820
822static int if_cs_probe(struct pcmcia_device *p_dev) 821static int if_cs_probe(struct pcmcia_device *p_dev)
@@ -854,7 +853,8 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
854 goto out1; 853 goto out1;
855 854
856 /* Initialize io access */ 855 /* Initialize io access */
857 card->iobase = ioport_map(p_dev->io.BasePort1, p_dev->io.NumPorts1); 856 card->iobase = ioport_map(p_dev->resource[0]->start,
857 resource_size(p_dev->resource[0]));
858 if (!card->iobase) { 858 if (!card->iobase) {
859 lbs_pr_err("error in ioport_map\n"); 859 lbs_pr_err("error in ioport_map\n");
860 ret = -EIO; 860 ret = -EIO;
@@ -873,9 +873,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
873 } 873 }
874 874
875 /* Finally, report what we've done */ 875 /* Finally, report what we've done */
876 lbs_deb_cs("irq %d, io 0x%04x-0x%04x\n", 876 lbs_deb_cs("irq %d, io %pR", p_dev->irq, p_dev->resource[0]);
877 p_dev->irq, p_dev->io.BasePort1,
878 p_dev->io.BasePort1 + p_dev->io.NumPorts1 - 1);
879 877
880 /* 878 /*
881 * Most of the libertas cards can do unaligned register access, but some 879 * Most of the libertas cards can do unaligned register access, but some
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 258967144b96..24958a86747b 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -719,6 +719,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
719 priv->deep_sleep_required = 0; 719 priv->deep_sleep_required = 0;
720 priv->wakeup_dev_required = 0; 720 priv->wakeup_dev_required = 0;
721 init_waitqueue_head(&priv->ds_awake_q); 721 init_waitqueue_head(&priv->ds_awake_q);
722 init_waitqueue_head(&priv->scan_q);
722 priv->authtype_auto = 1; 723 priv->authtype_auto = 1;
723 priv->is_host_sleep_configured = 0; 724 priv->is_host_sleep_configured = 0;
724 priv->is_host_sleep_activated = 0; 725 priv->is_host_sleep_activated = 0;
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index b16d5db52a4d..ef46a2d88539 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -17,7 +17,6 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <pcmcia/cs_types.h>
21#include <pcmcia/cs.h> 20#include <pcmcia/cs.h>
22#include <pcmcia/cistpl.h> 21#include <pcmcia/cistpl.h>
23#include <pcmcia/cisreg.h> 22#include <pcmcia/cisreg.h>
@@ -192,25 +191,23 @@ static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
192 p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 191 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
193 192
194 /* IO window settings */ 193 /* IO window settings */
195 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 194 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
196 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 195 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
197 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 196 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
198 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 197 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
199 if (!(io->flags & CISTPL_IO_8BIT)) 198 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
200 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 199 p_dev->resource[0]->flags |=
201 if (!(io->flags & CISTPL_IO_16BIT)) 200 pcmcia_io_cfg_data_width(io->flags);
202 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 201 p_dev->resource[0]->start = io->win[0].base;
203 p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 202 p_dev->resource[0]->end = io->win[0].len;
204 p_dev->io.BasePort1 = io->win[0].base;
205 p_dev->io.NumPorts1 = io->win[0].len;
206 if (io->nwin > 1) { 203 if (io->nwin > 1) {
207 p_dev->io.Attributes2 = p_dev->io.Attributes1; 204 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
208 p_dev->io.BasePort2 = io->win[1].base; 205 p_dev->resource[1]->start = io->win[1].base;
209 p_dev->io.NumPorts2 = io->win[1].len; 206 p_dev->resource[1]->end = io->win[1].len;
210 } 207 }
211 208
212 /* This reserves IO space but doesn't actually enable it */ 209 /* This reserves IO space but doesn't actually enable it */
213 if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 210 if (pcmcia_request_io(p_dev) != 0)
214 goto next_entry; 211 goto next_entry;
215 } 212 }
216 return 0; 213 return 0;
@@ -258,7 +255,8 @@ orinoco_cs_config(struct pcmcia_device *link)
258 /* We initialize the hermes structure before completing PCMCIA 255 /* We initialize the hermes structure before completing PCMCIA
259 * configuration just in case the interrupt handler gets 256 * configuration just in case the interrupt handler gets
260 * called. */ 257 * called. */
261 mem = ioport_map(link->io.BasePort1, link->io.NumPorts1); 258 mem = ioport_map(link->resource[0]->start,
259 resource_size(link->resource[0]));
262 if (!mem) 260 if (!mem)
263 goto failed; 261 goto failed;
264 262
@@ -280,7 +278,7 @@ orinoco_cs_config(struct pcmcia_device *link)
280 } 278 }
281 279
282 /* Register an interface with the stack */ 280 /* Register an interface with the stack */
283 if (orinoco_if_add(priv, link->io.BasePort1, 281 if (orinoco_if_add(priv, link->resource[0]->start,
284 link->irq, NULL) != 0) { 282 link->irq, NULL) != 0) {
285 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 283 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
286 goto failed; 284 goto failed;
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index b51a9adc80f6..873877e17e1b 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -25,7 +25,6 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <pcmcia/cs_types.h>
29#include <pcmcia/cs.h> 28#include <pcmcia/cs.h>
30#include <pcmcia/cistpl.h> 29#include <pcmcia/cistpl.h>
31#include <pcmcia/cisreg.h> 30#include <pcmcia/cisreg.h>
@@ -80,35 +79,27 @@ static int
80spectrum_reset(struct pcmcia_device *link, int idle) 79spectrum_reset(struct pcmcia_device *link, int idle)
81{ 80{
82 int ret; 81 int ret;
83 conf_reg_t reg; 82 u8 save_cor;
84 u_int save_cor; 83 u8 ccsr;
85 84
86 /* Doing it if hardware is gone is guaranteed crash */ 85 /* Doing it if hardware is gone is guaranteed crash */
87 if (!pcmcia_dev_present(link)) 86 if (!pcmcia_dev_present(link))
88 return -ENODEV; 87 return -ENODEV;
89 88
90 /* Save original COR value */ 89 /* Save original COR value */
91 reg.Function = 0; 90 ret = pcmcia_read_config_byte(link, CISREG_COR, &save_cor);
92 reg.Action = CS_READ;
93 reg.Offset = CISREG_COR;
94 ret = pcmcia_access_configuration_register(link, &reg);
95 if (ret) 91 if (ret)
96 goto failed; 92 goto failed;
97 save_cor = reg.Value;
98 93
99 /* Soft-Reset card */ 94 /* Soft-Reset card */
100 reg.Action = CS_WRITE; 95 ret = pcmcia_write_config_byte(link, CISREG_COR,
101 reg.Offset = CISREG_COR; 96 (save_cor | COR_SOFT_RESET));
102 reg.Value = (save_cor | COR_SOFT_RESET);
103 ret = pcmcia_access_configuration_register(link, &reg);
104 if (ret) 97 if (ret)
105 goto failed; 98 goto failed;
106 udelay(1000); 99 udelay(1000);
107 100
108 /* Read CCSR */ 101 /* Read CCSR */
109 reg.Action = CS_READ; 102 ret = pcmcia_read_config_byte(link, CISREG_CCSR, &ccsr);
110 reg.Offset = CISREG_CCSR;
111 ret = pcmcia_access_configuration_register(link, &reg);
112 if (ret) 103 if (ret)
113 goto failed; 104 goto failed;
114 105
@@ -116,19 +107,15 @@ spectrum_reset(struct pcmcia_device *link, int idle)
116 * Start or stop the firmware. Memory width bit should be 107 * Start or stop the firmware. Memory width bit should be
117 * preserved from the value we've just read. 108 * preserved from the value we've just read.
118 */ 109 */
119 reg.Action = CS_WRITE; 110 ccsr = (idle ? HCR_IDLE : HCR_RUN) | (ccsr & HCR_MEM16);
120 reg.Offset = CISREG_CCSR; 111 ret = pcmcia_write_config_byte(link, CISREG_CCSR, ccsr);
121 reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16);
122 ret = pcmcia_access_configuration_register(link, &reg);
123 if (ret) 112 if (ret)
124 goto failed; 113 goto failed;
125 udelay(1000); 114 udelay(1000);
126 115
127 /* Restore original COR configuration index */ 116 /* Restore original COR configuration index */
128 reg.Action = CS_WRITE; 117 ret = pcmcia_write_config_byte(link, CISREG_COR,
129 reg.Offset = CISREG_COR; 118 (save_cor & ~COR_SOFT_RESET));
130 reg.Value = (save_cor & ~COR_SOFT_RESET);
131 ret = pcmcia_access_configuration_register(link, &reg);
132 if (ret) 119 if (ret)
133 goto failed; 120 goto failed;
134 udelay(1000); 121 udelay(1000);
@@ -266,25 +253,23 @@ static int spectrum_cs_config_check(struct pcmcia_device *p_dev,
266 p_dev->conf.Attributes |= CONF_ENABLE_IRQ; 253 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
267 254
268 /* IO window settings */ 255 /* IO window settings */
269 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; 256 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
270 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 257 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
271 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 258 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
272 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 259 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
273 if (!(io->flags & CISTPL_IO_8BIT)) 260 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
274 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 261 p_dev->resource[0]->flags |=
275 if (!(io->flags & CISTPL_IO_16BIT)) 262 pcmcia_io_cfg_data_width(io->flags);
276 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 263 p_dev->resource[0]->start = io->win[0].base;
277 p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 264 p_dev->resource[0]->end = io->win[0].len;
278 p_dev->io.BasePort1 = io->win[0].base;
279 p_dev->io.NumPorts1 = io->win[0].len;
280 if (io->nwin > 1) { 265 if (io->nwin > 1) {
281 p_dev->io.Attributes2 = p_dev->io.Attributes1; 266 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
282 p_dev->io.BasePort2 = io->win[1].base; 267 p_dev->resource[1]->start = io->win[1].base;
283 p_dev->io.NumPorts2 = io->win[1].len; 268 p_dev->resource[1]->end = io->win[1].len;
284 } 269 }
285 270
286 /* This reserves IO space but doesn't actually enable it */ 271 /* This reserves IO space but doesn't actually enable it */
287 if (pcmcia_request_io(p_dev, &p_dev->io) != 0) 272 if (pcmcia_request_io(p_dev) != 0)
288 goto next_entry; 273 goto next_entry;
289 } 274 }
290 return 0; 275 return 0;
@@ -332,7 +317,8 @@ spectrum_cs_config(struct pcmcia_device *link)
332 /* We initialize the hermes structure before completing PCMCIA 317 /* We initialize the hermes structure before completing PCMCIA
333 * configuration just in case the interrupt handler gets 318 * configuration just in case the interrupt handler gets
334 * called. */ 319 * called. */
335 mem = ioport_map(link->io.BasePort1, link->io.NumPorts1); 320 mem = ioport_map(link->resource[0]->start,
321 resource_size(link->resource[0]));
336 if (!mem) 322 if (!mem)
337 goto failed; 323 goto failed;
338 324
@@ -359,7 +345,7 @@ spectrum_cs_config(struct pcmcia_device *link)
359 } 345 }
360 346
361 /* Register an interface with the stack */ 347 /* Register an interface with the stack */
362 if (orinoco_if_add(priv, link->io.BasePort1, 348 if (orinoco_if_add(priv, link->resource[0]->start,
363 link->irq, NULL) != 0) { 349 link->irq, NULL) != 0) {
364 printk(KERN_ERR PFX "orinoco_if_add() failed\n"); 350 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
365 goto failed; 351 goto failed;
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index 822f8dc26e9c..71a101fb2e4e 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -43,6 +43,8 @@ static DEFINE_PCI_DEVICE_TABLE(p54p_table) = {
43 { PCI_DEVICE(0x1260, 0x3886) }, 43 { PCI_DEVICE(0x1260, 0x3886) },
44 /* Intersil PRISM Xbow Wireless LAN adapter (Symbol AP-300) */ 44 /* Intersil PRISM Xbow Wireless LAN adapter (Symbol AP-300) */
45 { PCI_DEVICE(0x1260, 0xffff) }, 45 { PCI_DEVICE(0x1260, 0xffff) },
46 /* Standard Microsystems Corp SMC2802W Wireless PCI */
47 { PCI_DEVICE(0x10b8, 0x2802) },
46 { }, 48 { },
47}; 49};
48 50
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 9c38fc331dca..88560d0ae50a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -46,7 +46,6 @@
46#include <linux/ethtool.h> 46#include <linux/ethtool.h>
47#include <linux/ieee80211.h> 47#include <linux/ieee80211.h>
48 48
49#include <pcmcia/cs_types.h>
50#include <pcmcia/cs.h> 49#include <pcmcia/cs.h>
51#include <pcmcia/cistpl.h> 50#include <pcmcia/cistpl.h>
52#include <pcmcia/cisreg.h> 51#include <pcmcia/cisreg.h>
@@ -315,9 +314,8 @@ static int ray_probe(struct pcmcia_device *p_dev)
315 local->finder = p_dev; 314 local->finder = p_dev;
316 315
317 /* The io structure describes IO port mapping. None used here */ 316 /* The io structure describes IO port mapping. None used here */
318 p_dev->io.NumPorts1 = 0; 317 p_dev->resource[0]->end = 0;
319 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 318 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
320 p_dev->io.IOAddrLines = 5;
321 319
322 /* General socket configuration */ 320 /* General socket configuration */
323 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 321 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
@@ -394,7 +392,6 @@ static int ray_config(struct pcmcia_device *link)
394 int ret = 0; 392 int ret = 0;
395 int i; 393 int i;
396 win_req_t req; 394 win_req_t req;
397 memreq_t mem;
398 struct net_device *dev = (struct net_device *)link->priv; 395 struct net_device *dev = (struct net_device *)link->priv;
399 ray_dev_t *local = netdev_priv(dev); 396 ray_dev_t *local = netdev_priv(dev);
400 397
@@ -431,9 +428,7 @@ static int ray_config(struct pcmcia_device *link)
431 ret = pcmcia_request_window(link, &req, &link->win); 428 ret = pcmcia_request_window(link, &req, &link->win);
432 if (ret) 429 if (ret)
433 goto failed; 430 goto failed;
434 mem.CardOffset = 0x0000; 431 ret = pcmcia_map_mem_page(link, link->win, 0);
435 mem.Page = 0;
436 ret = pcmcia_map_mem_page(link, link->win, &mem);
437 if (ret) 432 if (ret)
438 goto failed; 433 goto failed;
439 local->sram = ioremap(req.Base, req.Size); 434 local->sram = ioremap(req.Base, req.Size);
@@ -447,9 +442,7 @@ static int ray_config(struct pcmcia_device *link)
447 ret = pcmcia_request_window(link, &req, &local->rmem_handle); 442 ret = pcmcia_request_window(link, &req, &local->rmem_handle);
448 if (ret) 443 if (ret)
449 goto failed; 444 goto failed;
450 mem.CardOffset = 0x8000; 445 ret = pcmcia_map_mem_page(link, local->rmem_handle, 0x8000);
451 mem.Page = 0;
452 ret = pcmcia_map_mem_page(link, local->rmem_handle, &mem);
453 if (ret) 446 if (ret)
454 goto failed; 447 goto failed;
455 local->rmem = ioremap(req.Base, req.Size); 448 local->rmem = ioremap(req.Base, req.Size);
@@ -463,9 +456,7 @@ static int ray_config(struct pcmcia_device *link)
463 ret = pcmcia_request_window(link, &req, &local->amem_handle); 456 ret = pcmcia_request_window(link, &req, &local->amem_handle);
464 if (ret) 457 if (ret)
465 goto failed; 458 goto failed;
466 mem.CardOffset = 0x0000; 459 ret = pcmcia_map_mem_page(link, local->amem_handle, 0);
467 mem.Page = 0;
468 ret = pcmcia_map_mem_page(link, local->amem_handle, &mem);
469 if (ret) 460 if (ret)
470 goto failed; 461 goto failed;
471 local->amem = ioremap(req.Base, req.Size); 462 local->amem = ioremap(req.Base, req.Size);
@@ -793,7 +784,6 @@ static void ray_release(struct pcmcia_device *link)
793{ 784{
794 struct net_device *dev = link->priv; 785 struct net_device *dev = link->priv;
795 ray_dev_t *local = netdev_priv(dev); 786 ray_dev_t *local = netdev_priv(dev);
796 int i;
797 787
798 dev_dbg(&link->dev, "ray_release\n"); 788 dev_dbg(&link->dev, "ray_release\n");
799 789
@@ -802,13 +792,6 @@ static void ray_release(struct pcmcia_device *link)
802 iounmap(local->sram); 792 iounmap(local->sram);
803 iounmap(local->rmem); 793 iounmap(local->rmem);
804 iounmap(local->amem); 794 iounmap(local->amem);
805 /* Do bother checking to see if these succeed or not */
806 i = pcmcia_release_window(link, local->amem_handle);
807 if (i != 0)
808 dev_dbg(&link->dev, "ReleaseWindow(local->amem) ret = %x\n", i);
809 i = pcmcia_release_window(link, local->rmem_handle);
810 if (i != 0)
811 dev_dbg(&link->dev, "ReleaseWindow(local->rmem) ret = %x\n", i);
812 pcmcia_disable_device(link); 795 pcmcia_disable_device(link);
813 796
814 dev_dbg(&link->dev, "ray_release ending\n"); 797 dev_dbg(&link->dev, "ray_release ending\n");
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 19b262e1ddbe..63c2cc408e15 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -240,16 +240,16 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
240 struct rt2x00_dev *rt2x00dev; 240 struct rt2x00_dev *rt2x00dev;
241 int retval; 241 int retval;
242 242
243 retval = pci_request_regions(pci_dev, pci_name(pci_dev)); 243 retval = pci_enable_device(pci_dev);
244 if (retval) { 244 if (retval) {
245 ERROR_PROBE("PCI request regions failed.\n"); 245 ERROR_PROBE("Enable device failed.\n");
246 return retval; 246 return retval;
247 } 247 }
248 248
249 retval = pci_enable_device(pci_dev); 249 retval = pci_request_regions(pci_dev, pci_name(pci_dev));
250 if (retval) { 250 if (retval) {
251 ERROR_PROBE("Enable device failed.\n"); 251 ERROR_PROBE("PCI request regions failed.\n");
252 goto exit_release_regions; 252 goto exit_disable_device;
253 } 253 }
254 254
255 pci_set_master(pci_dev); 255 pci_set_master(pci_dev);
@@ -260,14 +260,14 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
260 if (dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) { 260 if (dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) {
261 ERROR_PROBE("PCI DMA not supported.\n"); 261 ERROR_PROBE("PCI DMA not supported.\n");
262 retval = -EIO; 262 retval = -EIO;
263 goto exit_disable_device; 263 goto exit_release_regions;
264 } 264 }
265 265
266 hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw); 266 hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
267 if (!hw) { 267 if (!hw) {
268 ERROR_PROBE("Failed to allocate hardware.\n"); 268 ERROR_PROBE("Failed to allocate hardware.\n");
269 retval = -ENOMEM; 269 retval = -ENOMEM;
270 goto exit_disable_device; 270 goto exit_release_regions;
271 } 271 }
272 272
273 pci_set_drvdata(pci_dev, hw); 273 pci_set_drvdata(pci_dev, hw);
@@ -300,13 +300,12 @@ exit_free_reg:
300exit_free_device: 300exit_free_device:
301 ieee80211_free_hw(hw); 301 ieee80211_free_hw(hw);
302 302
303exit_disable_device:
304 if (retval != -EBUSY)
305 pci_disable_device(pci_dev);
306
307exit_release_regions: 303exit_release_regions:
308 pci_release_regions(pci_dev); 304 pci_release_regions(pci_dev);
309 305
306exit_disable_device:
307 pci_disable_device(pci_dev);
308
310 pci_set_drvdata(pci_dev, NULL); 309 pci_set_drvdata(pci_dev, NULL);
311 310
312 return retval; 311 return retval;
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
index 1d8178563d76..b50c39aaec05 100644
--- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
@@ -695,6 +695,8 @@ static void rtl8180_beacon_work(struct work_struct *work)
695 695
696 /* grab a fresh beacon */ 696 /* grab a fresh beacon */
697 skb = ieee80211_beacon_get(dev, vif); 697 skb = ieee80211_beacon_get(dev, vif);
698 if (!skb)
699 goto resched;
698 700
699 /* 701 /*
700 * update beacon timestamp w/ TSF value 702 * update beacon timestamp w/ TSF value
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c
index 96d25fb50495..4cb99c541e2a 100644
--- a/drivers/net/wireless/wl12xx/wl1271_spi.c
+++ b/drivers/net/wireless/wl12xx/wl1271_spi.c
@@ -160,9 +160,8 @@ static void wl1271_spi_init(struct wl1271 *wl)
160 spi_message_add_tail(&t, &m); 160 spi_message_add_tail(&t, &m);
161 161
162 spi_sync(wl_to_spi(wl), &m); 162 spi_sync(wl_to_spi(wl), &m);
163 kfree(cmd);
164
165 wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); 163 wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
164 kfree(cmd);
166} 165}
167 166
168#define WL1271_BUSY_WORD_TIMEOUT 1000 167#define WL1271_BUSY_WORD_TIMEOUT 1000
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 376c6b964a9c..a1cc2d498a1c 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -48,7 +48,6 @@
48 48
49#include <net/iw_handler.h> 49#include <net/iw_handler.h>
50 50
51#include <pcmcia/cs_types.h>
52#include <pcmcia/cs.h> 51#include <pcmcia/cs.h>
53#include <pcmcia/cistpl.h> 52#include <pcmcia/cistpl.h>
54#include <pcmcia/cisreg.h> 53#include <pcmcia/cisreg.h>
@@ -89,13 +88,6 @@
89static int wl3501_config(struct pcmcia_device *link); 88static int wl3501_config(struct pcmcia_device *link);
90static void wl3501_release(struct pcmcia_device *link); 89static void wl3501_release(struct pcmcia_device *link);
91 90
92/*
93 * The dev_info variable is the "key" that is used to match up this
94 * device driver with appropriate cards, through the card configuration
95 * database.
96 */
97static dev_info_t wl3501_dev_info = "wl3501_cs";
98
99static const struct { 91static const struct {
100 int reg_domain; 92 int reg_domain;
101 int min, max, deflt; 93 int min, max, deflt;
@@ -1421,7 +1413,7 @@ static struct iw_statistics *wl3501_get_wireless_stats(struct net_device *dev)
1421 1413
1422static void wl3501_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1414static void wl3501_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1423{ 1415{
1424 strlcpy(info->driver, wl3501_dev_info, sizeof(info->driver)); 1416 strlcpy(info->driver, "wl3501_cs", sizeof(info->driver));
1425} 1417}
1426 1418
1427static const struct ethtool_ops ops = { 1419static const struct ethtool_ops ops = {
@@ -1892,9 +1884,8 @@ static int wl3501_probe(struct pcmcia_device *p_dev)
1892 struct wl3501_card *this; 1884 struct wl3501_card *this;
1893 1885
1894 /* The io structure describes IO port mapping */ 1886 /* The io structure describes IO port mapping */
1895 p_dev->io.NumPorts1 = 16; 1887 p_dev->resource[0]->end = 16;
1896 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1888 p_dev->resource[0]->flags = IO_DATA_PATH_WIDTH_8;
1897 p_dev->io.IOAddrLines = 5;
1898 1889
1899 /* General socket configuration */ 1890 /* General socket configuration */
1900 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 1891 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
@@ -1940,13 +1931,14 @@ static int wl3501_config(struct pcmcia_device *link)
1940 /* Try allocating IO ports. This tries a few fixed addresses. If you 1931 /* Try allocating IO ports. This tries a few fixed addresses. If you
1941 * want, you can also read the card's config table to pick addresses -- 1932 * want, you can also read the card's config table to pick addresses --
1942 * see the serial driver for an example. */ 1933 * see the serial driver for an example. */
1934 link->io_lines = 5;
1943 1935
1944 for (j = 0x280; j < 0x400; j += 0x20) { 1936 for (j = 0x280; j < 0x400; j += 0x20) {
1945 /* The '^0x300' is so that we probe 0x300-0x3ff first, then 1937 /* The '^0x300' is so that we probe 0x300-0x3ff first, then
1946 * 0x200-0x2ff, and so on, because this seems safer */ 1938 * 0x200-0x2ff, and so on, because this seems safer */
1947 link->io.BasePort1 = j; 1939 link->resource[0]->start = j;
1948 link->io.BasePort2 = link->io.BasePort1 + 0x10; 1940 link->resource[1]->start = link->resource[0]->start + 0x10;
1949 i = pcmcia_request_io(link, &link->io); 1941 i = pcmcia_request_io(link);
1950 if (i == 0) 1942 if (i == 0)
1951 break; 1943 break;
1952 } 1944 }
@@ -1968,7 +1960,7 @@ static int wl3501_config(struct pcmcia_device *link)
1968 goto failed; 1960 goto failed;
1969 1961
1970 dev->irq = link->irq; 1962 dev->irq = link->irq;
1971 dev->base_addr = link->io.BasePort1; 1963 dev->base_addr = link->resource[0]->start;
1972 SET_NETDEV_DEV(dev, &link->dev); 1964 SET_NETDEV_DEV(dev, &link->dev);
1973 if (register_netdev(dev)) { 1965 if (register_netdev(dev)) {
1974 printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n"); 1966 printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n");
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index d04c5b262050..b2c2f391b29d 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -20,7 +20,7 @@
20#include <linux/skbuff.h> 20#include <linux/skbuff.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23 23#include <linux/of_address.h>
24#include <linux/of_device.h> 24#include <linux/of_device.h>
25#include <linux/of_platform.h> 25#include <linux/of_platform.h>
26#include <linux/of_mdio.h> 26#include <linux/of_mdio.h>