aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-12-12 07:14:22 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-01-07 15:16:51 -0500
commitb81950b165ff71d826fcac851153f9265a83d9ab (patch)
treedeca23d16027c10c0ef0a33831b424b51e74dd7b /drivers/net/wireless/ath
parentd5374ef13ebda6ec93f0b4af6b30682ea4b14782 (diff)
ath9k: use the devres API for allocations/mappings
Signed-off-by: Felix Fietkau <nbd@openwrt.org> Acked-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ath9k/ahb.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h5
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c100
-rw-r--r--drivers/net/wireless/ath/ath9k/mci.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c39
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c37
7 files changed, 51 insertions, 170 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
index 3a69804f4c16..d1ff3c246a12 100644
--- a/drivers/net/wireless/ath/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
@@ -86,29 +86,25 @@ static int ath_ahb_probe(struct platform_device *pdev)
86 86
87 if (!pdev->dev.platform_data) { 87 if (!pdev->dev.platform_data) {
88 dev_err(&pdev->dev, "no platform data specified\n"); 88 dev_err(&pdev->dev, "no platform data specified\n");
89 ret = -EINVAL; 89 return -EINVAL;
90 goto err_out;
91 } 90 }
92 91
93 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 92 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
94 if (res == NULL) { 93 if (res == NULL) {
95 dev_err(&pdev->dev, "no memory resource found\n"); 94 dev_err(&pdev->dev, "no memory resource found\n");
96 ret = -ENXIO; 95 return -ENXIO;
97 goto err_out;
98 } 96 }
99 97
100 mem = ioremap_nocache(res->start, resource_size(res)); 98 mem = devm_ioremap_nocache(&pdev->dev, res->start, resource_size(res));
101 if (mem == NULL) { 99 if (mem == NULL) {
102 dev_err(&pdev->dev, "ioremap failed\n"); 100 dev_err(&pdev->dev, "ioremap failed\n");
103 ret = -ENOMEM; 101 return -ENOMEM;
104 goto err_out;
105 } 102 }
106 103
107 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 104 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
108 if (res == NULL) { 105 if (res == NULL) {
109 dev_err(&pdev->dev, "no IRQ resource found\n"); 106 dev_err(&pdev->dev, "no IRQ resource found\n");
110 ret = -ENXIO; 107 return -ENXIO;
111 goto err_iounmap;
112 } 108 }
113 109
114 irq = res->start; 110 irq = res->start;
@@ -116,8 +112,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
116 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops); 112 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
117 if (hw == NULL) { 113 if (hw == NULL) {
118 dev_err(&pdev->dev, "no memory for ieee80211_hw\n"); 114 dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
119 ret = -ENOMEM; 115 return -ENOMEM;
120 goto err_iounmap;
121 } 116 }
122 117
123 SET_IEEE80211_DEV(hw, &pdev->dev); 118 SET_IEEE80211_DEV(hw, &pdev->dev);
@@ -156,9 +151,6 @@ static int ath_ahb_probe(struct platform_device *pdev)
156 err_free_hw: 151 err_free_hw:
157 ieee80211_free_hw(hw); 152 ieee80211_free_hw(hw);
158 platform_set_drvdata(pdev, NULL); 153 platform_set_drvdata(pdev, NULL);
159 err_iounmap:
160 iounmap(mem);
161 err_out:
162 return ret; 154 return ret;
163} 155}
164 156
@@ -168,12 +160,10 @@ static int ath_ahb_remove(struct platform_device *pdev)
168 160
169 if (hw) { 161 if (hw) {
170 struct ath_softc *sc = hw->priv; 162 struct ath_softc *sc = hw->priv;
171 void __iomem *mem = sc->mem;
172 163
173 ath9k_deinit_device(sc); 164 ath9k_deinit_device(sc);
174 free_irq(sc->irq, sc); 165 free_irq(sc->irq, sc);
175 ieee80211_free_hw(sc->hw); 166 ieee80211_free_hw(sc->hw);
176 iounmap(mem);
177 platform_set_drvdata(pdev, NULL); 167 platform_set_drvdata(pdev, NULL);
178 } 168 }
179 169
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 86e26a19efda..72501073b499 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -109,14 +109,11 @@ struct ath_descdma {
109 void *dd_desc; 109 void *dd_desc;
110 dma_addr_t dd_desc_paddr; 110 dma_addr_t dd_desc_paddr;
111 u32 dd_desc_len; 111 u32 dd_desc_len;
112 struct ath_buf *dd_bufptr;
113}; 112};
114 113
115int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, 114int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
116 struct list_head *head, const char *name, 115 struct list_head *head, const char *name,
117 int nbuf, int ndesc, bool is_tx); 116 int nbuf, int ndesc, bool is_tx);
118void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd,
119 struct list_head *head);
120 117
121/***********/ 118/***********/
122/* RX / TX */ 119/* RX / TX */
@@ -320,7 +317,6 @@ struct ath_rx {
320 spinlock_t rxbuflock; 317 spinlock_t rxbuflock;
321 struct list_head rxbuf; 318 struct list_head rxbuf;
322 struct ath_descdma rxdma; 319 struct ath_descdma rxdma;
323 struct ath_buf *rx_bufptr;
324 struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX]; 320 struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
325 321
326 struct sk_buff *frag; 322 struct sk_buff *frag;
@@ -345,7 +341,6 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
345void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an); 341void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
346void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq); 342void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
347int ath_tx_init(struct ath_softc *sc, int nbufs); 343int ath_tx_init(struct ath_softc *sc, int nbufs);
348void ath_tx_cleanup(struct ath_softc *sc);
349int ath_txq_update(struct ath_softc *sc, int qnum, 344int ath_txq_update(struct ath_softc *sc, int qnum,
350 struct ath9k_tx_queue_info *q); 345 struct ath9k_tx_queue_info *q);
351void ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop); 346void ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop);
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index f69ef5d48c7b..0f00a1306ac0 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -337,7 +337,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
337 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 337 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
338 u8 *ds; 338 u8 *ds;
339 struct ath_buf *bf; 339 struct ath_buf *bf;
340 int i, bsize, error, desc_len; 340 int i, bsize, desc_len;
341 341
342 ath_dbg(common, CONFIG, "%s DMA: %u buffers %u desc/buf\n", 342 ath_dbg(common, CONFIG, "%s DMA: %u buffers %u desc/buf\n",
343 name, nbuf, ndesc); 343 name, nbuf, ndesc);
@@ -353,8 +353,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
353 if ((desc_len % 4) != 0) { 353 if ((desc_len % 4) != 0) {
354 ath_err(common, "ath_desc not DWORD aligned\n"); 354 ath_err(common, "ath_desc not DWORD aligned\n");
355 BUG_ON((desc_len % 4) != 0); 355 BUG_ON((desc_len % 4) != 0);
356 error = -ENOMEM; 356 return -ENOMEM;
357 goto fail;
358 } 357 }
359 358
360 dd->dd_desc_len = desc_len * nbuf * ndesc; 359 dd->dd_desc_len = desc_len * nbuf * ndesc;
@@ -378,12 +377,11 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
378 } 377 }
379 378
380 /* allocate descriptors */ 379 /* allocate descriptors */
381 dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len, 380 dd->dd_desc = dmam_alloc_coherent(sc->dev, dd->dd_desc_len,
382 &dd->dd_desc_paddr, GFP_KERNEL); 381 &dd->dd_desc_paddr, GFP_KERNEL);
383 if (dd->dd_desc == NULL) { 382 if (!dd->dd_desc)
384 error = -ENOMEM; 383 return -ENOMEM;
385 goto fail; 384
386 }
387 ds = (u8 *) dd->dd_desc; 385 ds = (u8 *) dd->dd_desc;
388 ath_dbg(common, CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n", 386 ath_dbg(common, CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n",
389 name, ds, (u32) dd->dd_desc_len, 387 name, ds, (u32) dd->dd_desc_len,
@@ -391,12 +389,9 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
391 389
392 /* allocate buffers */ 390 /* allocate buffers */
393 bsize = sizeof(struct ath_buf) * nbuf; 391 bsize = sizeof(struct ath_buf) * nbuf;
394 bf = kzalloc(bsize, GFP_KERNEL); 392 bf = devm_kzalloc(sc->dev, bsize, GFP_KERNEL);
395 if (bf == NULL) { 393 if (!bf)
396 error = -ENOMEM; 394 return -ENOMEM;
397 goto fail2;
398 }
399 dd->dd_bufptr = bf;
400 395
401 for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) { 396 for (i = 0; i < nbuf; i++, bf++, ds += (desc_len * ndesc)) {
402 bf->bf_desc = ds; 397 bf->bf_desc = ds;
@@ -422,12 +417,6 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
422 list_add_tail(&bf->list, head); 417 list_add_tail(&bf->list, head);
423 } 418 }
424 return 0; 419 return 0;
425fail2:
426 dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
427 dd->dd_desc_paddr);
428fail:
429 memset(dd, 0, sizeof(*dd));
430 return error;
431} 420}
432 421
433static int ath9k_init_queues(struct ath_softc *sc) 422static int ath9k_init_queues(struct ath_softc *sc)
@@ -457,11 +446,13 @@ static int ath9k_init_channels_rates(struct ath_softc *sc)
457 ATH9K_NUM_CHANNELS); 446 ATH9K_NUM_CHANNELS);
458 447
459 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) { 448 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
460 channels = kmemdup(ath9k_2ghz_chantable, 449 channels = devm_kzalloc(sc->dev,
461 sizeof(ath9k_2ghz_chantable), GFP_KERNEL); 450 sizeof(ath9k_2ghz_chantable), GFP_KERNEL);
462 if (!channels) 451 if (!channels)
463 return -ENOMEM; 452 return -ENOMEM;
464 453
454 memcpy(channels, ath9k_2ghz_chantable,
455 sizeof(ath9k_2ghz_chantable));
465 sc->sbands[IEEE80211_BAND_2GHZ].channels = channels; 456 sc->sbands[IEEE80211_BAND_2GHZ].channels = channels;
466 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; 457 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
467 sc->sbands[IEEE80211_BAND_2GHZ].n_channels = 458 sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
@@ -472,14 +463,13 @@ static int ath9k_init_channels_rates(struct ath_softc *sc)
472 } 463 }
473 464
474 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) { 465 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) {
475 channels = kmemdup(ath9k_5ghz_chantable, 466 channels = devm_kzalloc(sc->dev,
476 sizeof(ath9k_5ghz_chantable), GFP_KERNEL); 467 sizeof(ath9k_5ghz_chantable), GFP_KERNEL);
477 if (!channels) { 468 if (!channels)
478 if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
479 kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
480 return -ENOMEM; 469 return -ENOMEM;
481 }
482 470
471 memcpy(channels, ath9k_5ghz_chantable,
472 sizeof(ath9k_5ghz_chantable));
483 sc->sbands[IEEE80211_BAND_5GHZ].channels = channels; 473 sc->sbands[IEEE80211_BAND_5GHZ].channels = channels;
484 sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; 474 sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
485 sc->sbands[IEEE80211_BAND_5GHZ].n_channels = 475 sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
@@ -565,7 +555,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
565 int ret = 0, i; 555 int ret = 0, i;
566 int csz = 0; 556 int csz = 0;
567 557
568 ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL); 558 ah = devm_kzalloc(sc->dev, sizeof(struct ath_hw), GFP_KERNEL);
569 if (!ah) 559 if (!ah)
570 return -ENOMEM; 560 return -ENOMEM;
571 561
@@ -636,7 +626,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
636 if (pdata && pdata->eeprom_name) { 626 if (pdata && pdata->eeprom_name) {
637 ret = ath9k_eeprom_request(sc, pdata->eeprom_name); 627 ret = ath9k_eeprom_request(sc, pdata->eeprom_name);
638 if (ret) 628 if (ret)
639 goto err_eeprom; 629 return ret;
640 } 630 }
641 631
642 /* Initializes the hardware for all supported chipsets */ 632 /* Initializes the hardware for all supported chipsets */
@@ -676,10 +666,6 @@ err_queues:
676 ath9k_hw_deinit(ah); 666 ath9k_hw_deinit(ah);
677err_hw: 667err_hw:
678 ath9k_eeprom_release(sc); 668 ath9k_eeprom_release(sc);
679err_eeprom:
680 kfree(ah);
681 sc->sc_ah = NULL;
682
683 return ret; 669 return ret;
684} 670}
685 671
@@ -844,8 +830,8 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc,
844 830
845 /* Bring up device */ 831 /* Bring up device */
846 error = ath9k_init_softc(devid, sc, bus_ops); 832 error = ath9k_init_softc(devid, sc, bus_ops);
847 if (error != 0) 833 if (error)
848 goto error_init; 834 return error;
849 835
850 ah = sc->sc_ah; 836 ah = sc->sc_ah;
851 common = ath9k_hw_common(ah); 837 common = ath9k_hw_common(ah);
@@ -855,19 +841,19 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc,
855 error = ath_regd_init(&common->regulatory, sc->hw->wiphy, 841 error = ath_regd_init(&common->regulatory, sc->hw->wiphy,
856 ath9k_reg_notifier); 842 ath9k_reg_notifier);
857 if (error) 843 if (error)
858 goto error_regd; 844 goto deinit;
859 845
860 reg = &common->regulatory; 846 reg = &common->regulatory;
861 847
862 /* Setup TX DMA */ 848 /* Setup TX DMA */
863 error = ath_tx_init(sc, ATH_TXBUF); 849 error = ath_tx_init(sc, ATH_TXBUF);
864 if (error != 0) 850 if (error != 0)
865 goto error_tx; 851 goto deinit;
866 852
867 /* Setup RX DMA */ 853 /* Setup RX DMA */
868 error = ath_rx_init(sc, ATH_RXBUF); 854 error = ath_rx_init(sc, ATH_RXBUF);
869 if (error != 0) 855 if (error != 0)
870 goto error_rx; 856 goto deinit;
871 857
872 ath9k_init_txpower_limits(sc); 858 ath9k_init_txpower_limits(sc);
873 859
@@ -881,19 +867,19 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc,
881 /* Register with mac80211 */ 867 /* Register with mac80211 */
882 error = ieee80211_register_hw(hw); 868 error = ieee80211_register_hw(hw);
883 if (error) 869 if (error)
884 goto error_register; 870 goto rx_cleanup;
885 871
886 error = ath9k_init_debug(ah); 872 error = ath9k_init_debug(ah);
887 if (error) { 873 if (error) {
888 ath_err(common, "Unable to create debugfs files\n"); 874 ath_err(common, "Unable to create debugfs files\n");
889 goto error_world; 875 goto unregister;
890 } 876 }
891 877
892 /* Handle world regulatory */ 878 /* Handle world regulatory */
893 if (!ath_is_world_regd(reg)) { 879 if (!ath_is_world_regd(reg)) {
894 error = regulatory_hint(hw->wiphy, reg->alpha2); 880 error = regulatory_hint(hw->wiphy, reg->alpha2);
895 if (error) 881 if (error)
896 goto error_world; 882 goto unregister;
897 } 883 }
898 884
899 ath_init_leds(sc); 885 ath_init_leds(sc);
@@ -901,17 +887,12 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc,
901 887
902 return 0; 888 return 0;
903 889
904error_world: 890unregister:
905 ieee80211_unregister_hw(hw); 891 ieee80211_unregister_hw(hw);
906error_register: 892rx_cleanup:
907 ath_rx_cleanup(sc); 893 ath_rx_cleanup(sc);
908error_rx: 894deinit:
909 ath_tx_cleanup(sc);
910error_tx:
911 /* Nothing */
912error_regd:
913 ath9k_deinit_softc(sc); 895 ath9k_deinit_softc(sc);
914error_init:
915 return error; 896 return error;
916} 897}
917 898
@@ -923,12 +904,6 @@ static void ath9k_deinit_softc(struct ath_softc *sc)
923{ 904{
924 int i = 0; 905 int i = 0;
925 906
926 if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
927 kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
928
929 if (sc->sbands[IEEE80211_BAND_5GHZ].channels)
930 kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels);
931
932 ath9k_deinit_btcoex(sc); 907 ath9k_deinit_btcoex(sc);
933 908
934 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) 909 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
@@ -940,8 +915,6 @@ static void ath9k_deinit_softc(struct ath_softc *sc)
940 sc->dfs_detector->exit(sc->dfs_detector); 915 sc->dfs_detector->exit(sc->dfs_detector);
941 916
942 ath9k_eeprom_release(sc); 917 ath9k_eeprom_release(sc);
943 kfree(sc->sc_ah);
944 sc->sc_ah = NULL;
945} 918}
946 919
947void ath9k_deinit_device(struct ath_softc *sc) 920void ath9k_deinit_device(struct ath_softc *sc)
@@ -957,22 +930,9 @@ void ath9k_deinit_device(struct ath_softc *sc)
957 930
958 ieee80211_unregister_hw(hw); 931 ieee80211_unregister_hw(hw);
959 ath_rx_cleanup(sc); 932 ath_rx_cleanup(sc);
960 ath_tx_cleanup(sc);
961 ath9k_deinit_softc(sc); 933 ath9k_deinit_softc(sc);
962} 934}
963 935
964void ath_descdma_cleanup(struct ath_softc *sc,
965 struct ath_descdma *dd,
966 struct list_head *head)
967{
968 dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
969 dd->dd_desc_paddr);
970
971 INIT_LIST_HEAD(head);
972 kfree(dd->dd_bufptr);
973 memset(dd, 0, sizeof(*dd));
974}
975
976/************************/ 936/************************/
977/* Module Hooks */ 937/* Module Hooks */
978/************************/ 938/************************/
diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
index 5c02702f21e7..d2074334ec9b 100644
--- a/drivers/net/wireless/ath/ath9k/mci.c
+++ b/drivers/net/wireless/ath/ath9k/mci.c
@@ -438,7 +438,7 @@ int ath_mci_setup(struct ath_softc *sc)
438 struct ath_mci_buf *buf = &mci->sched_buf; 438 struct ath_mci_buf *buf = &mci->sched_buf;
439 int ret; 439 int ret;
440 440
441 buf->bf_addr = dma_alloc_coherent(sc->dev, 441 buf->bf_addr = dmam_alloc_coherent(sc->dev,
442 ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE, 442 ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE,
443 &buf->bf_paddr, GFP_KERNEL); 443 &buf->bf_paddr, GFP_KERNEL);
444 444
@@ -477,11 +477,6 @@ void ath_mci_cleanup(struct ath_softc *sc)
477 struct ath_mci_coex *mci = &sc->mci_coex; 477 struct ath_mci_coex *mci = &sc->mci_coex;
478 struct ath_mci_buf *buf = &mci->sched_buf; 478 struct ath_mci_buf *buf = &mci->sched_buf;
479 479
480 if (buf->bf_addr)
481 dma_free_coherent(sc->dev,
482 ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE,
483 buf->bf_addr, buf->bf_paddr);
484
485 ar9003_mci_cleanup(ah); 480 ar9003_mci_cleanup(ah);
486 481
487 ath_dbg(common, MCI, "MCI De-Initialized\n"); 482 ath_dbg(common, MCI, "MCI De-Initialized\n");
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 7ae73fbd9136..0e0d39583837 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -147,7 +147,6 @@ static const struct ath_bus_ops ath_pci_bus_ops = {
147 147
148static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 148static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
149{ 149{
150 void __iomem *mem;
151 struct ath_softc *sc; 150 struct ath_softc *sc;
152 struct ieee80211_hw *hw; 151 struct ieee80211_hw *hw;
153 u8 csz; 152 u8 csz;
@@ -155,19 +154,19 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
155 int ret = 0; 154 int ret = 0;
156 char hw_name[64]; 155 char hw_name[64];
157 156
158 if (pci_enable_device(pdev)) 157 if (pcim_enable_device(pdev))
159 return -EIO; 158 return -EIO;
160 159
161 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 160 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
162 if (ret) { 161 if (ret) {
163 pr_err("32-bit DMA not available\n"); 162 pr_err("32-bit DMA not available\n");
164 goto err_dma; 163 return ret;
165 } 164 }
166 165
167 ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); 166 ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
168 if (ret) { 167 if (ret) {
169 pr_err("32-bit DMA consistent DMA enable failed\n"); 168 pr_err("32-bit DMA consistent DMA enable failed\n");
170 goto err_dma; 169 return ret;
171 } 170 }
172 171
173 /* 172 /*
@@ -203,25 +202,16 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
203 if ((val & 0x0000ff00) != 0) 202 if ((val & 0x0000ff00) != 0)
204 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); 203 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
205 204
206 ret = pci_request_region(pdev, 0, "ath9k"); 205 ret = pcim_iomap_regions(pdev, BIT(0), "ath9k");
207 if (ret) { 206 if (ret) {
208 dev_err(&pdev->dev, "PCI memory region reserve error\n"); 207 dev_err(&pdev->dev, "PCI memory region reserve error\n");
209 ret = -ENODEV; 208 return -ENODEV;
210 goto err_region;
211 }
212
213 mem = pci_iomap(pdev, 0, 0);
214 if (!mem) {
215 pr_err("PCI memory map error\n") ;
216 ret = -EIO;
217 goto err_iomap;
218 } 209 }
219 210
220 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops); 211 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
221 if (!hw) { 212 if (!hw) {
222 dev_err(&pdev->dev, "No memory for ieee80211_hw\n"); 213 dev_err(&pdev->dev, "No memory for ieee80211_hw\n");
223 ret = -ENOMEM; 214 return -ENOMEM;
224 goto err_alloc_hw;
225 } 215 }
226 216
227 SET_IEEE80211_DEV(hw, &pdev->dev); 217 SET_IEEE80211_DEV(hw, &pdev->dev);
@@ -230,7 +220,7 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
230 sc = hw->priv; 220 sc = hw->priv;
231 sc->hw = hw; 221 sc->hw = hw;
232 sc->dev = &pdev->dev; 222 sc->dev = &pdev->dev;
233 sc->mem = mem; 223 sc->mem = pcim_iomap_table(pdev)[0];
234 224
235 /* Will be cleared in ath9k_start() */ 225 /* Will be cleared in ath9k_start() */
236 set_bit(SC_OP_INVALID, &sc->sc_flags); 226 set_bit(SC_OP_INVALID, &sc->sc_flags);
@@ -251,7 +241,7 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
251 241
252 ath9k_hw_name(sc->sc_ah, hw_name, sizeof(hw_name)); 242 ath9k_hw_name(sc->sc_ah, hw_name, sizeof(hw_name));
253 wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n", 243 wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n",
254 hw_name, (unsigned long)mem, pdev->irq); 244 hw_name, (unsigned long)sc->mem, pdev->irq);
255 245
256 return 0; 246 return 0;
257 247
@@ -259,14 +249,6 @@ err_init:
259 free_irq(sc->irq, sc); 249 free_irq(sc->irq, sc);
260err_irq: 250err_irq:
261 ieee80211_free_hw(hw); 251 ieee80211_free_hw(hw);
262err_alloc_hw:
263 pci_iounmap(pdev, mem);
264err_iomap:
265 pci_release_region(pdev, 0);
266err_region:
267 /* Nothing */
268err_dma:
269 pci_disable_device(pdev);
270 return ret; 252 return ret;
271} 253}
272 254
@@ -274,17 +256,12 @@ static void ath_pci_remove(struct pci_dev *pdev)
274{ 256{
275 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 257 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
276 struct ath_softc *sc = hw->priv; 258 struct ath_softc *sc = hw->priv;
277 void __iomem *mem = sc->mem;
278 259
279 if (!is_ath9k_unloaded) 260 if (!is_ath9k_unloaded)
280 sc->sc_ah->ah_flags |= AH_UNPLUGGED; 261 sc->sc_ah->ah_flags |= AH_UNPLUGGED;
281 ath9k_deinit_device(sc); 262 ath9k_deinit_device(sc);
282 free_irq(sc->irq, sc); 263 free_irq(sc->irq, sc);
283 ieee80211_free_hw(sc->hw); 264 ieee80211_free_hw(sc->hw);
284
285 pci_iounmap(pdev, mem);
286 pci_disable_device(pdev);
287 pci_release_region(pdev, 0);
288} 265}
289 266
290#ifdef CONFIG_PM_SLEEP 267#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index d4df98a938bf..3d236aebf588 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -180,11 +180,6 @@ static void ath_rx_edma_cleanup(struct ath_softc *sc)
180 bf->bf_mpdu = NULL; 180 bf->bf_mpdu = NULL;
181 } 181 }
182 } 182 }
183
184 INIT_LIST_HEAD(&sc->rx.rxbuf);
185
186 kfree(sc->rx.rx_bufptr);
187 sc->rx.rx_bufptr = NULL;
188} 183}
189 184
190static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size) 185static void ath_rx_edma_init_queue(struct ath_rx_edma *rx_edma, int size)
@@ -211,12 +206,11 @@ static int ath_rx_edma_init(struct ath_softc *sc, int nbufs)
211 ah->caps.rx_hp_qdepth); 206 ah->caps.rx_hp_qdepth);
212 207
213 size = sizeof(struct ath_buf) * nbufs; 208 size = sizeof(struct ath_buf) * nbufs;
214 bf = kzalloc(size, GFP_KERNEL); 209 bf = devm_kzalloc(sc->dev, size, GFP_KERNEL);
215 if (!bf) 210 if (!bf)
216 return -ENOMEM; 211 return -ENOMEM;
217 212
218 INIT_LIST_HEAD(&sc->rx.rxbuf); 213 INIT_LIST_HEAD(&sc->rx.rxbuf);
219 sc->rx.rx_bufptr = bf;
220 214
221 for (i = 0; i < nbufs; i++, bf++) { 215 for (i = 0; i < nbufs; i++, bf++) {
222 skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_KERNEL); 216 skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_KERNEL);
@@ -363,9 +357,6 @@ void ath_rx_cleanup(struct ath_softc *sc)
363 bf->bf_mpdu = NULL; 357 bf->bf_mpdu = NULL;
364 } 358 }
365 } 359 }
366
367 if (sc->rx.rxdma.dd_desc_len != 0)
368 ath_descdma_cleanup(sc, &sc->rx.rxdma, &sc->rx.rxbuf);
369 } 360 }
370} 361}
371 362
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 90e48a0fafe5..ca4a0341294f 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2361,8 +2361,8 @@ static int ath_txstatus_setup(struct ath_softc *sc, int size)
2361 u8 txs_len = sc->sc_ah->caps.txs_len; 2361 u8 txs_len = sc->sc_ah->caps.txs_len;
2362 2362
2363 dd->dd_desc_len = size * txs_len; 2363 dd->dd_desc_len = size * txs_len;
2364 dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len, 2364 dd->dd_desc = dmam_alloc_coherent(sc->dev, dd->dd_desc_len,
2365 &dd->dd_desc_paddr, GFP_KERNEL); 2365 &dd->dd_desc_paddr, GFP_KERNEL);
2366 if (!dd->dd_desc) 2366 if (!dd->dd_desc)
2367 return -ENOMEM; 2367 return -ENOMEM;
2368 2368
@@ -2382,14 +2382,6 @@ static int ath_tx_edma_init(struct ath_softc *sc)
2382 return err; 2382 return err;
2383} 2383}
2384 2384
2385static void ath_tx_edma_cleanup(struct ath_softc *sc)
2386{
2387 struct ath_descdma *dd = &sc->txsdma;
2388
2389 dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
2390 dd->dd_desc_paddr);
2391}
2392
2393int ath_tx_init(struct ath_softc *sc, int nbufs) 2385int ath_tx_init(struct ath_softc *sc, int nbufs)
2394{ 2386{
2395 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2387 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -2402,7 +2394,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs)
2402 if (error != 0) { 2394 if (error != 0) {
2403 ath_err(common, 2395 ath_err(common,
2404 "Failed to allocate tx descriptors: %d\n", error); 2396 "Failed to allocate tx descriptors: %d\n", error);
2405 goto err; 2397 return error;
2406 } 2398 }
2407 2399
2408 error = ath_descdma_setup(sc, &sc->beacon.bdma, &sc->beacon.bbuf, 2400 error = ath_descdma_setup(sc, &sc->beacon.bdma, &sc->beacon.bbuf,
@@ -2410,36 +2402,17 @@ int ath_tx_init(struct ath_softc *sc, int nbufs)
2410 if (error != 0) { 2402 if (error != 0) {
2411 ath_err(common, 2403 ath_err(common,
2412 "Failed to allocate beacon descriptors: %d\n", error); 2404 "Failed to allocate beacon descriptors: %d\n", error);
2413 goto err; 2405 return error;
2414 } 2406 }
2415 2407
2416 INIT_DELAYED_WORK(&sc->tx_complete_work, ath_tx_complete_poll_work); 2408 INIT_DELAYED_WORK(&sc->tx_complete_work, ath_tx_complete_poll_work);
2417 2409
2418 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 2410 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
2419 error = ath_tx_edma_init(sc); 2411 error = ath_tx_edma_init(sc);
2420 if (error)
2421 goto err;
2422 }
2423
2424err:
2425 if (error != 0)
2426 ath_tx_cleanup(sc);
2427 2412
2428 return error; 2413 return error;
2429} 2414}
2430 2415
2431void ath_tx_cleanup(struct ath_softc *sc)
2432{
2433 if (sc->beacon.bdma.dd_desc_len != 0)
2434 ath_descdma_cleanup(sc, &sc->beacon.bdma, &sc->beacon.bbuf);
2435
2436 if (sc->tx.txdma.dd_desc_len != 0)
2437 ath_descdma_cleanup(sc, &sc->tx.txdma, &sc->tx.txbuf);
2438
2439 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
2440 ath_tx_edma_cleanup(sc);
2441}
2442
2443void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an) 2416void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
2444{ 2417{
2445 struct ath_atx_tid *tid; 2418 struct ath_atx_tid *tid;