diff options
author | Kulikov Vasiliy <segooon@gmail.com> | 2010-08-03 01:43:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-04 19:18:02 -0400 |
commit | 7aaaaa1e44b2a4047dfe05f304a5090eb995cf44 (patch) | |
tree | e8acddbddcfefd6b698c9061343b82baf0205d84 /drivers | |
parent | 3cfc2c42c1cbc8e238bb9c0612c0df4565e3a8b4 (diff) |
cxgb3: 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index 066fd5b09fda..ad19585d960b 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -3198,17 +3198,17 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
3198 | } | 3198 | } |
3199 | } | 3199 | } |
3200 | 3200 | ||
3201 | err = pci_request_regions(pdev, DRV_NAME); | 3201 | err = pci_enable_device(pdev); |
3202 | if (err) { | 3202 | if (err) { |
3203 | /* Just info, some other driver may have claimed the device. */ | 3203 | dev_err(&pdev->dev, "cannot enable PCI device\n"); |
3204 | dev_info(&pdev->dev, "cannot obtain PCI resources\n"); | 3204 | goto out; |
3205 | return err; | ||
3206 | } | 3205 | } |
3207 | 3206 | ||
3208 | err = pci_enable_device(pdev); | 3207 | err = pci_request_regions(pdev, DRV_NAME); |
3209 | if (err) { | 3208 | if (err) { |
3210 | dev_err(&pdev->dev, "cannot enable PCI device\n"); | 3209 | /* Just info, some other driver may have claimed the device. */ |
3211 | goto out_release_regions; | 3210 | dev_info(&pdev->dev, "cannot obtain PCI resources\n"); |
3211 | goto out_disable_device; | ||
3212 | } | 3212 | } |
3213 | 3213 | ||
3214 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { | 3214 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { |
@@ -3217,11 +3217,11 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
3217 | if (err) { | 3217 | if (err) { |
3218 | dev_err(&pdev->dev, "unable to obtain 64-bit DMA for " | 3218 | dev_err(&pdev->dev, "unable to obtain 64-bit DMA for " |
3219 | "coherent allocations\n"); | 3219 | "coherent allocations\n"); |
3220 | goto out_disable_device; | 3220 | goto out_release_regions; |
3221 | } | 3221 | } |
3222 | } else if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) { | 3222 | } else if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0) { |
3223 | dev_err(&pdev->dev, "no usable DMA configuration\n"); | 3223 | dev_err(&pdev->dev, "no usable DMA configuration\n"); |
3224 | goto out_disable_device; | 3224 | goto out_release_regions; |
3225 | } | 3225 | } |
3226 | 3226 | ||
3227 | pci_set_master(pdev); | 3227 | pci_set_master(pdev); |
@@ -3234,7 +3234,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
3234 | adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); | 3234 | adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); |
3235 | if (!adapter) { | 3235 | if (!adapter) { |
3236 | err = -ENOMEM; | 3236 | err = -ENOMEM; |
3237 | goto out_disable_device; | 3237 | goto out_release_regions; |
3238 | } | 3238 | } |
3239 | 3239 | ||
3240 | adapter->nofail_skb = | 3240 | adapter->nofail_skb = |
@@ -3370,11 +3370,12 @@ out_free_dev: | |||
3370 | out_free_adapter: | 3370 | out_free_adapter: |
3371 | kfree(adapter); | 3371 | kfree(adapter); |
3372 | 3372 | ||
3373 | out_disable_device: | ||
3374 | pci_disable_device(pdev); | ||
3375 | out_release_regions: | 3373 | out_release_regions: |
3376 | pci_release_regions(pdev); | 3374 | pci_release_regions(pdev); |
3375 | out_disable_device: | ||
3376 | pci_disable_device(pdev); | ||
3377 | pci_set_drvdata(pdev, NULL); | 3377 | pci_set_drvdata(pdev, NULL); |
3378 | out: | ||
3378 | return err; | 3379 | return err; |
3379 | } | 3380 | } |
3380 | 3381 | ||