]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCSI] attribute_container: update to use the group interface
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Thu, 3 Jan 2008 00:48:47 +0000 (18:48 -0600)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 23 Jan 2008 17:29:17 +0000 (11:29 -0600)
This patch is the beginning of moving the attribute_containers to use
attribute groups exclusively.  The attr element is now deprecated and
will eventually be removed (along with all the hand rolled code for
doing exactly what attribute groups do) when all the consumers are
converted to attribute groups.

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/base/attribute_container.c
include/linux/attribute_container.h

index 7370d7cf59888050d374d7a48a03185a06f0df7c..5bf25c6f966cd920753eff462507c1a773d448e9 100644 (file)
@@ -320,9 +320,14 @@ attribute_container_add_attrs(struct class_device *classdev)
        struct class_device_attribute **attrs = cont->attrs;
        int i, error;
 
-       if (!attrs)
+       BUG_ON(attrs && cont->grp);
+
+       if (!attrs && !cont->grp)
                return 0;
 
+       if (cont->grp)
+               return sysfs_create_group(&classdev->kobj, cont->grp);
+
        for (i = 0; attrs[i]; i++) {
                error = class_device_create_file(classdev, attrs[i]);
                if (error)
@@ -378,9 +383,14 @@ attribute_container_remove_attrs(struct class_device *classdev)
        struct class_device_attribute **attrs = cont->attrs;
        int i;
 
-       if (!attrs)
+       if (!attrs && !cont->grp)
                return;
 
+       if (cont->grp) {
+               sysfs_remove_group(&classdev->kobj, cont->grp);
+               return ;
+       }
+
        for (i = 0; attrs[i]; i++)
                class_device_remove_file(classdev, attrs[i]);
 }
index 8ff2749339484fdddd066bab4ab971916a510b93..f5582332af046d4cb00ea31b3beeebccd7da2384 100644 (file)
@@ -17,6 +17,7 @@ struct attribute_container {
        struct list_head        node;
        struct klist            containers;
        struct class            *class;
+       struct attribute_group  *grp;
        struct class_device_attribute **attrs;
        int (*match)(struct attribute_container *, struct device *);
 #define        ATTRIBUTE_CONTAINER_NO_CLASSDEVS        0x01