[package] mac80211: update ath9k patches
[openwrt.git] / package / mac80211 / patches / 404-ath9k-introduce-bus-specific-cleanup-routine.patch
1 From 72542311c85de25b6f612e8de8cfdeb96efe7308 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 v3 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 Changes-licensed-under: ISC
10
11 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
12 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
13 ---
14  drivers/net/wireless/ath9k/core.h |    7 +++++++
15  drivers/net/wireless/ath9k/main.c |   37 +++++++++++++++++++++++--------------
16  2 files changed, 30 insertions(+), 14 deletions(-)
17
18 --- a/drivers/net/wireless/ath9k/core.h
19 +++ b/drivers/net/wireless/ath9k/core.h
20 @@ -695,6 +695,7 @@ enum PROT_MODE {
21  
22  struct ath_bus_ops {
23         void            (*read_cachesize)(struct ath_softc *sc, int *csz);
24 +       void            (*cleanup)(struct ath_softc *sc);
25  };
26  
27  struct ath_softc {
28 @@ -704,6 +705,7 @@ struct ath_softc {
29         struct tasklet_struct bcon_tasklet;
30         struct ath_hal *sc_ah;
31         void __iomem *mem;
32 +       int irq;
33         spinlock_t sc_resetlock;
34         struct mutex mutex;
35  
36 @@ -760,4 +762,9 @@ static inline void ath_read_cachesize(st
37         sc->bus_ops->read_cachesize(sc, csz);
38  }
39  
40 +static inline void ath_bus_cleanup(struct ath_softc *sc)
41 +{
42 +       sc->bus_ops->cleanup(sc);
43 +}
44 +
45  #endif /* CORE_H */
46 --- a/drivers/net/wireless/ath9k/main.c
47 +++ b/drivers/net/wireless/ath9k/main.c
48 @@ -39,6 +39,7 @@ static struct pci_device_id ath_pci_id_t
49  };
50  
51  static void ath_detach(struct ath_softc *sc);
52 +static void ath_cleanup(struct ath_softc *sc);
53  
54  /* return bus cachesize in 4B word units */
55  
56 @@ -1269,13 +1270,7 @@ static int ath_start_rfkill_poll(struct 
57                         rfkill_free(sc->rf_kill.rfkill);
58  
59                         /* Deinitialize the device */
60 -                       ath_detach(sc);
61 -                       if (to_pci_dev(sc->dev)->irq)
62 -                               free_irq(to_pci_dev(sc->dev)->irq, sc);
63 -                       pci_iounmap(to_pci_dev(sc->dev), sc->mem);
64 -                       pci_release_region(to_pci_dev(sc->dev), 0);
65 -                       pci_disable_device(to_pci_dev(sc->dev));
66 -                       ieee80211_free_hw(sc->hw);
67 +                       ath_cleanup(sc);
68                         return -EIO;
69                 } else {
70                         sc->sc_flags |= SC_OP_RFKILL_REGISTERED;
71 @@ -1286,6 +1281,14 @@ static int ath_start_rfkill_poll(struct 
72  }
73  #endif /* CONFIG_RFKILL */
74  
75 +static void ath_cleanup(struct ath_softc *sc)
76 +{
77 +       ath_detach(sc);
78 +       free_irq(sc->irq, sc);
79 +       ath_bus_cleanup(sc);
80 +       ieee80211_free_hw(sc->hw);
81 +}
82 +
83  static void ath_detach(struct ath_softc *sc)
84  {
85         struct ieee80211_hw *hw = sc->hw;
86 @@ -2538,8 +2541,18 @@ ath_rf_name(u16 rf_version)
87         return "????";
88  }
89  
90 +static void ath_pci_cleanup(struct ath_softc *sc)
91 +{
92 +       struct pci_dev *pdev = to_pci_dev(sc->dev);
93 +
94 +       pci_iounmap(pdev, sc->mem);
95 +       pci_release_region(pdev, 0);
96 +       pci_disable_device(pdev);
97 +}
98 +
99  static struct ath_bus_ops ath_pci_bus_ops = {
100         .read_cachesize = ath_pci_read_cachesize,
101 +       .cleanup = ath_pci_cleanup,
102  };
103  
104  static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
105 @@ -2646,6 +2659,8 @@ static int ath_pci_probe(struct pci_dev 
106                 goto bad4;
107         }
108  
109 +       sc->irq = pdev->irq;
110 +
111         ah = sc->sc_ah;
112         printk(KERN_INFO
113                "%s: Atheros AR%s MAC/BB Rev:%x "
114 @@ -2676,13 +2691,7 @@ static void ath_pci_remove(struct pci_de
115         struct ieee80211_hw *hw = pci_get_drvdata(pdev);
116         struct ath_softc *sc = hw->priv;
117  
118 -       ath_detach(sc);
119 -       if (pdev->irq)
120 -               free_irq(pdev->irq, sc);
121 -       pci_iounmap(pdev, sc->mem);
122 -       pci_release_region(pdev, 0);
123 -       pci_disable_device(pdev);
124 -       ieee80211_free_hw(hw);
125 +       ath_cleanup(sc);
126  }
127  
128  #ifdef CONFIG_PM