aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2012-01-24 14:35:13 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2012-01-26 20:04:39 -0500
commited283e9f0a2cc0541870828c76c6c6997c51a318 (patch)
tree60950f46dae4af2cd8648e1c187a198e481904c7 /drivers/pci
parentfad12ac8c8c2591c7f4e61d19b6a9d76cd49fafa (diff)
USB/PCI/PCMCIA: Clean up new_id and remove_id sysfs attribute routines
This patch (as1514) cleans up some places where new_id and remove_id sysfs attributes are created and deleted. Handling both attributes in a single routine rather than a pair of routines makes the code smaller. It also prevents certain kinds of errors, like one we currently have in the USB subsystem: The removeid attribute is often created even when newid isn't (because the driver's no_dynamid_id flag is set). In the case of the PCMCIA subsystem, the newid attribute is created but never explicitly deleted. The patch adds a deletion routine. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org> Acked-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-driver.c50
1 files changed, 17 insertions, 33 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index ff540477fe8b..8d9616b821ca 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -188,43 +188,34 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count)
188static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); 188static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
189 189
190static int 190static int
191pci_create_newid_file(struct pci_driver *drv) 191pci_create_newid_files(struct pci_driver *drv)
192{ 192{
193 int error = 0; 193 int error = 0;
194 if (drv->probe != NULL)
195 error = driver_create_file(&drv->driver, &driver_attr_new_id);
196 return error;
197}
198
199static void pci_remove_newid_file(struct pci_driver *drv)
200{
201 driver_remove_file(&drv->driver, &driver_attr_new_id);
202}
203 194
204static int 195 if (drv->probe != NULL) {
205pci_create_removeid_file(struct pci_driver *drv) 196 error = driver_create_file(&drv->driver, &driver_attr_new_id);
206{ 197 if (error == 0) {
207 int error = 0; 198 error = driver_create_file(&drv->driver,
208 if (drv->probe != NULL) 199 &driver_attr_remove_id);
209 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 }
210 return error; 205 return error;
211} 206}
212 207
213static void pci_remove_removeid_file(struct pci_driver *drv) 208static void pci_remove_newid_files(struct pci_driver *drv)
214{ 209{
215 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);
216} 212}
217#else /* !CONFIG_HOTPLUG */ 213#else /* !CONFIG_HOTPLUG */
218static inline int pci_create_newid_file(struct pci_driver *drv) 214static inline int pci_create_newid_files(struct pci_driver *drv)
219{ 215{
220 return 0; 216 return 0;
221} 217}
222static inline void pci_remove_newid_file(struct pci_driver *drv) {} 218static inline void pci_remove_newid_files(struct pci_driver *drv) {}
223static inline int pci_create_removeid_file(struct pci_driver *drv)
224{
225 return 0;
226}
227static inline void pci_remove_removeid_file(struct pci_driver *drv) {}
228#endif 219#endif
229 220
230/** 221/**
@@ -1136,18 +1127,12 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,
1136 if (error) 1127 if (error)
1137 goto out; 1128 goto out;
1138 1129
1139 error = pci_create_newid_file(drv); 1130 error = pci_create_newid_files(drv);
1140 if (error) 1131 if (error)
1141 goto out_newid; 1132 goto out_newid;
1142
1143 error = pci_create_removeid_file(drv);
1144 if (error)
1145 goto out_removeid;
1146out: 1133out:
1147 return error; 1134 return error;
1148 1135
1149out_removeid:
1150 pci_remove_newid_file(drv);
1151out_newid: 1136out_newid:
1152 driver_unregister(&drv->driver); 1137 driver_unregister(&drv->driver);
1153 goto out; 1138 goto out;
@@ -1166,8 +1151,7 @@ out_newid:
1166void 1151void
1167pci_unregister_driver(struct pci_driver *drv) 1152pci_unregister_driver(struct pci_driver *drv)
1168{ 1153{
1169 pci_remove_removeid_file(drv); 1154 pci_remove_newid_files(drv);
1170 pci_remove_newid_file(drv);
1171 driver_unregister(&drv->driver); 1155 driver_unregister(&drv->driver);
1172 pci_free_dynids(drv); 1156 pci_free_dynids(drv);
1173} 1157}