Lines Matching refs:cls
88 int class_create_file_ns(struct class *cls, const struct class_attribute *attr, in class_create_file_ns() argument
93 if (cls) in class_create_file_ns()
94 error = sysfs_create_file_ns(&cls->p->subsys.kobj, in class_create_file_ns()
101 void class_remove_file_ns(struct class *cls, const struct class_attribute *attr, in class_remove_file_ns() argument
104 if (cls) in class_remove_file_ns()
105 sysfs_remove_file_ns(&cls->p->subsys.kobj, &attr->attr, ns); in class_remove_file_ns()
108 static struct class *class_get(struct class *cls) in class_get() argument
110 if (cls) in class_get()
111 kset_get(&cls->p->subsys); in class_get()
112 return cls; in class_get()
115 static void class_put(struct class *cls) in class_put() argument
117 if (cls) in class_put()
118 kset_put(&cls->p->subsys); in class_put()
141 static int class_add_groups(struct class *cls, in class_add_groups() argument
144 return sysfs_create_groups(&cls->p->subsys.kobj, groups); in class_add_groups()
147 static void class_remove_groups(struct class *cls, in class_remove_groups() argument
150 return sysfs_remove_groups(&cls->p->subsys.kobj, groups); in class_remove_groups()
153 int __class_register(struct class *cls, struct lock_class_key *key) in __class_register() argument
158 pr_debug("device class '%s': registering\n", cls->name); in __class_register()
167 error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name); in __class_register()
174 if (!cls->dev_kobj) in __class_register()
175 cls->dev_kobj = sysfs_dev_char_kobj; in __class_register()
179 if (!sysfs_deprecated || cls != &block_class) in __class_register()
185 cp->class = cls; in __class_register()
186 cls->p = cp; in __class_register()
193 error = class_add_groups(class_get(cls), cls->class_groups); in __class_register()
194 class_put(cls); in __class_register()
199 void class_unregister(struct class *cls) in class_unregister() argument
201 pr_debug("device class '%s': unregistering\n", cls->name); in class_unregister()
202 class_remove_groups(cls, cls->class_groups); in class_unregister()
203 kset_unregister(&cls->p->subsys); in class_unregister()
206 static void class_create_release(struct class *cls) in class_create_release() argument
208 pr_debug("%s called for %s\n", __func__, cls->name); in class_create_release()
209 kfree(cls); in class_create_release()
229 struct class *cls; in __class_create() local
232 cls = kzalloc(sizeof(*cls), GFP_KERNEL); in __class_create()
233 if (!cls) { in __class_create()
238 cls->name = name; in __class_create()
239 cls->owner = owner; in __class_create()
240 cls->class_release = class_create_release; in __class_create()
242 retval = __class_register(cls, key); in __class_create()
246 return cls; in __class_create()
249 kfree(cls); in __class_create()
261 void class_destroy(struct class *cls) in class_destroy() argument
263 if ((cls == NULL) || (IS_ERR(cls))) in class_destroy()
266 class_unregister(cls); in class_destroy()
499 struct class_compat *cls; in class_compat_register() local
501 cls = kmalloc(sizeof(struct class_compat), GFP_KERNEL); in class_compat_register()
502 if (!cls) in class_compat_register()
504 cls->kobj = kobject_create_and_add(name, &class_kset->kobj); in class_compat_register()
505 if (!cls->kobj) { in class_compat_register()
506 kfree(cls); in class_compat_register()
509 return cls; in class_compat_register()
517 void class_compat_unregister(struct class_compat *cls) in class_compat_unregister() argument
519 kobject_put(cls->kobj); in class_compat_unregister()
520 kfree(cls); in class_compat_unregister()
531 int class_compat_create_link(struct class_compat *cls, struct device *dev, in class_compat_create_link() argument
536 error = sysfs_create_link(cls->kobj, &dev->kobj, dev_name(dev)); in class_compat_create_link()
549 sysfs_remove_link(cls->kobj, dev_name(dev)); in class_compat_create_link()
564 void class_compat_remove_link(struct class_compat *cls, struct device *dev, in class_compat_remove_link() argument
569 sysfs_remove_link(cls->kobj, dev_name(dev)); in class_compat_remove_link()