diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-12-12 07:14:22 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-01-07 15:16:51 -0500 |
commit | b81950b165ff71d826fcac851153f9265a83d9ab (patch) | |
tree | deca23d16027c10c0ef0a33831b424b51e74dd7b /drivers/net/wireless/ath/ath9k/pci.c | |
parent | d5374ef13ebda6ec93f0b4af6b30682ea4b14782 (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/ath9k/pci.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/pci.c | 39 |
1 files changed, 8 insertions, 31 deletions
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 | ||
148 | static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 148 | static 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); |
260 | err_irq: | 250 | err_irq: |
261 | ieee80211_free_hw(hw); | 251 | ieee80211_free_hw(hw); |
262 | err_alloc_hw: | ||
263 | pci_iounmap(pdev, mem); | ||
264 | err_iomap: | ||
265 | pci_release_region(pdev, 0); | ||
266 | err_region: | ||
267 | /* Nothing */ | ||
268 | err_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 |