diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2007-02-14 07:39:26 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-17 00:19:18 +0100 |
commit | 4aca67e5f54bf6ee439b5bdbc77007a547ad5b43 (patch) | |
tree | 06b6c0ba74397f4064383644b3fe6fb7d65ec364 /drivers/base/bus.c | |
parent | debugfs: Remove misleading comments. (diff) | |
download | linux-4aca67e5f54bf6ee439b5bdbc77007a547ad5b43.tar.xz linux-4aca67e5f54bf6ee439b5bdbc77007a547ad5b43.zip |
Driver core: device_add_attrs() cleanup
Clean up the coding in device_add_attrs() a bit.
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r-- | drivers/base/bus.c | 22 |
1 files changed, 10 insertions, 12 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, return error; } -static int device_add_attrs(struct bus_type * bus, struct device * dev) +static int device_add_attrs(struct bus_type *bus, struct device *dev) { int error = 0; int i; - if (bus->dev_attrs) { - for (i = 0; attr_name(bus->dev_attrs[i]); i++) { - error = device_create_file(dev,&bus->dev_attrs[i]); - if (error) - goto Err; + if (!bus->dev_attrs) + return 0; + + for (i = 0; attr_name(bus->dev_attrs[i]); i++) { + error = device_create_file(dev,&bus->dev_attrs[i]); + if (error) { + while (--i >= 0) + device_remove_file(dev, &bus->dev_attrs[i]); + break; } } - Done: return error; - Err: - while (--i >= 0) - device_remove_file(dev,&bus->dev_attrs[i]); - goto Done; } - static void device_remove_attrs(struct bus_type * bus, struct device * dev) { int i; |