aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/sys.c')
-rw-r--r--drivers/base/sys.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 0d903909af7e..8980feec5d14 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -54,7 +54,7 @@ sysdev_store(struct kobject *kobj, struct attribute *attr,
54 return -EIO; 54 return -EIO;
55} 55}
56 56
57static struct sysfs_ops sysfs_ops = { 57static const struct sysfs_ops sysfs_ops = {
58 .show = sysdev_show, 58 .show = sysdev_show,
59 .store = sysdev_store, 59 .store = sysdev_store,
60}; 60};
@@ -89,7 +89,7 @@ static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr,
89 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 89 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
90 90
91 if (class_attr->show) 91 if (class_attr->show)
92 return class_attr->show(class, buffer); 92 return class_attr->show(class, class_attr, buffer);
93 return -EIO; 93 return -EIO;
94} 94}
95 95
@@ -100,11 +100,11 @@ static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr,
100 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 100 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr);
101 101
102 if (class_attr->store) 102 if (class_attr->store)
103 return class_attr->store(class, buffer, count); 103 return class_attr->store(class, class_attr, buffer, count);
104 return -EIO; 104 return -EIO;
105} 105}
106 106
107static struct sysfs_ops sysfs_class_ops = { 107static const struct sysfs_ops sysfs_class_ops = {
108 .show = sysdev_class_show, 108 .show = sysdev_class_show,
109 .store = sysdev_class_store, 109 .store = sysdev_class_store,
110}; 110};
@@ -145,13 +145,20 @@ int sysdev_class_register(struct sysdev_class *cls)
145 if (retval) 145 if (retval)
146 return retval; 146 return retval;
147 147
148 return kset_register(&cls->kset); 148 retval = kset_register(&cls->kset);
149 if (!retval && cls->attrs)
150 retval = sysfs_create_files(&cls->kset.kobj,
151 (const struct attribute **)cls->attrs);
152 return retval;
149} 153}
150 154
151void sysdev_class_unregister(struct sysdev_class *cls) 155void sysdev_class_unregister(struct sysdev_class *cls)
152{ 156{
153 pr_debug("Unregistering sysdev class '%s'\n", 157 pr_debug("Unregistering sysdev class '%s'\n",
154 kobject_name(&cls->kset.kobj)); 158 kobject_name(&cls->kset.kobj));
159 if (cls->attrs)
160 sysfs_remove_files(&cls->kset.kobj,
161 (const struct attribute **)cls->attrs);
155 kset_unregister(&cls->kset); 162 kset_unregister(&cls->kset);
156} 163}
157 164