diff options
author | Sujith <Sujith.Manoharan@atheros.com> | 2010-01-08 00:06:07 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-01-12 14:02:05 -0500 |
commit | 285f2ddae03ca207877262f5a9dbd9cddd8b3913 (patch) | |
tree | 7b26606956f4d6f4c1f564718769501b34d3f640 /drivers/net/wireless/ath/ath9k/pci.c | |
parent | 1b04b9308ebc7f6accb319cf51c9b8ec29f79707 (diff) |
ath9k: Cleanup init/deinit routines
The device initialization and termination functions
were messy and convoluted. Introduce helper functions
to clarify init_softc() and simplify things in general.
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/pci.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/pci.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c index f7af5ea54753..95b9a07597ef 100644 --- a/drivers/net/wireless/ath/ath9k/pci.c +++ b/drivers/net/wireless/ath/ath9k/pci.c | |||
@@ -113,25 +113,22 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
113 | u16 subsysid; | 113 | u16 subsysid; |
114 | u32 val; | 114 | u32 val; |
115 | int ret = 0; | 115 | int ret = 0; |
116 | struct ath_hw *ah; | ||
117 | char hw_name[64]; | 116 | char hw_name[64]; |
118 | 117 | ||
119 | if (pci_enable_device(pdev)) | 118 | if (pci_enable_device(pdev)) |
120 | return -EIO; | 119 | return -EIO; |
121 | 120 | ||
122 | ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 121 | ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
123 | |||
124 | if (ret) { | 122 | if (ret) { |
125 | printk(KERN_ERR "ath9k: 32-bit DMA not available\n"); | 123 | printk(KERN_ERR "ath9k: 32-bit DMA not available\n"); |
126 | goto bad; | 124 | goto err_dma; |
127 | } | 125 | } |
128 | 126 | ||
129 | ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); | 127 | ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
130 | |||
131 | if (ret) { | 128 | if (ret) { |
132 | printk(KERN_ERR "ath9k: 32-bit DMA consistent " | 129 | printk(KERN_ERR "ath9k: 32-bit DMA consistent " |
133 | "DMA enable failed\n"); | 130 | "DMA enable failed\n"); |
134 | goto bad; | 131 | goto err_dma; |
135 | } | 132 | } |
136 | 133 | ||
137 | /* | 134 | /* |
@@ -171,22 +168,22 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
171 | if (ret) { | 168 | if (ret) { |
172 | dev_err(&pdev->dev, "PCI memory region reserve error\n"); | 169 | dev_err(&pdev->dev, "PCI memory region reserve error\n"); |
173 | ret = -ENODEV; | 170 | ret = -ENODEV; |
174 | goto bad; | 171 | goto err_region; |
175 | } | 172 | } |
176 | 173 | ||
177 | mem = pci_iomap(pdev, 0, 0); | 174 | mem = pci_iomap(pdev, 0, 0); |
178 | if (!mem) { | 175 | if (!mem) { |
179 | printk(KERN_ERR "PCI memory map error\n") ; | 176 | printk(KERN_ERR "PCI memory map error\n") ; |
180 | ret = -EIO; | 177 | ret = -EIO; |
181 | goto bad1; | 178 | goto err_iomap; |
182 | } | 179 | } |
183 | 180 | ||
184 | hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy) + | 181 | hw = ieee80211_alloc_hw(sizeof(struct ath_wiphy) + |
185 | sizeof(struct ath_softc), &ath9k_ops); | 182 | sizeof(struct ath_softc), &ath9k_ops); |
186 | if (!hw) { | 183 | if (!hw) { |
187 | dev_err(&pdev->dev, "no memory for ieee80211_hw\n"); | 184 | dev_err(&pdev->dev, "No memory for ieee80211_hw\n"); |
188 | ret = -ENOMEM; | 185 | ret = -ENOMEM; |
189 | goto bad2; | 186 | goto err_alloc_hw; |
190 | } | 187 | } |
191 | 188 | ||
192 | SET_IEEE80211_DEV(hw, &pdev->dev); | 189 | SET_IEEE80211_DEV(hw, &pdev->dev); |
@@ -201,25 +198,22 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
201 | sc->dev = &pdev->dev; | 198 | sc->dev = &pdev->dev; |
202 | sc->mem = mem; | 199 | sc->mem = mem; |
203 | 200 | ||
204 | pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsysid); | ||
205 | ret = ath_init_device(id->device, sc, subsysid, &ath_pci_bus_ops); | ||
206 | if (ret) { | ||
207 | dev_err(&pdev->dev, "failed to initialize device\n"); | ||
208 | goto bad3; | ||
209 | } | ||
210 | |||
211 | /* setup interrupt service routine */ | ||
212 | |||
213 | ret = request_irq(pdev->irq, ath_isr, IRQF_SHARED, "ath9k", sc); | 201 | ret = request_irq(pdev->irq, ath_isr, IRQF_SHARED, "ath9k", sc); |
214 | if (ret) { | 202 | if (ret) { |
215 | dev_err(&pdev->dev, "request_irq failed\n"); | 203 | dev_err(&pdev->dev, "request_irq failed\n"); |
216 | goto bad4; | 204 | goto err_irq; |
217 | } | 205 | } |
218 | 206 | ||
219 | sc->irq = pdev->irq; | 207 | sc->irq = pdev->irq; |
220 | 208 | ||
221 | ah = sc->sc_ah; | 209 | pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsysid); |
222 | ath9k_hw_name(ah, hw_name, sizeof(hw_name)); | 210 | ret = ath9k_init_device(id->device, sc, subsysid, &ath_pci_bus_ops); |
211 | if (ret) { | ||
212 | dev_err(&pdev->dev, "Failed to initialize device\n"); | ||
213 | goto err_init; | ||
214 | } | ||
215 | |||
216 | ath9k_hw_name(sc->sc_ah, hw_name, sizeof(hw_name)); | ||
223 | printk(KERN_INFO | 217 | printk(KERN_INFO |
224 | "%s: %s mem=0x%lx, irq=%d\n", | 218 | "%s: %s mem=0x%lx, irq=%d\n", |
225 | wiphy_name(hw->wiphy), | 219 | wiphy_name(hw->wiphy), |
@@ -227,15 +221,18 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
227 | (unsigned long)mem, pdev->irq); | 221 | (unsigned long)mem, pdev->irq); |
228 | 222 | ||
229 | return 0; | 223 | return 0; |
230 | bad4: | 224 | |
231 | ath_detach(sc); | 225 | err_init: |
232 | bad3: | 226 | free_irq(sc->irq, sc); |
227 | err_irq: | ||
233 | ieee80211_free_hw(hw); | 228 | ieee80211_free_hw(hw); |
234 | bad2: | 229 | err_alloc_hw: |
235 | pci_iounmap(pdev, mem); | 230 | pci_iounmap(pdev, mem); |
236 | bad1: | 231 | err_iomap: |
237 | pci_release_region(pdev, 0); | 232 | pci_release_region(pdev, 0); |
238 | bad: | 233 | err_region: |
234 | /* Nothing */ | ||
235 | err_dma: | ||
239 | pci_disable_device(pdev); | 236 | pci_disable_device(pdev); |
240 | return ret; | 237 | return ret; |
241 | } | 238 | } |
@@ -245,8 +242,12 @@ static void ath_pci_remove(struct pci_dev *pdev) | |||
245 | struct ieee80211_hw *hw = pci_get_drvdata(pdev); | 242 | struct ieee80211_hw *hw = pci_get_drvdata(pdev); |
246 | struct ath_wiphy *aphy = hw->priv; | 243 | struct ath_wiphy *aphy = hw->priv; |
247 | struct ath_softc *sc = aphy->sc; | 244 | struct ath_softc *sc = aphy->sc; |
245 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
248 | 246 | ||
249 | ath_cleanup(sc); | 247 | ath9k_deinit_device(sc); |
248 | free_irq(sc->irq, sc); | ||
249 | ieee80211_free_hw(sc->hw); | ||
250 | ath_bus_cleanup(common); | ||
250 | } | 251 | } |
251 | 252 | ||
252 | #ifdef CONFIG_PM | 253 | #ifdef CONFIG_PM |