aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c52
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)
190static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); 188static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
191 189
192static int 190static int
193pci_create_newid_file(struct pci_driver *drv) 191pci_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
201static void pci_remove_newid_file(struct pci_driver *drv)
202{
203 driver_remove_file(&drv->driver, &driver_attr_new_id);
204}
205 194
206static int 195 if (drv->probe != NULL) {
207pci_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
215static void pci_remove_removeid_file(struct pci_driver *drv) 208static 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 */
220static inline int pci_create_newid_file(struct pci_driver *drv) 214static inline int pci_create_newid_files(struct pci_driver *drv)
221{ 215{
222 return 0; 216 return 0;
223} 217}
224static inline void pci_remove_newid_file(struct pci_driver *drv) {} 218static inline void pci_remove_newid_files(struct pci_driver *drv) {}
225static inline int pci_create_removeid_file(struct pci_driver *drv)
226{
227 return 0;
228}
229static 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;
1148out: 1133out:
1149 return error; 1134 return error;
1150 1135
1151out_removeid:
1152 pci_remove_newid_file(drv);
1153out_newid: 1136out_newid:
1154 driver_unregister(&drv->driver); 1137 driver_unregister(&drv->driver);
1155 goto out; 1138 goto out;
@@ -1168,8 +1151,7 @@ out_newid:
1168void 1151void
1169pci_unregister_driver(struct pci_driver *drv) 1152pci_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}