Commit c22610dadc0452b1273494f2b5157123c6cd60e1
Committed by
Greg KH
1 parent
43b7d7cfb1
Exists in
master
and in
7 other branches
[PATCH] PCI Hotplug: remove pci_visit_dev
If my CPCI hotplug update patch is applied, then there are no longer any in tree users of the pci_visit_dev API, and it and its related code can be removed. Signed-off-by: Scott Murray <scottm@somanetworks.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 2 changed files with 0 additions and 136 deletions Inline Diff
drivers/pci/hotplug.c
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/pci.h> | 2 | #include <linux/pci.h> |
3 | #include <linux/module.h> | 3 | #include <linux/module.h> |
4 | #include "pci.h" | 4 | #include "pci.h" |
5 | 5 | ||
6 | int pci_hotplug (struct device *dev, char **envp, int num_envp, | 6 | int pci_hotplug (struct device *dev, char **envp, int num_envp, |
7 | char *buffer, int buffer_size) | 7 | char *buffer, int buffer_size) |
8 | { | 8 | { |
9 | struct pci_dev *pdev; | 9 | struct pci_dev *pdev; |
10 | char *scratch; | 10 | char *scratch; |
11 | int i = 0; | 11 | int i = 0; |
12 | int length = 0; | 12 | int length = 0; |
13 | 13 | ||
14 | if (!dev) | 14 | if (!dev) |
15 | return -ENODEV; | 15 | return -ENODEV; |
16 | 16 | ||
17 | pdev = to_pci_dev(dev); | 17 | pdev = to_pci_dev(dev); |
18 | if (!pdev) | 18 | if (!pdev) |
19 | return -ENODEV; | 19 | return -ENODEV; |
20 | 20 | ||
21 | scratch = buffer; | 21 | scratch = buffer; |
22 | 22 | ||
23 | /* stuff we want to pass to /sbin/hotplug */ | 23 | /* stuff we want to pass to /sbin/hotplug */ |
24 | envp[i++] = scratch; | 24 | envp[i++] = scratch; |
25 | length += scnprintf (scratch, buffer_size - length, "PCI_CLASS=%04X", | 25 | length += scnprintf (scratch, buffer_size - length, "PCI_CLASS=%04X", |
26 | pdev->class); | 26 | pdev->class); |
27 | if ((buffer_size - length <= 0) || (i >= num_envp)) | 27 | if ((buffer_size - length <= 0) || (i >= num_envp)) |
28 | return -ENOMEM; | 28 | return -ENOMEM; |
29 | ++length; | 29 | ++length; |
30 | scratch += length; | 30 | scratch += length; |
31 | 31 | ||
32 | envp[i++] = scratch; | 32 | envp[i++] = scratch; |
33 | length += scnprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X", | 33 | length += scnprintf (scratch, buffer_size - length, "PCI_ID=%04X:%04X", |
34 | pdev->vendor, pdev->device); | 34 | pdev->vendor, pdev->device); |
35 | if ((buffer_size - length <= 0) || (i >= num_envp)) | 35 | if ((buffer_size - length <= 0) || (i >= num_envp)) |
36 | return -ENOMEM; | 36 | return -ENOMEM; |
37 | ++length; | 37 | ++length; |
38 | scratch += length; | 38 | scratch += length; |
39 | 39 | ||
40 | envp[i++] = scratch; | 40 | envp[i++] = scratch; |
41 | length += scnprintf (scratch, buffer_size - length, | 41 | length += scnprintf (scratch, buffer_size - length, |
42 | "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, | 42 | "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, |
43 | pdev->subsystem_device); | 43 | pdev->subsystem_device); |
44 | if ((buffer_size - length <= 0) || (i >= num_envp)) | 44 | if ((buffer_size - length <= 0) || (i >= num_envp)) |
45 | return -ENOMEM; | 45 | return -ENOMEM; |
46 | ++length; | 46 | ++length; |
47 | scratch += length; | 47 | scratch += length; |
48 | 48 | ||
49 | envp[i++] = scratch; | 49 | envp[i++] = scratch; |
50 | length += scnprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s", | 50 | length += scnprintf (scratch, buffer_size - length, "PCI_SLOT_NAME=%s", |
51 | pci_name(pdev)); | 51 | pci_name(pdev)); |
52 | if ((buffer_size - length <= 0) || (i >= num_envp)) | 52 | if ((buffer_size - length <= 0) || (i >= num_envp)) |
53 | return -ENOMEM; | 53 | return -ENOMEM; |
54 | 54 | ||
55 | envp[i] = NULL; | 55 | envp[i] = NULL; |
56 | 56 | ||
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | |||
60 | static int pci_visit_bus (struct pci_visit * fn, struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_parent) | ||
61 | { | ||
62 | struct list_head *ln; | ||
63 | struct pci_dev *dev; | ||
64 | struct pci_dev_wrapped wrapped_dev; | ||
65 | int result = 0; | ||
66 | |||
67 | pr_debug("PCI: Scanning bus %04x:%02x\n", pci_domain_nr(wrapped_bus->bus), | ||
68 | wrapped_bus->bus->number); | ||
69 | |||
70 | if (fn->pre_visit_pci_bus) { | ||
71 | result = fn->pre_visit_pci_bus(wrapped_bus, wrapped_parent); | ||
72 | if (result) | ||
73 | return result; | ||
74 | } | ||
75 | |||
76 | ln = wrapped_bus->bus->devices.next; | ||
77 | while (ln != &wrapped_bus->bus->devices) { | ||
78 | dev = pci_dev_b(ln); | ||
79 | ln = ln->next; | ||
80 | |||
81 | memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped)); | ||
82 | wrapped_dev.dev = dev; | ||
83 | |||
84 | result = pci_visit_dev(fn, &wrapped_dev, wrapped_bus); | ||
85 | if (result) | ||
86 | return result; | ||
87 | } | ||
88 | |||
89 | if (fn->post_visit_pci_bus) | ||
90 | result = fn->post_visit_pci_bus(wrapped_bus, wrapped_parent); | ||
91 | |||
92 | return result; | ||
93 | } | ||
94 | |||
95 | static int pci_visit_bridge (struct pci_visit * fn, | ||
96 | struct pci_dev_wrapped *wrapped_dev, | ||
97 | struct pci_bus_wrapped *wrapped_parent) | ||
98 | { | ||
99 | struct pci_bus *bus; | ||
100 | struct pci_bus_wrapped wrapped_bus; | ||
101 | int result = 0; | ||
102 | |||
103 | pr_debug("PCI: Scanning bridge %s\n", pci_name(wrapped_dev->dev)); | ||
104 | |||
105 | if (fn->visit_pci_dev) { | ||
106 | result = fn->visit_pci_dev(wrapped_dev, wrapped_parent); | ||
107 | if (result) | ||
108 | return result; | ||
109 | } | ||
110 | |||
111 | bus = wrapped_dev->dev->subordinate; | ||
112 | if (bus) { | ||
113 | memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped)); | ||
114 | wrapped_bus.bus = bus; | ||
115 | |||
116 | result = pci_visit_bus(fn, &wrapped_bus, wrapped_dev); | ||
117 | } | ||
118 | return result; | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * pci_visit_dev - scans the pci buses. | ||
123 | * @fn: callback functions that are called while visiting | ||
124 | * @wrapped_dev: the device to scan | ||
125 | * @wrapped_parent: the bus where @wrapped_dev is connected to | ||
126 | * | ||
127 | * Every bus and every function is presented to a custom | ||
128 | * function that can act upon it. | ||
129 | */ | ||
130 | int pci_visit_dev(struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev, | ||
131 | struct pci_bus_wrapped *wrapped_parent) | ||
132 | { | ||
133 | struct pci_dev* dev = wrapped_dev ? wrapped_dev->dev : NULL; | ||
134 | int result = 0; | ||
135 | |||
136 | if (!dev) | ||
137 | return 0; | ||
138 | |||
139 | if (fn->pre_visit_pci_dev) { | ||
140 | result = fn->pre_visit_pci_dev(wrapped_dev, wrapped_parent); | ||
141 | if (result) | ||
142 | return result; | ||
143 | } | ||
144 | |||
145 | switch (dev->class >> 8) { | ||
146 | case PCI_CLASS_BRIDGE_PCI: | ||
147 | result = pci_visit_bridge(fn, wrapped_dev, | ||
148 | wrapped_parent); | ||
149 | if (result) | ||
150 | return result; | ||
151 | break; | ||
152 | default: | ||
153 | pr_debug("PCI: Scanning device %s\n", pci_name(dev)); | ||
154 | if (fn->visit_pci_dev) { | ||
155 | result = fn->visit_pci_dev (wrapped_dev, | ||
156 | wrapped_parent); | ||
157 | if (result) | ||
158 | return result; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | if (fn->post_visit_pci_dev) | ||
163 | result = fn->post_visit_pci_dev(wrapped_dev, wrapped_parent); | ||
164 | |||
165 | return result; | ||
166 | } | ||
167 | EXPORT_SYMBOL(pci_visit_dev); | ||
168 | 59 |
drivers/pci/pci.h
1 | /* Functions internal to the PCI core code */ | 1 | /* Functions internal to the PCI core code */ |
2 | 2 | ||
3 | extern int pci_hotplug (struct device *dev, char **envp, int num_envp, | 3 | extern int pci_hotplug (struct device *dev, char **envp, int num_envp, |
4 | char *buffer, int buffer_size); | 4 | char *buffer, int buffer_size); |
5 | extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); | 5 | extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); |
6 | extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); | 6 | extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); |
7 | extern void pci_cleanup_rom(struct pci_dev *dev); | 7 | extern void pci_cleanup_rom(struct pci_dev *dev); |
8 | extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, | 8 | extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, |
9 | unsigned long size, unsigned long align, | 9 | unsigned long size, unsigned long align, |
10 | unsigned long min, unsigned int type_mask, | 10 | unsigned long min, unsigned int type_mask, |
11 | void (*alignf)(void *, struct resource *, | 11 | void (*alignf)(void *, struct resource *, |
12 | unsigned long, unsigned long), | 12 | unsigned long, unsigned long), |
13 | void *alignf_data); | 13 | void *alignf_data); |
14 | /* PCI /proc functions */ | 14 | /* PCI /proc functions */ |
15 | #ifdef CONFIG_PROC_FS | 15 | #ifdef CONFIG_PROC_FS |
16 | extern int pci_proc_attach_device(struct pci_dev *dev); | 16 | extern int pci_proc_attach_device(struct pci_dev *dev); |
17 | extern int pci_proc_detach_device(struct pci_dev *dev); | 17 | extern int pci_proc_detach_device(struct pci_dev *dev); |
18 | extern int pci_proc_attach_bus(struct pci_bus *bus); | 18 | extern int pci_proc_attach_bus(struct pci_bus *bus); |
19 | extern int pci_proc_detach_bus(struct pci_bus *bus); | 19 | extern int pci_proc_detach_bus(struct pci_bus *bus); |
20 | #else | 20 | #else |
21 | static inline int pci_proc_attach_device(struct pci_dev *dev) { return 0; } | 21 | static inline int pci_proc_attach_device(struct pci_dev *dev) { return 0; } |
22 | static inline int pci_proc_detach_device(struct pci_dev *dev) { return 0; } | 22 | static inline int pci_proc_detach_device(struct pci_dev *dev) { return 0; } |
23 | static inline int pci_proc_attach_bus(struct pci_bus *bus) { return 0; } | 23 | static inline int pci_proc_attach_bus(struct pci_bus *bus) { return 0; } |
24 | static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } | 24 | static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | /* Functions for PCI Hotplug drivers to use */ | 27 | /* Functions for PCI Hotplug drivers to use */ |
28 | extern struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); | 28 | extern struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); |
29 | extern unsigned int pci_do_scan_bus(struct pci_bus *bus); | 29 | extern unsigned int pci_do_scan_bus(struct pci_bus *bus); |
30 | extern int pci_remove_device_safe(struct pci_dev *dev); | 30 | extern int pci_remove_device_safe(struct pci_dev *dev); |
31 | extern unsigned char pci_max_busnr(void); | 31 | extern unsigned char pci_max_busnr(void); |
32 | extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); | 32 | extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); |
33 | extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); | 33 | extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); |
34 | 34 | ||
35 | struct pci_dev_wrapped { | ||
36 | struct pci_dev *dev; | ||
37 | void *data; | ||
38 | }; | ||
39 | |||
40 | struct pci_bus_wrapped { | ||
41 | struct pci_bus *bus; | ||
42 | void *data; | ||
43 | }; | ||
44 | |||
45 | struct pci_visit { | ||
46 | int (* pre_visit_pci_bus) (struct pci_bus_wrapped *, | ||
47 | struct pci_dev_wrapped *); | ||
48 | int (* post_visit_pci_bus) (struct pci_bus_wrapped *, | ||
49 | struct pci_dev_wrapped *); | ||
50 | |||
51 | int (* pre_visit_pci_dev) (struct pci_dev_wrapped *, | ||
52 | struct pci_bus_wrapped *); | ||
53 | int (* visit_pci_dev) (struct pci_dev_wrapped *, | ||
54 | struct pci_bus_wrapped *); | ||
55 | int (* post_visit_pci_dev) (struct pci_dev_wrapped *, | ||
56 | struct pci_bus_wrapped *); | ||
57 | }; | ||
58 | |||
59 | extern int pci_visit_dev(struct pci_visit *fn, | ||
60 | struct pci_dev_wrapped *wrapped_dev, | ||
61 | struct pci_bus_wrapped *wrapped_parent); | ||
62 | extern void pci_remove_legacy_files(struct pci_bus *bus); | 35 | extern void pci_remove_legacy_files(struct pci_bus *bus); |
63 | 36 | ||
64 | /* Lock for read/write access to pci device and bus lists */ | 37 | /* Lock for read/write access to pci device and bus lists */ |
65 | extern spinlock_t pci_bus_lock; | 38 | extern spinlock_t pci_bus_lock; |
66 | 39 | ||
67 | #ifdef CONFIG_X86_IO_APIC | 40 | #ifdef CONFIG_X86_IO_APIC |
68 | extern int pci_msi_quirk; | 41 | extern int pci_msi_quirk; |
69 | #else | 42 | #else |
70 | #define pci_msi_quirk 0 | 43 | #define pci_msi_quirk 0 |
71 | #endif | 44 | #endif |
72 | 45 | ||
73 | extern int pcie_mch_quirk; | 46 | extern int pcie_mch_quirk; |
74 | extern struct device_attribute pci_dev_attrs[]; | 47 | extern struct device_attribute pci_dev_attrs[]; |
75 | extern struct class_device_attribute class_device_attr_cpuaffinity; | 48 | extern struct class_device_attribute class_device_attr_cpuaffinity; |
76 | 49 | ||
77 | /** | 50 | /** |
78 | * pci_match_one_device - Tell if a PCI device structure has a matching | 51 | * pci_match_one_device - Tell if a PCI device structure has a matching |
79 | * PCI device id structure | 52 | * PCI device id structure |
80 | * @id: single PCI device id structure to match | 53 | * @id: single PCI device id structure to match |
81 | * @dev: the PCI device structure to match against | 54 | * @dev: the PCI device structure to match against |
82 | * | 55 | * |
83 | * Returns the matching pci_device_id structure or %NULL if there is no match. | 56 | * Returns the matching pci_device_id structure or %NULL if there is no match. |
84 | */ | 57 | */ |
85 | static inline const struct pci_device_id * | 58 | static inline const struct pci_device_id * |
86 | pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) | 59 | pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) |
87 | { | 60 | { |
88 | if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) && | 61 | if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) && |
89 | (id->device == PCI_ANY_ID || id->device == dev->device) && | 62 | (id->device == PCI_ANY_ID || id->device == dev->device) && |
90 | (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && | 63 | (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && |
91 | (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) && | 64 | (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) && |
92 | !((id->class ^ dev->class) & id->class_mask)) | 65 | !((id->class ^ dev->class) & id->class_mask)) |
93 | return id; | 66 | return id; |
94 | return NULL; | 67 | return NULL; |
95 | } | 68 | } |
96 | 69 | ||
97 | 70 |