diff options
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r-- | drivers/pci/pci-driver.c | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 3623d65f8b86..8d9616b821ca 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -72,9 +72,7 @@ int pci_add_dynid(struct pci_driver *drv, | |||
72 | list_add_tail(&dynid->node, &drv->dynids.list); | 72 | list_add_tail(&dynid->node, &drv->dynids.list); |
73 | spin_unlock(&drv->dynids.lock); | 73 | spin_unlock(&drv->dynids.lock); |
74 | 74 | ||
75 | get_driver(&drv->driver); | ||
76 | retval = driver_attach(&drv->driver); | 75 | retval = driver_attach(&drv->driver); |
77 | put_driver(&drv->driver); | ||
78 | 76 | ||
79 | return retval; | 77 | return retval; |
80 | } | 78 | } |
@@ -190,43 +188,34 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count) | |||
190 | static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); | 188 | static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); |
191 | 189 | ||
192 | static int | 190 | static int |
193 | pci_create_newid_file(struct pci_driver *drv) | 191 | pci_create_newid_files(struct pci_driver *drv) |
194 | { | 192 | { |
195 | int error = 0; | 193 | int error = 0; |
196 | if (drv->probe != NULL) | ||
197 | error = driver_create_file(&drv->driver, &driver_attr_new_id); | ||
198 | return error; | ||
199 | } | ||
200 | |||
201 | static void pci_remove_newid_file(struct pci_driver *drv) | ||
202 | { | ||
203 | driver_remove_file(&drv->driver, &driver_attr_new_id); | ||
204 | } | ||
205 | 194 | ||
206 | static int | 195 | if (drv->probe != NULL) { |
207 | pci_create_removeid_file(struct pci_driver *drv) | 196 | error = driver_create_file(&drv->driver, &driver_attr_new_id); |
208 | { | 197 | if (error == 0) { |
209 | int error = 0; | 198 | error = driver_create_file(&drv->driver, |
210 | if (drv->probe != NULL) | 199 | &driver_attr_remove_id); |
211 | error = driver_create_file(&drv->driver,&driver_attr_remove_id); | 200 | if (error) |
201 | driver_remove_file(&drv->driver, | ||
202 | &driver_attr_new_id); | ||
203 | } | ||
204 | } | ||
212 | return error; | 205 | return error; |
213 | } | 206 | } |
214 | 207 | ||
215 | static void pci_remove_removeid_file(struct pci_driver *drv) | 208 | static void pci_remove_newid_files(struct pci_driver *drv) |
216 | { | 209 | { |
217 | driver_remove_file(&drv->driver, &driver_attr_remove_id); | 210 | driver_remove_file(&drv->driver, &driver_attr_remove_id); |
211 | driver_remove_file(&drv->driver, &driver_attr_new_id); | ||
218 | } | 212 | } |
219 | #else /* !CONFIG_HOTPLUG */ | 213 | #else /* !CONFIG_HOTPLUG */ |
220 | static inline int pci_create_newid_file(struct pci_driver *drv) | 214 | static inline int pci_create_newid_files(struct pci_driver *drv) |
221 | { | 215 | { |
222 | return 0; | 216 | return 0; |
223 | } | 217 | } |
224 | static inline void pci_remove_newid_file(struct pci_driver *drv) {} | 218 | static inline void pci_remove_newid_files(struct pci_driver *drv) {} |
225 | static inline int pci_create_removeid_file(struct pci_driver *drv) | ||
226 | { | ||
227 | return 0; | ||
228 | } | ||
229 | static inline void pci_remove_removeid_file(struct pci_driver *drv) {} | ||
230 | #endif | 219 | #endif |
231 | 220 | ||
232 | /** | 221 | /** |
@@ -1138,18 +1127,12 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner, | |||
1138 | if (error) | 1127 | if (error) |
1139 | goto out; | 1128 | goto out; |
1140 | 1129 | ||
1141 | error = pci_create_newid_file(drv); | 1130 | error = pci_create_newid_files(drv); |
1142 | if (error) | 1131 | if (error) |
1143 | goto out_newid; | 1132 | goto out_newid; |
1144 | |||
1145 | error = pci_create_removeid_file(drv); | ||
1146 | if (error) | ||
1147 | goto out_removeid; | ||
1148 | out: | 1133 | out: |
1149 | return error; | 1134 | return error; |
1150 | 1135 | ||
1151 | out_removeid: | ||
1152 | pci_remove_newid_file(drv); | ||
1153 | out_newid: | 1136 | out_newid: |
1154 | driver_unregister(&drv->driver); | 1137 | driver_unregister(&drv->driver); |
1155 | goto out; | 1138 | goto out; |
@@ -1168,8 +1151,7 @@ out_newid: | |||
1168 | void | 1151 | void |
1169 | pci_unregister_driver(struct pci_driver *drv) | 1152 | pci_unregister_driver(struct pci_driver *drv) |
1170 | { | 1153 | { |
1171 | pci_remove_removeid_file(drv); | 1154 | pci_remove_newid_files(drv); |
1172 | pci_remove_newid_file(drv); | ||
1173 | driver_unregister(&drv->driver); | 1155 | driver_unregister(&drv->driver); |
1174 | pci_free_dynids(drv); | 1156 | pci_free_dynids(drv); |
1175 | } | 1157 | } |