aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c22
-rw-r--r--drivers/base/class.c3
2 files changed, 11 insertions, 14 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 472810f8e6e7..253868e03c70 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -324,27 +324,25 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
324 return error; 324 return error;
325} 325}
326 326
327static int device_add_attrs(struct bus_type * bus, struct device * dev) 327static int device_add_attrs(struct bus_type *bus, struct device *dev)
328{ 328{
329 int error = 0; 329 int error = 0;
330 int i; 330 int i;
331 331
332 if (bus->dev_attrs) { 332 if (!bus->dev_attrs)
333 for (i = 0; attr_name(bus->dev_attrs[i]); i++) { 333 return 0;
334 error = device_create_file(dev,&bus->dev_attrs[i]); 334
335 if (error) 335 for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
336 goto Err; 336 error = device_create_file(dev,&bus->dev_attrs[i]);
337 if (error) {
338 while (--i >= 0)
339 device_remove_file(dev, &bus->dev_attrs[i]);
340 break;
337 } 341 }
338 } 342 }
339 Done:
340 return error; 343 return error;
341 Err:
342 while (--i >= 0)
343 device_remove_file(dev,&bus->dev_attrs[i]);
344 goto Done;
345} 344}
346 345
347
348static void device_remove_attrs(struct bus_type * bus, struct device * dev) 346static void device_remove_attrs(struct bus_type * bus, struct device * dev)
349{ 347{
350 int i; 348 int i;
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 96def1ddba19..1417e5cd4c6f 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -163,8 +163,7 @@ int class_register(struct class * cls)
163void class_unregister(struct class * cls) 163void class_unregister(struct class * cls)
164{ 164{
165 pr_debug("device class '%s': unregistering\n", cls->name); 165 pr_debug("device class '%s': unregistering\n", cls->name);
166 if (cls->virtual_dir) 166 kobject_unregister(cls->virtual_dir);
167 kobject_unregister(cls->virtual_dir);
168 remove_class_attrs(cls); 167 remove_class_attrs(cls);
169 subsystem_unregister(&cls->subsys); 168 subsystem_unregister(&cls->subsys);
170} 169}