aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-stub.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-09-03 02:27:27 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-09-09 16:44:34 -0400
commitb439b1d4e3ae3c36ed94ed233119ff0d145af257 (patch)
tree073a9a0acdeb203bd7735a0a91c2b5f397f74852 /drivers/pci/pci-stub.c
parent9dba910e9de2c4aa15ec1286f10052c107ef48ca (diff)
PCI: pci-stub: add pci_stub.ids parameter
Add ids module parameter which allows specifying initial IDs for the pci-stub driver. When built into the kernel, pci-stub is linked before any real pci drivers and by setting up IDs from initialization it can prevent built-in drivers from attaching to specific devices. While at it, make pci_stub_probe() print out about devices it grabbed to weed out "but my controller isn't being probed" bug reports. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci-stub.c')
-rw-r--r--drivers/pci/pci-stub.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c
index 74fbec0bf6c..f7b68ca6cc9 100644
--- a/drivers/pci/pci-stub.c
+++ b/drivers/pci/pci-stub.c
@@ -19,8 +19,16 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
21 21
22static char ids[1024] __initdata;
23
24module_param_string(ids, ids, sizeof(ids), 0);
25MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the stub driver, format is "
26 "\"vendor:device[:subvendor[:subdevice[:class[:class_mask]]]]\""
27 " and multiple comma separated entries can be specified");
28
22static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) 29static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)
23{ 30{
31 dev_printk(KERN_INFO, &dev->dev, "claimed by stub\n");
24 return 0; 32 return 0;
25} 33}
26 34
@@ -32,7 +40,42 @@ static struct pci_driver stub_driver = {
32 40
33static int __init pci_stub_init(void) 41static int __init pci_stub_init(void)
34{ 42{
35 return pci_register_driver(&stub_driver); 43 char *p, *id;
44 int rc;
45
46 rc = pci_register_driver(&stub_driver);
47 if (rc)
48 return rc;
49
50 /* add ids specified in the module parameter */
51 p = ids;
52 while ((id = strsep(&p, ","))) {
53 unsigned int vendor, device, subvendor = PCI_ANY_ID,
54 subdevice = PCI_ANY_ID, class=0, class_mask=0;
55 int fields;
56
57 fields = sscanf(id, "%x:%x:%x:%x:%x:%x",
58 &vendor, &device, &subvendor, &subdevice,
59 &class, &class_mask);
60
61 if (fields < 2) {
62 printk(KERN_WARNING
63 "pci-stub: invalid id string \"%s\"\n", id);
64 continue;
65 }
66
67 printk(KERN_INFO
68 "pci-stub: add %04X:%04X sub=%04X:%04X cls=%08X/%08X\n",
69 vendor, device, subvendor, subdevice, class, class_mask);
70
71 rc = pci_add_dynid(&stub_driver, vendor, device,
72 subvendor, subdevice, class, class_mask, 0);
73 if (rc)
74 printk(KERN_WARNING
75 "pci-stub: failed to add dynamic id (%d)\n", rc);
76 }
77
78 return 0;
36} 79}
37 80
38static void __exit pci_stub_exit(void) 81static void __exit pci_stub_exit(void)