d1b2f3c1f990762bc4f0667165c398a1b14288d5
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 404-ath9k-introduce-bus-specific-cleanup-routine.patch
1 From 4167fb37cceda6a5ebfbfc4431abc69a1857ce43 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Mon, 5 Jan 2009 10:59:29 +0100
4 Subject: [PATCH 04/11] ath9k: introduce bus specific cleanup routine
5
6 We have left only some PCI specific cleanup code. We have to convert
7 them as well.
8
9 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
10 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
11 ---
12 drivers/net/wireless/ath9k/core.h | 6 ++++++
13 drivers/net/wireless/ath9k/main.c | 30 ++++++++++++++++--------------
14 2 files changed, 22 insertions(+), 14 deletions(-)
15
16 --- a/drivers/net/wireless/ath9k/core.h
17 +++ b/drivers/net/wireless/ath9k/core.h
18 @@ -695,6 +695,7 @@ enum PROT_MODE {
19
20 struct ath_bus_ops {
21 void (*read_cachesize)(struct ath_softc *sc, int *csz);
22 + void (*cleanup)(struct ath_softc *sc);
23 };
24
25 struct ath_softc {
26 @@ -760,4 +761,9 @@ static inline void ath_read_cachesize(st
27 sc->bus_ops->read_cachesize(sc, csz);
28 }
29
30 +static inline void ath_bus_cleanup(struct ath_softc *sc)
31 +{
32 + sc->bus_ops->cleanup(sc);
33 +}
34 +
35 #endif /* CORE_H */
36 --- a/drivers/net/wireless/ath9k/main.c
37 +++ b/drivers/net/wireless/ath9k/main.c
38 @@ -1267,13 +1267,7 @@ static int ath_start_rfkill_poll(struct
39 rfkill_free(sc->rf_kill.rfkill);
40
41 /* Deinitialize the device */
42 - ath_detach(sc);
43 - if (to_pci_dev(sc->dev)->irq)
44 - free_irq(to_pci_dev(sc->dev)->irq, sc);
45 - pci_iounmap(to_pci_dev(sc->dev), sc->mem);
46 - pci_release_region(to_pci_dev(sc->dev), 0);
47 - pci_disable_device(to_pci_dev(sc->dev));
48 - ieee80211_free_hw(sc->hw);
49 + ath_bus_cleanup(sc);
50 return -EIO;
51 } else {
52 sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
53 @@ -2529,8 +2523,22 @@ ath_rf_name(u16 rf_version)
54 return "????";
55 }
56
57 +static void ath_pci_cleanup(struct ath_softc *sc)
58 +{
59 + struct pci_dev *pdev = to_pci_dev(sc->dev);
60 +
61 + ath_detach(sc);
62 + if (pdev->irq)
63 + free_irq(pdev->irq, sc);
64 + pci_iounmap(pdev, sc->mem);
65 + pci_release_region(pdev, 0);
66 + pci_disable_device(pdev);
67 + ieee80211_free_hw(sc->hw);
68 +}
69 +
70 static struct ath_bus_ops ath_pci_bus_ops = {
71 .read_cachesize = ath_pci_read_cachesize,
72 + .cleanup = ath_pci_cleanup,
73 };
74
75 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
76 @@ -2667,13 +2675,7 @@ static void ath_pci_remove(struct pci_de
77 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
78 struct ath_softc *sc = hw->priv;
79
80 - ath_detach(sc);
81 - if (pdev->irq)
82 - free_irq(pdev->irq, sc);
83 - pci_iounmap(pdev, sc->mem);
84 - pci_release_region(pdev, 0);
85 - pci_disable_device(pdev);
86 - ieee80211_free_hw(hw);
87 + ath_pci_cleanup(sc);
88 }
89
90 #ifdef CONFIG_PM