aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorKulikov Vasiliy <segooon@gmail.com>2010-08-03 11:43:22 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-04 15:28:37 -0400
commit47cb905d6b1f46bf403998f4838baa3f3b597391 (patch)
tree08de40b5141e70b434d5f77bbc44898c83a2c67c /drivers/net/wireless/rt2x00
parent93c08c32914264f539baf7f04cce310a0dd30a7a (diff)
rt2x00: do not use PCI resources before pci_enable_device()
IRQ and resource[] may not have correct values until after PCI hotplug setup occurs at pci_enable_device() time. The semantic match that finds this problem is as follows: // <smpl> @@ identifier x; identifier request ~= "pci_request.*|pci_resource.*"; @@ ( * x->irq | * x->resource | * request(x, ...) ) ... *pci_enable_device(x) // </smpl> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 19b262e1ddbe..63c2cc408e15 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -240,16 +240,16 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
240 struct rt2x00_dev *rt2x00dev; 240 struct rt2x00_dev *rt2x00dev;
241 int retval; 241 int retval;
242 242
243 retval = pci_request_regions(pci_dev, pci_name(pci_dev)); 243 retval = pci_enable_device(pci_dev);
244 if (retval) { 244 if (retval) {
245 ERROR_PROBE("PCI request regions failed.\n"); 245 ERROR_PROBE("Enable device failed.\n");
246 return retval; 246 return retval;
247 } 247 }
248 248
249 retval = pci_enable_device(pci_dev); 249 retval = pci_request_regions(pci_dev, pci_name(pci_dev));
250 if (retval) { 250 if (retval) {
251 ERROR_PROBE("Enable device failed.\n"); 251 ERROR_PROBE("PCI request regions failed.\n");
252 goto exit_release_regions; 252 goto exit_disable_device;
253 } 253 }
254 254
255 pci_set_master(pci_dev); 255 pci_set_master(pci_dev);
@@ -260,14 +260,14 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
260 if (dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) { 260 if (dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) {
261 ERROR_PROBE("PCI DMA not supported.\n"); 261 ERROR_PROBE("PCI DMA not supported.\n");
262 retval = -EIO; 262 retval = -EIO;
263 goto exit_disable_device; 263 goto exit_release_regions;
264 } 264 }
265 265
266 hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw); 266 hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
267 if (!hw) { 267 if (!hw) {
268 ERROR_PROBE("Failed to allocate hardware.\n"); 268 ERROR_PROBE("Failed to allocate hardware.\n");
269 retval = -ENOMEM; 269 retval = -ENOMEM;
270 goto exit_disable_device; 270 goto exit_release_regions;
271 } 271 }
272 272
273 pci_set_drvdata(pci_dev, hw); 273 pci_set_drvdata(pci_dev, hw);
@@ -300,13 +300,12 @@ exit_free_reg:
300exit_free_device: 300exit_free_device:
301 ieee80211_free_hw(hw); 301 ieee80211_free_hw(hw);
302 302
303exit_disable_device:
304 if (retval != -EBUSY)
305 pci_disable_device(pci_dev);
306
307exit_release_regions: 303exit_release_regions:
308 pci_release_regions(pci_dev); 304 pci_release_regions(pci_dev);
309 305
306exit_disable_device:
307 pci_disable_device(pci_dev);
308
310 pci_set_drvdata(pci_dev, NULL); 309 pci_set_drvdata(pci_dev, NULL);
311 310
312 return retval; 311 return retval;