Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4aca67e5f54bf6ee439b5bdbc77007a547ad5b43
Commit:     4aca67e5f54bf6ee439b5bdbc77007a547ad5b43
Parent:     873760fbf4d1c8c477a50386438303b6b89b6566
Author:     Andrew Morton <[EMAIL PROTECTED]>
AuthorDate: Tue Feb 13 22:39:26 2007 -0800
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Feb 16 15:19:18 2007 -0800

    Driver core: device_add_attrs() cleanup
    
    Clean up the coding in device_add_attrs() a bit.
    
    Cc: Jean Delvare <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 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 472810f..253868e 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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to