2 * support for probing IDE PCI devices in the PCI bus order
4 * Copyright (c) 1998-2000 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (c) 1995-1998 Mark Lord
7 * May be copied or modified under the terms of the GNU General Public License
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/ide.h>
19 static int pre_init
= 1; /* Before first ordered IDE scan */
20 static LIST_HEAD(ide_pci_drivers
);
23 * __ide_pci_register_driver - attach IDE driver
25 * @module: owner module of the driver
27 * Registers a driver with the IDE layer. The IDE layer arranges that
28 * boot time setup is done in the expected device order and then
29 * hands the controllers off to the core PCI code to do the rest of
32 * Returns are the same as for pci_register_driver
35 int __ide_pci_register_driver(struct pci_driver
*driver
, struct module
*module
,
39 return __pci_register_driver(driver
, module
, mod_name
);
40 driver
->driver
.owner
= module
;
41 list_add_tail(&driver
->node
, &ide_pci_drivers
);
44 EXPORT_SYMBOL_GPL(__ide_pci_register_driver
);
47 * ide_scan_pcidev - find an IDE driver for a device
48 * @dev: PCI device to check
50 * Look for an IDE driver to handle the device we are considering.
51 * This is only used during boot up to get the ordering correct. After
52 * boot up the pci layer takes over the job.
55 static int __init
ide_scan_pcidev(struct pci_dev
*dev
)
60 list_for_each(l
, &ide_pci_drivers
) {
61 d
= list_entry(l
, struct pci_driver
, node
);
63 const struct pci_device_id
*id
=
64 pci_match_id(d
->id_table
, dev
);
66 if (id
!= NULL
&& d
->probe(dev
, id
) >= 0) {
77 * ide_scan_pcibus - perform the initial IDE driver scan
79 * Perform the initial bus rather than driver ordered scan of the
80 * PCI drivers. After this all IDE pci handling becomes standard
81 * module ordering not traditionally ordered.
84 static int __init
ide_scan_pcibus(void)
86 struct pci_dev
*dev
= NULL
;
88 struct list_head
*l
, *n
;
91 if (!ide_scan_direction
)
92 while ((dev
= pci_get_device(PCI_ANY_ID
, PCI_ANY_ID
, dev
)))
95 while ((dev
= pci_get_device_reverse(PCI_ANY_ID
, PCI_ANY_ID
,
100 * Hand the drivers over to the PCI layer now we
104 list_for_each_safe(l
, n
, &ide_pci_drivers
) {
106 d
= list_entry(l
, struct pci_driver
, node
);
107 if (__pci_register_driver(d
, d
->driver
.owner
,
109 printk(KERN_ERR
"%s: failed to register %s driver\n",
110 __FUNCTION__
, d
->driver
.mod_name
);
116 module_init(ide_scan_pcibus
);