1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * sysfs.h - definitions for the device driver filesystem 4 * 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 <[email protected]> 9 * 10 * Please see Documentation/filesystems/sysfs.rst for more information. 11 */ 12 13 #ifndef _SYSFS_H_ 14 #define _SYSFS_H_ 15 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> 24 25 struct kobject; 26 struct module; 27 struct bin_attribute; 28 enum kobj_ns_type; 29 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 38 }; 39 40 /** 41 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute 42 * @attr: struct attribute to initialize 43 * 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. 49 */ 50 #ifdef CONFIG_DEBUG_LOCK_ALLOC 51 #define sysfs_attr_init(attr) \ 52 do { \ 53 static struct lock_class_key __key; \ 54 \ 55 (attr)->key = &__key; \ 56 } while (0) 57 #else 58 #define sysfs_attr_init(attr) do {} while (0) 59 #endif 60 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. 93 */ 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; 102 }; 103 104 #define SYSFS_PREALLOC 010000 105 #define SYSFS_GROUP_INVISIBLE 020000 106 107 /* 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. 116 * 117 * static umode_t example_attr_visible(struct kobject *kobj, 118 * struct attribute *attr, int n) 119 * { 120 * if (example_attr_condition) 121 * return 0; 122 * else if (ro_attr_condition) 123 * return 0444; 124 * return a->mode; 125 * } 126 * 127 * static bool example_group_visible(struct kobject *kobj) 128 * { 129 * if (example_group_condition) 130 * return false; 131 * return true; 132 * } 133 * 134 * DEFINE_SYSFS_GROUP_VISIBLE(example); 135 * 136 * static struct attribute_group example_group = { 137 * .name = "example", 138 * .is_visible = SYSFS_GROUP_VISIBLE(example), 139 * .attrs = &example_attrs, 140 * }; 141 * 142 * Note that it expects <name>_attr_visible and <name>_group_visible to 143 * be defined. 144 */ 145 #define DEFINE_SYSFS_GROUP_VISIBLE(name) \ 146 static inline umode_t sysfs_group_visible_##name( \ 147 struct kobject *kobj, struct attribute *attr, int n) \ 148 { \ 149 if (n == 0 && !name##_group_visible(kobj)) \ 150 return SYSFS_GROUP_INVISIBLE; \ 151 return name##_attr_visible(kobj, attr, n); \ 152 } 153 154 /* 155 * Same as DEFINE_SYSFS_GROUP_VISIBLE, but for groups with only binary 156 * attributes. If an attribute_group defines both text and binary 157 * attributes, the group visibility is determined by the function 158 * specified to is_visible() not is_bin_visible() 159 */ 160 #define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \ 161 static inline umode_t sysfs_group_visible_##name( \ 162 struct kobject *kobj, struct bin_attribute *attr, int n) \ 163 { \ 164 if (n == 0 && !name##_group_visible(kobj)) \ 165 return SYSFS_GROUP_INVISIBLE; \ 166 return name##_attr_visible(kobj, attr, n); \ 167 } 168 169 #define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn 170 171 /* 172 * Use these macros to make defining attributes easier. 173 * See include/linux/device.h for examples.. 174 */ 175 176 #define __ATTR(_name, _mode, _show, _store) { \ 177 .attr = {.name = __stringify(_name), \ 178 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ 179 .show = _show, \ 180 .store = _store, \ 181 } 182 183 #define __ATTR_PREALLOC(_name, _mode, _show, _store) { \ 184 .attr = {.name = __stringify(_name), \ 185 .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\ 186 .show = _show, \ 187 .store = _store, \ 188 } 189 190 #define __ATTR_RO(_name) { \ 191 .attr = { .name = __stringify(_name), .mode = 0444 }, \ 192 .show = _name##_show, \ 193 } 194 195 #define __ATTR_RO_MODE(_name, _mode) { \ 196 .attr = { .name = __stringify(_name), \ 197 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ 198 .show = _name##_show, \ 199 } 200 201 #define __ATTR_RW_MODE(_name, _mode) { \ 202 .attr = { .name = __stringify(_name), \ 203 .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ 204 .show = _name##_show, \ 205 .store = _name##_store, \ 206 } 207 208 #define __ATTR_WO(_name) { \ 209 .attr = { .name = __stringify(_name), .mode = 0200 }, \ 210 .store = _name##_store, \ 211 } 212 213 #define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store) 214 215 #define __ATTR_NULL { .attr = { .name = NULL } } 216 217 #ifdef CONFIG_DEBUG_LOCK_ALLOC 218 #define __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) { \ 219 .attr = {.name = __stringify(_name), .mode = _mode, \ 220 .ignore_lockdep = true }, \ 221 .show = _show, \ 222 .store = _store, \ 223 } 224 #else 225 #define __ATTR_IGNORE_LOCKDEP __ATTR 226 #endif 227 228 #define __ATTRIBUTE_GROUPS(_name) \ 229 static const struct attribute_group *_name##_groups[] = { \ 230 &_name##_group, \ 231 NULL, \ 232 } 233 234 #define ATTRIBUTE_GROUPS(_name) \ 235 static const struct attribute_group _name##_group = { \ 236 .attrs = _name##_attrs, \ 237 }; \ 238 __ATTRIBUTE_GROUPS(_name) 239 240 #define BIN_ATTRIBUTE_GROUPS(_name) \ 241 static const struct attribute_group _name##_group = { \ 242 .bin_attrs = _name##_attrs, \ 243 }; \ 244 __ATTRIBUTE_GROUPS(_name) 245 246 struct file; 247 struct vm_area_struct; 248 struct address_space; 249 250 struct bin_attribute { 251 struct attribute attr; 252 size_t size; 253 void *private; 254 struct address_space *(*f_mapping)(void); 255 ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, 256 char *, loff_t, size_t); 257 ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *, 258 char *, loff_t, size_t); 259 loff_t (*llseek)(struct file *, struct kobject *, struct bin_attribute *, 260 loff_t, int); 261 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr, 262 struct vm_area_struct *vma); 263 }; 264 265 /** 266 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute 267 * @attr: struct bin_attribute to initialize 268 * 269 * Initialize a dynamically allocated struct bin_attribute so we 270 * can make lockdep happy. This is a new requirement for 271 * attributes and initially this is only needed when lockdep is 272 * enabled. Lockdep gives a nice error when your attribute is 273 * added to sysfs if you don't have this. 274 */ 275 #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) 276 277 /* macros to create static binary attributes easier */ 278 #define __BIN_ATTR(_name, _mode, _read, _write, _size) { \ 279 .attr = { .name = __stringify(_name), .mode = _mode }, \ 280 .read = _read, \ 281 .write = _write, \ 282 .size = _size, \ 283 } 284 285 #define __BIN_ATTR_RO(_name, _size) { \ 286 .attr = { .name = __stringify(_name), .mode = 0444 }, \ 287 .read = _name##_read, \ 288 .size = _size, \ 289 } 290 291 #define __BIN_ATTR_WO(_name, _size) { \ 292 .attr = { .name = __stringify(_name), .mode = 0200 }, \ 293 .write = _name##_write, \ 294 .size = _size, \ 295 } 296 297 #define __BIN_ATTR_RW(_name, _size) \ 298 __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size) 299 300 #define __BIN_ATTR_NULL __ATTR_NULL 301 302 #define BIN_ATTR(_name, _mode, _read, _write, _size) \ 303 struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read, \ 304 _write, _size) 305 306 #define BIN_ATTR_RO(_name, _size) \ 307 struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size) 308 309 #define BIN_ATTR_WO(_name, _size) \ 310 struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size) 311 312 #define BIN_ATTR_RW(_name, _size) \ 313 struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size) 314 315 316 #define __BIN_ATTR_ADMIN_RO(_name, _size) { \ 317 .attr = { .name = __stringify(_name), .mode = 0400 }, \ 318 .read = _name##_read, \ 319 .size = _size, \ 320 } 321 322 #define __BIN_ATTR_ADMIN_RW(_name, _size) \ 323 __BIN_ATTR(_name, 0600, _name##_read, _name##_write, _size) 324 325 #define BIN_ATTR_ADMIN_RO(_name, _size) \ 326 struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RO(_name, _size) 327 328 #define BIN_ATTR_ADMIN_RW(_name, _size) \ 329 struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size) 330 331 struct sysfs_ops { 332 ssize_t (*show)(struct kobject *, struct attribute *, char *); 333 ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); 334 }; 335 336 #ifdef CONFIG_SYSFS 337 338 int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns); 339 void sysfs_remove_dir(struct kobject *kobj); 340 int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, 341 const void *new_ns); 342 int __must_check sysfs_move_dir_ns(struct kobject *kobj, 343 struct kobject *new_parent_kobj, 344 const void *new_ns); 345 int __must_check sysfs_create_mount_point(struct kobject *parent_kobj, 346 const char *name); 347 void sysfs_remove_mount_point(struct kobject *parent_kobj, 348 const char *name); 349 350 int __must_check sysfs_create_file_ns(struct kobject *kobj, 351 const struct attribute *attr, 352 const void *ns); 353 int __must_check sysfs_create_files(struct kobject *kobj, 354 const struct attribute * const *attr); 355 int __must_check sysfs_chmod_file(struct kobject *kobj, 356 const struct attribute *attr, umode_t mode); 357 struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj, 358 const struct attribute *attr); 359 void sysfs_unbreak_active_protection(struct kernfs_node *kn); 360 void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, 361 const void *ns); 362 bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr); 363 void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr); 364 365 int __must_check sysfs_create_bin_file(struct kobject *kobj, 366 const struct bin_attribute *attr); 367 void sysfs_remove_bin_file(struct kobject *kobj, 368 const struct bin_attribute *attr); 369 370 int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target, 371 const char *name); 372 int __must_check sysfs_create_link_nowarn(struct kobject *kobj, 373 struct kobject *target, 374 const char *name); 375 void sysfs_remove_link(struct kobject *kobj, const char *name); 376 377 int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target, 378 const char *old_name, const char *new_name, 379 const void *new_ns); 380 381 void sysfs_delete_link(struct kobject *dir, struct kobject *targ, 382 const char *name); 383 384 int __must_check sysfs_create_group(struct kobject *kobj, 385 const struct attribute_group *grp); 386 int __must_check sysfs_create_groups(struct kobject *kobj, 387 const struct attribute_group **groups); 388 int __must_check sysfs_update_groups(struct kobject *kobj, 389 const struct attribute_group **groups); 390 int sysfs_update_group(struct kobject *kobj, 391 const struct attribute_group *grp); 392 void sysfs_remove_group(struct kobject *kobj, 393 const struct attribute_group *grp); 394 void sysfs_remove_groups(struct kobject *kobj, 395 const struct attribute_group **groups); 396 int sysfs_add_file_to_group(struct kobject *kobj, 397 const struct attribute *attr, const char *group); 398 void sysfs_remove_file_from_group(struct kobject *kobj, 399 const struct attribute *attr, const char *group); 400 int sysfs_merge_group(struct kobject *kobj, 401 const struct attribute_group *grp); 402 void sysfs_unmerge_group(struct kobject *kobj, 403 const struct attribute_group *grp); 404 int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name, 405 struct kobject *target, const char *link_name); 406 void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name, 407 const char *link_name); 408 int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, 409 struct kobject *target_kobj, 410 const char *target_name, 411 const char *symlink_name); 412 413 void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); 414 415 int __must_check sysfs_init(void); 416 417 static inline void sysfs_enable_ns(struct kernfs_node *kn) 418 { 419 return kernfs_enable_ns(kn); 420 } 421 422 int sysfs_file_change_owner(struct kobject *kobj, const char *name, kuid_t kuid, 423 kgid_t kgid); 424 int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid); 425 int sysfs_link_change_owner(struct kobject *kobj, struct kobject *targ, 426 const char *name, kuid_t kuid, kgid_t kgid); 427 int sysfs_groups_change_owner(struct kobject *kobj, 428 const struct attribute_group **groups, 429 kuid_t kuid, kgid_t kgid); 430 int sysfs_group_change_owner(struct kobject *kobj, 431 const struct attribute_group *groups, kuid_t kuid, 432 kgid_t kgid); 433 __printf(2, 3) 434 int sysfs_emit(char *buf, const char *fmt, ...); 435 __printf(3, 4) 436 int sysfs_emit_at(char *buf, int at, const char *fmt, ...); 437 438 #else /* CONFIG_SYSFS */ 439 440 static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) 441 { 442 return 0; 443 } 444 445 static inline void sysfs_remove_dir(struct kobject *kobj) 446 { 447 } 448 449 static inline int sysfs_rename_dir_ns(struct kobject *kobj, 450 const char *new_name, const void *new_ns) 451 { 452 return 0; 453 } 454 455 static inline int sysfs_move_dir_ns(struct kobject *kobj, 456 struct kobject *new_parent_kobj, 457 const void *new_ns) 458 { 459 return 0; 460 } 461 462 static inline int sysfs_create_mount_point(struct kobject *parent_kobj, 463 const char *name) 464 { 465 return 0; 466 } 467 468 static inline void sysfs_remove_mount_point(struct kobject *parent_kobj, 469 const char *name) 470 { 471 } 472 473 static inline int sysfs_create_file_ns(struct kobject *kobj, 474 const struct attribute *attr, 475 const void *ns) 476 { 477 return 0; 478 } 479 480 static inline int sysfs_create_files(struct kobject *kobj, 481 const struct attribute * const *attr) 482 { 483 return 0; 484 } 485 486 static inline int sysfs_chmod_file(struct kobject *kobj, 487 const struct attribute *attr, umode_t mode) 488 { 489 return 0; 490 } 491 492 static inline struct kernfs_node * 493 sysfs_break_active_protection(struct kobject *kobj, 494 const struct attribute *attr) 495 { 496 return NULL; 497 } 498 499 static inline void sysfs_unbreak_active_protection(struct kernfs_node *kn) 500 { 501 } 502 503 static inline void sysfs_remove_file_ns(struct kobject *kobj, 504 const struct attribute *attr, 505 const void *ns) 506 { 507 } 508 509 static inline bool sysfs_remove_file_self(struct kobject *kobj, 510 const struct attribute *attr) 511 { 512 return false; 513 } 514 515 static inline void sysfs_remove_files(struct kobject *kobj, 516 const struct attribute * const *attr) 517 { 518 } 519 520 static inline int sysfs_create_bin_file(struct kobject *kobj, 521 const struct bin_attribute *attr) 522 { 523 return 0; 524 } 525 526 static inline void sysfs_remove_bin_file(struct kobject *kobj, 527 const struct bin_attribute *attr) 528 { 529 } 530 531 static inline int sysfs_create_link(struct kobject *kobj, 532 struct kobject *target, const char *name) 533 { 534 return 0; 535 } 536 537 static inline int sysfs_create_link_nowarn(struct kobject *kobj, 538 struct kobject *target, 539 const char *name) 540 { 541 return 0; 542 } 543 544 static inline void sysfs_remove_link(struct kobject *kobj, const char *name) 545 { 546 } 547 548 static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t, 549 const char *old_name, 550 const char *new_name, const void *ns) 551 { 552 return 0; 553 } 554 555 static inline void sysfs_delete_link(struct kobject *k, struct kobject *t, 556 const char *name) 557 { 558 } 559 560 static inline int sysfs_create_group(struct kobject *kobj, 561 const struct attribute_group *grp) 562 { 563 return 0; 564 } 565 566 static inline int sysfs_create_groups(struct kobject *kobj, 567 const struct attribute_group **groups) 568 { 569 return 0; 570 } 571 572 static inline int sysfs_update_groups(struct kobject *kobj, 573 const struct attribute_group **groups) 574 { 575 return 0; 576 } 577 578 static inline int sysfs_update_group(struct kobject *kobj, 579 const struct attribute_group *grp) 580 { 581 return 0; 582 } 583 584 static inline void sysfs_remove_group(struct kobject *kobj, 585 const struct attribute_group *grp) 586 { 587 } 588 589 static inline void sysfs_remove_groups(struct kobject *kobj, 590 const struct attribute_group **groups) 591 { 592 } 593 594 static inline int sysfs_add_file_to_group(struct kobject *kobj, 595 const struct attribute *attr, const char *group) 596 { 597 return 0; 598 } 599 600 static inline void sysfs_remove_file_from_group(struct kobject *kobj, 601 const struct attribute *attr, const char *group) 602 { 603 } 604 605 static inline int sysfs_merge_group(struct kobject *kobj, 606 const struct attribute_group *grp) 607 { 608 return 0; 609 } 610 611 static inline void sysfs_unmerge_group(struct kobject *kobj, 612 const struct attribute_group *grp) 613 { 614 } 615 616 static inline int sysfs_add_link_to_group(struct kobject *kobj, 617 const char *group_name, struct kobject *target, 618 const char *link_name) 619 { 620 return 0; 621 } 622 623 static inline void sysfs_remove_link_from_group(struct kobject *kobj, 624 const char *group_name, const char *link_name) 625 { 626 } 627 628 static inline int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, 629 struct kobject *target_kobj, 630 const char *target_name, 631 const char *symlink_name) 632 { 633 return 0; 634 } 635 636 static inline void sysfs_notify(struct kobject *kobj, const char *dir, 637 const char *attr) 638 { 639 } 640 641 static inline int __must_check sysfs_init(void) 642 { 643 return 0; 644 } 645 646 static inline void sysfs_enable_ns(struct kernfs_node *kn) 647 { 648 } 649 650 static inline int sysfs_file_change_owner(struct kobject *kobj, 651 const char *name, kuid_t kuid, 652 kgid_t kgid) 653 { 654 return 0; 655 } 656 657 static inline int sysfs_link_change_owner(struct kobject *kobj, 658 struct kobject *targ, 659 const char *name, kuid_t kuid, 660 kgid_t kgid) 661 { 662 return 0; 663 } 664 665 static inline int sysfs_change_owner(struct kobject *kobj, kuid_t kuid, kgid_t kgid) 666 { 667 return 0; 668 } 669 670 static inline int sysfs_groups_change_owner(struct kobject *kobj, 671 const struct attribute_group **groups, 672 kuid_t kuid, kgid_t kgid) 673 { 674 return 0; 675 } 676 677 static inline int sysfs_group_change_owner(struct kobject *kobj, 678 const struct attribute_group *groups, 679 kuid_t kuid, kgid_t kgid) 680 { 681 return 0; 682 } 683 684 __printf(2, 3) 685 static inline int sysfs_emit(char *buf, const char *fmt, ...) 686 { 687 return 0; 688 } 689 690 __printf(3, 4) 691 static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...) 692 { 693 return 0; 694 } 695 #endif /* CONFIG_SYSFS */ 696 697 static inline int __must_check sysfs_create_file(struct kobject *kobj, 698 const struct attribute *attr) 699 { 700 return sysfs_create_file_ns(kobj, attr, NULL); 701 } 702 703 static inline void sysfs_remove_file(struct kobject *kobj, 704 const struct attribute *attr) 705 { 706 sysfs_remove_file_ns(kobj, attr, NULL); 707 } 708 709 static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target, 710 const char *old_name, const char *new_name) 711 { 712 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL); 713 } 714 715 static inline void sysfs_notify_dirent(struct kernfs_node *kn) 716 { 717 kernfs_notify(kn); 718 } 719 720 static inline struct kernfs_node *sysfs_get_dirent(struct kernfs_node *parent, 721 const char *name) 722 { 723 return kernfs_find_and_get(parent, name); 724 } 725 726 static inline struct kernfs_node *sysfs_get(struct kernfs_node *kn) 727 { 728 kernfs_get(kn); 729 return kn; 730 } 731 732 static inline void sysfs_put(struct kernfs_node *kn) 733 { 734 kernfs_put(kn); 735 } 736 737 #endif /* _SYSFS_H_ */ 738