Lines Matching refs:cls

88 int class_create_file_ns(struct class *cls, const struct class_attribute *attr,
93 if (cls)
94 error = sysfs_create_file_ns(&cls->p->subsys.kobj,
101 void class_remove_file_ns(struct class *cls, const struct class_attribute *attr,
104 if (cls)
105 sysfs_remove_file_ns(&cls->p->subsys.kobj, &attr->attr, ns);
108 static struct class *class_get(struct class *cls)
110 if (cls)
111 kset_get(&cls->p->subsys);
112 return cls;
115 static void class_put(struct class *cls)
117 if (cls)
118 kset_put(&cls->p->subsys);
141 static int class_add_groups(struct class *cls,
144 return sysfs_create_groups(&cls->p->subsys.kobj, groups);
147 static void class_remove_groups(struct class *cls,
150 return sysfs_remove_groups(&cls->p->subsys.kobj, groups);
153 int __class_register(struct class *cls, struct lock_class_key *key)
158 pr_debug("device class '%s': registering\n", cls->name);
167 error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
174 if (!cls->dev_kobj)
175 cls->dev_kobj = sysfs_dev_char_kobj;
179 if (!sysfs_deprecated || cls != &block_class)
185 cp->class = cls;
186 cls->p = cp;
193 error = class_add_groups(class_get(cls), cls->class_groups);
194 class_put(cls);
204 void class_unregister(struct class *cls)
206 pr_debug("device class '%s': unregistering\n", cls->name);
207 class_remove_groups(cls, cls->class_groups);
208 kset_unregister(&cls->p->subsys);
211 static void class_create_release(struct class *cls)
213 pr_debug("%s called for %s\n", __func__, cls->name);
214 kfree(cls);
234 struct class *cls;
237 cls = kzalloc(sizeof(*cls), GFP_KERNEL);
238 if (!cls) {
243 cls->name = name;
244 cls->owner = owner;
245 cls->class_release = class_create_release;
247 retval = __class_register(cls, key);
251 return cls;
254 kfree(cls);
261 * @cls: pointer to the struct class that is to be destroyed
266 void class_destroy(struct class *cls)
268 if ((cls == NULL) || (IS_ERR(cls)))
271 class_unregister(cls);
504 struct class_compat *cls;
506 cls = kmalloc(sizeof(struct class_compat), GFP_KERNEL);
507 if (!cls)
509 cls->kobj = kobject_create_and_add(name, &class_kset->kobj);
510 if (!cls->kobj) {
511 kfree(cls);
514 return cls;
520 * @cls: the class to unregister
522 void class_compat_unregister(struct class_compat *cls)
524 kobject_put(cls->kobj);
525 kfree(cls);
532 * @cls: the compatibility class
536 int class_compat_create_link(struct class_compat *cls, struct device *dev,
541 error = sysfs_create_link(cls->kobj, &dev->kobj, dev_name(dev));
554 sysfs_remove_link(cls->kobj, dev_name(dev));
564 * @cls: the compatibility class
569 void class_compat_remove_link(struct class_compat *cls, struct device *dev,
574 sysfs_remove_link(cls->kobj, dev_name(dev));