| 1 |
Send to: [email protected], [email protected], [email protected] |
| 2 |
|
| 3 |
Subject: [PATCH 1/2]: drivers/char: remove unnecessary pci_dev_put |
| 4 |
|
| 5 |
--------------------------------------- |
| 6 |
|
| 7 |
From: Julia Lawall <[email protected]> |
| 8 |
|
| 9 |
pci_get_class implicitly does a pci_dev_put on its second argument, so |
| 10 |
pci_dev_put is only needed if there is a break out of the loop. |
| 11 |
|
| 12 |
The semantic match detecting this problem is as follows: |
| 13 |
|
| 14 |
// <smpl> |
| 15 |
@@ |
| 16 |
expression dev; |
| 17 |
expression E; |
| 18 |
@@ |
| 19 |
|
| 20 |
* pci_dev_put(dev) |
| 21 |
... when != dev = E |
| 22 |
( |
| 23 |
* pci_get_device(...,dev) |
| 24 |
| |
| 25 |
* pci_get_device_reverse(...,dev) |
| 26 |
| |
| 27 |
* pci_get_subsys(...,dev) |
| 28 |
| |
| 29 |
* pci_get_class(...,dev) |
| 30 |
) |
| 31 |
// </smpl> |
| 32 |
|
| 33 |
Signed-off-by: Julia Lawall <[email protected]> |
| 34 |
--- |
| 35 |
|
| 36 |
diff -up a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c |
| 37 |
--- a/drivers/char/agp/amd-k7-agp.c 2007-11-15 07:33:31.000000000 +0100 |
| 38 |
+++ b/drivers/char/agp/amd-k7-agp.c 2007-11-15 07:40:48.000000000 +0100 |
| 39 |
@@ -436,10 +436,6 @@ static int __devinit agp_amdk7_probe(str |
| 40 |
return -ENODEV; |
| 41 |
} |
| 42 |
cap_ptr = pci_find_capability(gfxcard, PCI_CAP_ID_AGP); |
| 43 |
- if (!cap_ptr) { |
| 44 |
- pci_dev_put(gfxcard); |
| 45 |
- continue; |
| 46 |
- } |
| 47 |
} |
| 48 |
|
| 49 |
/* With so many variants of NVidia cards, it's simpler just |