diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2007-09-11 16:28:34 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-09-11 16:28:34 -0400 |
commit | 0505b55fb51fa289027f33ae793995c191277536 (patch) | |
tree | b6d4d6d7af1ce177f61e93e0fa9878c1a3199a44 /drivers/ide/setup-pci.c | |
parent | dc4b6fd620aec395048b2877daca87ba7bfcd5e0 (diff) |
ide: fix PCI refcounting
The IDE core never marked the PCI IDE devices as being in use after succesfull
driver probe call (the devices were marked in use only while being probed), and
so was susceptible to issues caused by unsolicited PCI hotplug device removal.
So, add pci_dev_get() call to ide_scan_pcidev() and convert this function to
the kernel style, also dropping a bunch of useless curly braces from its caller,
ide_scan_pcibus() and somewhat beautifying printk() call there, while at it...
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 30e596c0f120..1129f8c30840 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -816,19 +816,15 @@ static int __init ide_scan_pcidev(struct pci_dev *dev) | |||
816 | struct list_head *l; | 816 | struct list_head *l; |
817 | struct pci_driver *d; | 817 | struct pci_driver *d; |
818 | 818 | ||
819 | list_for_each(l, &ide_pci_drivers) | 819 | list_for_each(l, &ide_pci_drivers) { |
820 | { | ||
821 | d = list_entry(l, struct pci_driver, node); | 820 | d = list_entry(l, struct pci_driver, node); |
822 | if(d->id_table) | 821 | if (d->id_table) { |
823 | { | 822 | const struct pci_device_id *id = pci_match_id(d->id_table, |
824 | const struct pci_device_id *id = pci_match_id(d->id_table, dev); | 823 | dev); |
825 | if(id != NULL) | 824 | if (id != NULL && d->probe(dev, id) >= 0) { |
826 | { | 825 | dev->driver = d; |
827 | if(d->probe(dev, id) >= 0) | 826 | pci_dev_get(dev); |
828 | { | 827 | return 1; |
829 | dev->driver = d; | ||
830 | return 1; | ||
831 | } | ||
832 | } | 828 | } |
833 | } | 829 | } |
834 | } | 830 | } |
@@ -851,15 +847,13 @@ void __init ide_scan_pcibus (int scan_direction) | |||
851 | struct list_head *l, *n; | 847 | struct list_head *l, *n; |
852 | 848 | ||
853 | pre_init = 0; | 849 | pre_init = 0; |
854 | if (!scan_direction) { | 850 | if (!scan_direction) |
855 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 851 | while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) |
856 | ide_scan_pcidev(dev); | 852 | ide_scan_pcidev(dev); |
857 | } | 853 | else |
858 | } else { | 854 | while ((dev = pci_get_device_reverse(PCI_ANY_ID, PCI_ANY_ID, dev)) |
859 | while ((dev = pci_get_device_reverse(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { | 855 | != NULL) |
860 | ide_scan_pcidev(dev); | 856 | ide_scan_pcidev(dev); |
861 | } | ||
862 | } | ||
863 | 857 | ||
864 | /* | 858 | /* |
865 | * Hand the drivers over to the PCI layer now we | 859 | * Hand the drivers over to the PCI layer now we |
@@ -869,12 +863,9 @@ void __init ide_scan_pcibus (int scan_direction) | |||
869 | list_for_each_safe(l, n, &ide_pci_drivers) { | 863 | list_for_each_safe(l, n, &ide_pci_drivers) { |
870 | list_del(l); | 864 | list_del(l); |
871 | d = list_entry(l, struct pci_driver, node); | 865 | d = list_entry(l, struct pci_driver, node); |
872 | if (__pci_register_driver(d, d->driver.owner, | 866 | if (__pci_register_driver(d, d->driver.owner, d->driver.mod_name)) |
873 | d->driver.mod_name)) { | 867 | printk(KERN_ERR "%s: failed to register driver for %s\n", |
874 | printk(KERN_ERR "%s: failed to register driver " | 868 | __FUNCTION__, d->driver.mod_name); |
875 | "for %s\n", __FUNCTION__, | ||
876 | d->driver.mod_name); | ||
877 | } | ||
878 | } | 869 | } |
879 | } | 870 | } |
880 | #endif | 871 | #endif |