include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / base / sys.c
index a38445c..9354dc1 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/pm.h>
 #include <linux/device.h>
@@ -54,7 +53,7 @@ sysdev_store(struct kobject *kobj, struct attribute *attr,
        return -EIO;
 }
 
-static struct sysfs_ops sysfs_ops = {
+static const struct sysfs_ops sysfs_ops = {
        .show   = sysdev_show,
        .store  = sysdev_store,
 };
@@ -104,7 +103,7 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
        return -EIO;
 }
 
-static struct sysfs_ops sysfs_class_ops = {
+static const struct sysfs_ops sysfs_class_ops = {
        .show   = sysdev_class_show,
        .store  = sysdev_class_store,
 };
@@ -145,13 +144,20 @@ int sysdev_class_register(struct sysdev_class *cls)
        if (retval)
                return retval;
 
-       return kset_register(&cls->kset);
+       retval = kset_register(&cls->kset);
+       if (!retval && cls->attrs)
+               retval = sysfs_create_files(&cls->kset.kobj,
+                                           (const struct attribute **)cls->attrs);
+       return retval;
 }
 
 void sysdev_class_unregister(struct sysdev_class *cls)
 {
        pr_debug("Unregistering sysdev class '%s'\n",
                 kobject_name(&cls->kset.kobj));
+       if (cls->attrs)
+               sysfs_remove_files(&cls->kset.kobj,
+                                  (const struct attribute **)cls->attrs);
        kset_unregister(&cls->kset);
 }