Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.git] / drivers / base / attribute_container.c
index 1ec0654..3b43e8a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 
 #include "base.h"
 
@@ -60,7 +61,7 @@ attribute_container_classdev_to_container(struct class_device *classdev)
 }
 EXPORT_SYMBOL_GPL(attribute_container_classdev_to_container);
 
-static struct list_head attribute_container_list;
+static LIST_HEAD(attribute_container_list);
 
 static DEFINE_MUTEX(attribute_container_mutex);
 
@@ -319,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)
@@ -377,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]);
 }
@@ -428,10 +439,3 @@ attribute_container_find_class_device(struct attribute_container *cont,
        return cdev;
 }
 EXPORT_SYMBOL_GPL(attribute_container_find_class_device);
-
-int __init
-attribute_container_init(void)
-{
-       INIT_LIST_HEAD(&attribute_container_list);
-       return 0;
-}