printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / sysfs.h
blobc4e64dc112063f7cb89bf66059d0338716089e87
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * sysfs.h - definitions for the device driver filesystem
5 * Copyright (c) 2001,2002 Patrick Mochel
6 * Copyright (c) 2004 Silicon Graphics, Inc.
7 * Copyright (c) 2007 SUSE Linux Products GmbH
8 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
10 * Please see Documentation/filesystems/sysfs.rst for more information.
13 #ifndef _SYSFS_H_
14 #define _SYSFS_H_
16 #include <linux/kernfs.h>
17 #include <linux/compiler.h>
18 #include <linux/errno.h>
19 #include <linux/list.h>
20 #include <linux/lockdep.h>
21 #include <linux/kobject_ns.h>
22 #include <linux/stat.h>
23 #include <linux/atomic.h>
25 struct kobject;
26 struct module;
27 struct bin_attribute;
28 enum kobj_ns_type;
30 struct attribute {
31 const char *name;
32 umode_t mode;
33 #ifdef CONFIG_DEBUG_LOCK_ALLOC
34 bool ignore_lockdep:1;
35 struct lock_class_key *key;
36 struct lock_class_key skey;
37 #endif
40 /**
41 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
42 * @attr: struct attribute to initialize
44 * Initialize a dynamically allocated struct attribute so we can
45 * make lockdep happy. This is a new requirement for attributes
46 * and initially this is only needed when lockdep is enabled.
47 * Lockdep gives a nice error when your attribute is added to
48 * sysfs if you don't have this.
50 #ifdef CONFIG_DEBUG_LOCK_ALLOC
51 #define sysfs_attr_init(attr) \
52 do { \
53 static struct lock_class_key __key; \
55 (attr)->key = &__key; \
56 } while (0)
57 #else
58 #define sysfs_attr_init(attr) do {} while (0)
59 #endif
61 /**
62 * struct attribute_group - data structure used to declare an attribute group.
63 * @name: Optional: Attribute group name
64 * If specified, the attribute group will be created in a
65 * new subdirectory with this name. Additionally when a
66 * group is named, @is_visible and @is_bin_visible may
67 * return SYSFS_GROUP_INVISIBLE to control visibility of
68 * the directory itself.
69 * @is_visible: Optional: Function to return permissions associated with an
70 * attribute of the group. Will be called repeatedly for
71 * each non-binary attribute in the group. Only read/write
72 * permissions as well as SYSFS_PREALLOC are accepted. Must
73 * return 0 if an attribute is not visible. The returned
74 * value will replace static permissions defined in struct
75 * attribute. Use SYSFS_GROUP_VISIBLE() when assigning this
76 * callback to specify separate _group_visible() and
77 * _attr_visible() handlers.
78 * @is_bin_visible:
79 * Optional: Function to return permissions associated with a
80 * binary attribute of the group. Will be called repeatedly
81 * for each binary attribute in the group. Only read/write
82 * permissions as well as SYSFS_PREALLOC (and the
83 * visibility flags for named groups) are accepted. Must
84 * return 0 if a binary attribute is not visible. The
85 * returned value will replace static permissions defined
86 * in struct bin_attribute. If @is_visible is not set, Use
87 * SYSFS_GROUP_VISIBLE() when assigning this callback to
88 * specify separate _group_visible() and _attr_visible()
89 * handlers.
90 * @attrs: Pointer to NULL terminated list of attributes.
91 * @bin_attrs: Pointer to NULL terminated list of binary attributes.
92 * Either attrs or bin_attrs or both must be provided.
94 struct attribute_group {
95 const char *name;
96 umode_t (*is_visible)(struct kobject *,
97 struct attribute *, int);
98 umode_t (*is_bin_visible)(struct kobject *,
99 struct bin_attribute *, int);
100 struct attribute **attrs;
101 struct bin_attribute **bin_attrs;
104 #define SYSFS_PREALLOC 010000
105 #define SYSFS_GROUP_INVISIBLE 020000
108 * DEFINE_SYSFS_GROUP_VISIBLE(name):
109 * A helper macro to pair with the assignment of ".is_visible =
110 * SYSFS_GROUP_VISIBLE(name)", that arranges for the directory
111 * associated with a named attribute_group to optionally be hidden.
112 * This allows for static declaration of attribute_groups, and the
113 * simplification of attribute visibility lifetime that implies,
114 * without polluting sysfs with empty attribute directories.
115 * Ex.
117 * static umode_t example_attr_visible(struct kobject *kobj,
118 * struct attribute *attr, int n)
120 * if (example_attr_condition)
121 * return 0;
122 * else if (ro_attr_condition)
123 * return 0444;
124 * return a->mode;
127 * static bool example_group_visible(struct kobject *kobj)
129 * if (example_group_condition)
130 * return false;
131 * return true;
134 * DEFINE_SYSFS_GROUP_VISIBLE(example);
136 * static struct attribute_group example_group = {
137 * .name = "example",
138 * .is_visible = SYSFS_GROUP_VISIBLE(example),
139 * .attrs = &example_attrs,
140 * };
142 * Note that it expects <name>_attr_visible and <name>_group_visible to
143 * be defined. For cases where individual attributes do not need
144 * separate visibility consideration, only entire group visibility at
145 * once, see DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE().
147 #define DEFINE_SYSFS_GROUP_VISIBLE(name) \
148 static inline umode_t sysfs_group_visible_##name( \
149 struct kobject *kobj, struct attribute *attr, int n) \
151 if (n == 0 && !name##_group_visible(kobj)) \
152 return SYSFS_GROUP_INVISIBLE; \
153 return name##_attr_visible(kobj, attr, n); \
157 * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name):
158 * A helper macro to pair with SYSFS_GROUP_VISIBLE() that like
159 * DEFINE_SYSFS_GROUP_VISIBLE() controls group visibility, but does
160 * not require the implementation of a per-attribute visibility
161 * callback.
162 * Ex.
164 * static bool example_group_visible(struct kobject *kobj)
166 * if (example_group_condition)
167 * return false;
168 * return true;
171 * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(example);
173 * static struct attribute_group example_group = {
174 * .name = "example",
175 * .is_visible = SYSFS_GROUP_VISIBLE(example),
176 * .attrs = &example_attrs,
177 * };
179 #define DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name) \
180 static inline umode_t sysfs_group_visible_##name( \
181 struct kobject *kobj, struct attribute *a, int n) \
183 if (n == 0 && !name##_group_visible(kobj)) \
184 return SYSFS_GROUP_INVISIBLE; \
185 return a->mode; \
189 * Same as DEFINE_SYSFS_GROUP_VISIBLE, but for groups with only binary
190 * attributes. If an attribute_group defines both text and binary
191 * attributes, the group visibility is determined by the function
192 * specified to is_visible() not is_bin_visible()
194 #define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \
195 static inline umode_t sysfs_group_visible_##name( \
196 struct kobject *kobj, struct bin_attribute *attr, int n) \
198 if (n == 0 && !name##_group_visible(kobj)) \
199 return SYSFS_GROUP_INVISIBLE; \
200 return name##_attr_visible(kobj, attr, n); \
203 #define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) \
204 static inline umode_t sysfs_group_visible_##name( \
205 struct kobject *kobj, struct bin_attribute *a, int n) \
207 if (n == 0 && !name##_group_visible(kobj)) \
208 return SYSFS_GROUP_INVISIBLE; \
209 return a->mode; \
212 #define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn
215 * Use these macros to make defining attributes easier.
216 * See include/linux/device.h for examples..
219 #define __ATTR(_name, _mode, _show, _store) { \
220 .attr = {.name = __stringify(_name), \
221 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
222 .show = _show, \
223 .store = _store, \
226 #define __ATTR_PREALLOC(_name, _mode, _show, _store) { \
227 .attr = {.name = __stringify(_name), \
228 .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\
229 .show = _show, \
230 .store = _store, \
233 #define __ATTR_RO(_name) { \
234 .attr = { .name = __stringify(_name), .mode = 0444 }, \
235 .show = _name##_show, \
238 #define __ATTR_RO_MODE(_name, _mode) { \
239 .attr = { .name = __stringify(_name), \
240 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
241 .show = _name##_show, \
244 #define __ATTR_RW_MODE(_name, _mode) { \
245 .attr = { .name = __stringify(_name), \
246 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
247 .show = _name##_show, \
248 .store = _name##_store, \
251 #define __ATTR_WO(_name) { \
252 .attr = { .name = __stringify(_name), .mode = 0200 }, \
253 .store = _name##_store, \
256 #define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store)
258 #define __ATTR_NULL { .attr = { .name = NULL } }
260 #ifdef CONFIG_DEBUG_LOCK_ALLOC
261 #define __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) { \
262 .attr = {.name = __stringify(_name), .mode = _mode, \
263 .ignore_lockdep = true }, \
264 .show = _show, \
265 .store = _store, \
267 #else
268 #define __ATTR_IGNORE_LOCKDEP __ATTR
269 #endif
271 #define __ATTRIBUTE_GROUPS(_name) \
272 static const struct attribute_group *_name##_groups[] = { \
273 &_name##_group, \
274 NULL, \
277 #define ATTRIBUTE_GROUPS(_name) \
278 static const struct attribute_group _name##_group = { \
279 .attrs = _name##_attrs, \
280 }; \
281 __ATTRIBUTE_GROUPS(_name)
283 #define BIN_ATTRIBUTE_GROUPS(_name) \
284 static const struct attribute_group _name##_group = { \
285 .bin_attrs = _name##_attrs, \
286 }; \
287 __ATTRIBUTE_GROUPS(_name)
289 struct file;
290 struct vm_area_struct;
291 struct address_space;
293 struct bin_attribute {
294 struct attribute attr;
295 size_t size;
296 void *private;
297 struct address_space *(*f_mapping)(void);
298 ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
299 char *, loff_t, size_t);
300 ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
301 char *, loff_t, size_t);
302 loff_t (*llseek)(struct file *, struct kobject *, struct bin_attribute *,
303 loff_t, int);
304 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
305 struct vm_area_struct *vma);
309 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
310 * @attr: struct bin_attribute to initialize
312 * Initialize a dynamically allocated struct bin_attribute so we
313 * can make lockdep happy. This is a new requirement for
314 * attributes and initially this is only needed when lockdep is
315 * enabled. Lockdep gives a nice error when your attribute is
316 * added to sysfs if you don't have this.
318 #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
320 /* macros to create static binary attributes easier */
321 #define __BIN_ATTR(_name, _mode, _read, _write, _size) { \
322 .attr = { .name = __stringify(_name), .mode = _mode }, \
323 .read = _read, \
324 .write = _write, \
325 .size = _size, \
328 #define __BIN_ATTR_RO(_name, _size) { \
329 .attr = { .name = __stringify(_name), .mode = 0444 }, \
330 .read = _name##_read, \
331 .size = _size, \
334 #define __BIN_ATTR_WO(_name, _size) { \
335 .attr = { .name = __stringify(_name), .mode = 0200 }, \
336 .write = _name##_write, \
337 .size = _size, \
340 #define __BIN_ATTR_RW(_name, _size) \
341 __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size)
343 #define __BIN_ATTR_NULL __ATTR_NULL
345 #define BIN_ATTR(_name, _mode, _read, _write, _size) \
346 struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read, \
347 _write, _size)
349 #define BIN_ATTR_RO(_name, _size) \
350 struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size)
352 #define BIN_ATTR_WO(_name, _size) \
353 struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size)
355 #define BIN_ATTR_RW(_name, _size) \
356 struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
359 #define __BIN_ATTR_ADMIN_RO(_name, _size) { \
360 .attr = { .name = __stringify(_name), .mode = 0400 }, \
361 .read = _name##_read, \
362 .size = _size, \
365 #define __BIN_ATTR_ADMIN_RW(_name, _size) \
366 __BIN_ATTR(_name, 0600, _name##_read, _name##_write, _size)
368 #define BIN_ATTR_ADMIN_RO(_name, _size) \
369 struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RO(_name, _size)
371 #define BIN_ATTR_ADMIN_RW(_name, _size) \
372 struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size)
374 #define __BIN_ATTR_SIMPLE_RO(_name, _mode) { \
375 .attr = { .name = __stringify(_name), .mode = _mode }, \
376 .read = sysfs_bin_attr_simple_read, \
379 #define BIN_ATTR_SIMPLE_RO(_name) \
380 struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0444)
382 #define BIN_ATTR_SIMPLE_ADMIN_RO(_name) \
383 struct bin_attribute bin_attr_##_name = __BIN_ATTR_SIMPLE_RO(_name, 0400)
385 struct sysfs_ops {
386 ssize_t (*show)(struct kobject *, struct attribute *, char *);
387 ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t);
390 #ifdef CONFIG_SYSFS
392 int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
393 void sysfs_remove_dir(struct kobject *kobj);
394 int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
395 const void *new_ns);
396 int __must_check sysfs_move_dir_ns(struct kobject *kobj,
397 struct kobject *new_parent_kobj,
398 const void *new_ns);
399 int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
400 const char *name);
401 void sysfs_remove_mount_point(struct kobject *parent_kobj,
402 const char *name);
404 int __must_check sysfs_create_file_ns(struct kobject *kobj,
405 const struct attribute *attr,
406 const void *ns);
407 int __must_check sysfs_create_files(struct kobject *kobj,
408 const struct attribute * const *attr);
409 int __must_check sysfs_chmod_file(struct kobject *kobj,
410 const struct attribute *attr, umode_t mode);
411 struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
412 const struct attribute *attr);
413 void sysfs_unbreak_active_protection(struct kernfs_node *kn);
414 void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
415 const void *ns);
416 bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
417 void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
419 int __must_check sysfs_create_bin_file(struct kobject *kobj,
420 const struct bin_attribute *attr);
421 void sysfs_remove_bin_file(struct kobject *kobj,
422 const struct bin_attribute *attr);
424 int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
425 const char *name);
426 int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
427 struct kobject *target,
428 const char *name);
429 void sysfs_remove_link(struct kobject *kobj, const char *name);
431 int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
432 const char *old_name, const char *new_name,
433 const void *new_ns);
435 void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
436 const char *name);
438 int __must_check sysfs_create_group(struct kobject *kobj,
439 const struct attribute_group *grp);
440 int __must_check sysfs_create_groups(struct kobject *kobj,
441 const struct attribute_group **groups);
442 int __must_check sysfs_update_groups(struct kobject *kobj,
443 const struct attribute_group **groups);
444 int sysfs_update_group(struct kobject *kobj,
445 const struct attribute_group *grp);
446 void sysfs_remove_group(struct kobject *kobj,
447 const struct attribute_group *grp);
448 void sysfs_remove_groups(struct kobject *kobj,
449 const struct attribute_group **groups);
450 int sysfs_add_file_to_group(struct kobject *kobj,
451 const struct attribute *attr, const char *group);
452 void sysfs_remove_file_from_group(struct kobject *kobj,
453 const struct attribute *attr, const char *group);
454 int sysfs_merge_group(struct kobject *kobj,
455 const struct attribute_group *grp);
456 void sysfs_unmerge_group(struct kobject *kobj,
457 const struct attribute_group *grp);
458 int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
459 struct kobject *target, const char *link_name);
460 void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
461 const char *link_name);
462 int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
463 struct kobject *target_kobj,
464 const char *target_name,
465 const char *symlink_name);
467 void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
469 int __must_check sysfs_init(void);
471 static inline void sysfs_enable_ns(struct kernfs_node *kn)
473 return kernfs_enable_ns(kn);
476 int sysfs_file_change_owner(struct kobject *kobj, const char *name, kuid_t kuid,
477 kgid_t kgid);
478 int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid);
479 int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ,
480 const char *name, kuid_t kuid, kgid_t kgid);
481 int sysfs_groups_change_owner(struct kobject *kobj,
482 const struct attribute_group **groups,
483 kuid_t kuid, kgid_t kgid);
484 int sysfs_group_change_owner(struct kobject *kobj,
485 const struct attribute_group *groups, kuid_t kuid,
486 kgid_t kgid);
487 __printf(2, 3)
488 int sysfs_emit(char *buf, const char *fmt, ...);
489 __printf(3, 4)
490 int sysfs_emit_at(char *buf, int at, const char *fmt, ...);
492 ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj,
493 struct bin_attribute *attr, char *buf,
494 loff_t off, size_t count);
496 #else /* CONFIG_SYSFS */
498 static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
500 return 0;
503 static inline void sysfs_remove_dir(struct kobject *kobj)
507 static inline int sysfs_rename_dir_ns(struct kobject *kobj,
508 const char *new_name, const void *new_ns)
510 return 0;
513 static inline int sysfs_move_dir_ns(struct kobject *kobj,
514 struct kobject *new_parent_kobj,
515 const void *new_ns)
517 return 0;
520 static inline int sysfs_create_mount_point(struct kobject *parent_kobj,
521 const char *name)
523 return 0;
526 static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
527 const char *name)
531 static inline int sysfs_create_file_ns(struct kobject *kobj,
532 const struct attribute *attr,
533 const void *ns)
535 return 0;
538 static inline int sysfs_create_files(struct kobject *kobj,
539 const struct attribute * const *attr)
541 return 0;
544 static inline int sysfs_chmod_file(struct kobject *kobj,
545 const struct attribute *attr, umode_t mode)
547 return 0;
550 static inline struct kernfs_node *
551 sysfs_break_active_protection(struct kobject *kobj,
552 const struct attribute *attr)
554 return NULL;
557 static inline void sysfs_unbreak_active_protection(struct kernfs_node *kn)
561 static inline void sysfs_remove_file_ns(struct kobject *kobj,
562 const struct attribute *attr,
563 const void *ns)
567 static inline bool sysfs_remove_file_self(struct kobject *kobj,
568 const struct attribute *attr)
570 return false;
573 static inline void sysfs_remove_files(struct kobject *kobj,
574 const struct attribute * const *attr)
578 static inline int sysfs_create_bin_file(struct kobject *kobj,
579 const struct bin_attribute *attr)
581 return 0;
584 static inline void sysfs_remove_bin_file(struct kobject *kobj,
585 const struct bin_attribute *attr)
589 static inline int sysfs_create_link(struct kobject *kobj,
590 struct kobject *target, const char *name)
592 return 0;
595 static inline int sysfs_create_link_nowarn(struct kobject *kobj,
596 struct kobject *target,
597 const char *name)
599 return 0;
602 static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
606 static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
607 const char *old_name,
608 const char *new_name, const void *ns)
610 return 0;
613 static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
614 const char *name)
618 static inline int sysfs_create_group(struct kobject *kobj,
619 const struct attribute_group *grp)
621 return 0;
624 static inline int sysfs_create_groups(struct kobject *kobj,
625 const struct attribute_group **groups)
627 return 0;
630 static inline int sysfs_update_groups(struct kobject *kobj,
631 const struct attribute_group **groups)
633 return 0;
636 static inline int sysfs_update_group(struct kobject *kobj,
637 const struct attribute_group *grp)
639 return 0;
642 static inline void sysfs_remove_group(struct kobject *kobj,
643 const struct attribute_group *grp)
647 static inline void sysfs_remove_groups(struct kobject *kobj,
648 const struct attribute_group **groups)
652 static inline int sysfs_add_file_to_group(struct kobject *kobj,
653 const struct attribute *attr, const char *group)
655 return 0;
658 static inline void sysfs_remove_file_from_group(struct kobject *kobj,
659 const struct attribute *attr, const char *group)
663 static inline int sysfs_merge_group(struct kobject *kobj,
664 const struct attribute_group *grp)
666 return 0;
669 static inline void sysfs_unmerge_group(struct kobject *kobj,
670 const struct attribute_group *grp)
674 static inline int sysfs_add_link_to_group(struct kobject *kobj,
675 const char *group_name, struct kobject *target,
676 const char *link_name)
678 return 0;
681 static inline void sysfs_remove_link_from_group(struct kobject *kobj,
682 const char *group_name, const char *link_name)
686 static inline int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
687 struct kobject *target_kobj,
688 const char *target_name,
689 const char *symlink_name)
691 return 0;
694 static inline void sysfs_notify(struct kobject *kobj, const char *dir,
695 const char *attr)
699 static inline int __must_check sysfs_init(void)
701 return 0;
704 static inline void sysfs_enable_ns(struct kernfs_node *kn)
708 static inline int sysfs_file_change_owner(struct kobject *kobj,
709 const char *name, kuid_t kuid,
710 kgid_t kgid)
712 return 0;
715 static inline int sysfs_link_change_owner(struct kobject *kobj,
716 struct kobject *targ,
717 const char *name, kuid_t kuid,
718 kgid_t kgid)
720 return 0;
723 static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid)
725 return 0;
728 static inline int sysfs_groups_change_owner(struct kobject *kobj,
729 const struct attribute_group **groups,
730 kuid_t kuid, kgid_t kgid)
732 return 0;
735 static inline int sysfs_group_change_owner(struct kobject *kobj,
736 const struct attribute_group *groups,
737 kuid_t kuid, kgid_t kgid)
739 return 0;
742 __printf(2, 3)
743 static inline int sysfs_emit(char *buf, const char *fmt, ...)
745 return 0;
748 __printf(3, 4)
749 static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
751 return 0;
754 static inline ssize_t sysfs_bin_attr_simple_read(struct file *file,
755 struct kobject *kobj,
756 struct bin_attribute *attr,
757 char *buf, loff_t off,
758 size_t count)
760 return 0;
762 #endif /* CONFIG_SYSFS */
764 static inline int __must_check sysfs_create_file(struct kobject *kobj,
765 const struct attribute *attr)
767 return sysfs_create_file_ns(kobj, attr, NULL);
770 static inline void sysfs_remove_file(struct kobject *kobj,
771 const struct attribute *attr)
773 sysfs_remove_file_ns(kobj, attr, NULL);
776 static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
777 const char *old_name, const char *new_name)
779 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
782 static inline void sysfs_notify_dirent(struct kernfs_node *kn)
784 kernfs_notify(kn);
787 static inline struct kernfs_node *sysfs_get_dirent(struct kernfs_node *parent,
788 const char *name)
790 return kernfs_find_and_get(parent, name);
793 static inline struct kernfs_node *sysfs_get(struct kernfs_node *kn)
795 kernfs_get(kn);
796 return kn;
799 static inline void sysfs_put(struct kernfs_node *kn)
801 kernfs_put(kn);
804 #endif /* _SYSFS_H_ */