[package] mac80211: update ath9k patches
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 404-ath9k-introduce-bus-specific-cleanup-routine.patch
1 From 7524b77fe24a4464b08a2ac987ec22711a4f2027 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 v2 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 | 7 +++++++
13 drivers/net/wireless/ath9k/main.c | 37 +++++++++++++++++++++++--------------
14 2 files changed, 30 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 @@ -704,6 +705,7 @@ struct ath_softc {
27 struct tasklet_struct bcon_tasklet;
28 struct ath_hal *sc_ah;
29 void __iomem *mem;
30 + int irq;
31 spinlock_t sc_resetlock;
32 struct mutex mutex;
33
34 @@ -760,4 +762,9 @@ static inline void ath_read_cachesize(st
35 sc->bus_ops->read_cachesize(sc, csz);
36 }
37
38 +static inline void ath_bus_cleanup(struct ath_softc *sc)
39 +{
40 + sc->bus_ops->cleanup(sc);
41 +}
42 +
43 #endif /* CORE_H */
44 --- a/drivers/net/wireless/ath9k/main.c
45 +++ b/drivers/net/wireless/ath9k/main.c
46 @@ -39,6 +39,7 @@ static struct pci_device_id ath_pci_id_t
47 };
48
49 static void ath_detach(struct ath_softc *sc);
50 +static void ath_cleanup(struct ath_softc *sc);
51
52 /* return bus cachesize in 4B word units */
53
54 @@ -1267,13 +1268,7 @@ static int ath_start_rfkill_poll(struct
55 rfkill_free(sc->rf_kill.rfkill);
56
57 /* Deinitialize the device */
58 - ath_detach(sc);
59 - if (to_pci_dev(sc->dev)->irq)
60 - free_irq(to_pci_dev(sc->dev)->irq, sc);
61 - pci_iounmap(to_pci_dev(sc->dev), sc->mem);
62 - pci_release_region(to_pci_dev(sc->dev), 0);
63 - pci_disable_device(to_pci_dev(sc->dev));
64 - ieee80211_free_hw(sc->hw);
65 + ath_cleanup(sc);
66 return -EIO;
67 } else {
68 sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
69 @@ -1284,6 +1279,14 @@ static int ath_start_rfkill_poll(struct
70 }
71 #endif /* CONFIG_RFKILL */
72
73 +static void ath_cleanup(struct ath_softc *sc)
74 +{
75 + ath_detach(sc);
76 + free_irq(sc->irq, sc);
77 + ath_bus_cleanup(sc);
78 + ieee80211_free_hw(sc->hw);
79 +}
80 +
81 static void ath_detach(struct ath_softc *sc)
82 {
83 struct ieee80211_hw *hw = sc->hw;
84 @@ -2529,8 +2532,18 @@ ath_rf_name(u16 rf_version)
85 return "????";
86 }
87
88 +static void ath_pci_cleanup(struct ath_softc *sc)
89 +{
90 + struct pci_dev *pdev = to_pci_dev(sc->dev);
91 +
92 + pci_iounmap(pdev, sc->mem);
93 + pci_release_region(pdev, 0);
94 + pci_disable_device(pdev);
95 +}
96 +
97 static struct ath_bus_ops ath_pci_bus_ops = {
98 .read_cachesize = ath_pci_read_cachesize,
99 + .cleanup = ath_pci_cleanup,
100 };
101
102 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
103 @@ -2637,6 +2650,8 @@ static int ath_pci_probe(struct pci_dev
104 goto bad4;
105 }
106
107 + sc->irq = pdev->irq;
108 +
109 ah = sc->sc_ah;
110 printk(KERN_INFO
111 "%s: Atheros AR%s MAC/BB Rev:%x "
112 @@ -2667,13 +2682,7 @@ static void ath_pci_remove(struct pci_de
113 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
114 struct ath_softc *sc = hw->priv;
115
116 - ath_detach(sc);
117 - if (pdev->irq)
118 - free_irq(pdev->irq, sc);
119 - pci_iounmap(pdev, sc->mem);
120 - pci_release_region(pdev, 0);
121 - pci_disable_device(pdev);
122 - ieee80211_free_hw(hw);
123 + ath_cleanup(sc);
124 }
125
126 #ifdef CONFIG_PM