diff options
| -rw-r--r-- | fs/sysfs/file.c | 20 | ||||
| -rw-r--r-- | include/linux/sysfs.h | 14 |
2 files changed, 34 insertions, 0 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index dc30d9e31683..50b725bcc3f3 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
| @@ -542,6 +542,18 @@ int sysfs_create_file(struct kobject * kobj, const struct attribute * attr) | |||
| 542 | 542 | ||
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | int sysfs_create_files(struct kobject *kobj, const struct attribute **ptr) | ||
| 546 | { | ||
| 547 | int err = 0; | ||
| 548 | int i; | ||
| 549 | |||
| 550 | for (i = 0; ptr[i] && !err; i++) | ||
| 551 | err = sysfs_create_file(kobj, ptr[i]); | ||
| 552 | if (err) | ||
| 553 | while (--i >= 0) | ||
| 554 | sysfs_remove_file(kobj, ptr[i]); | ||
| 555 | return err; | ||
| 556 | } | ||
| 545 | 557 | ||
| 546 | /** | 558 | /** |
| 547 | * sysfs_add_file_to_group - add an attribute file to a pre-existing group. | 559 | * sysfs_add_file_to_group - add an attribute file to a pre-existing group. |
| @@ -614,6 +626,12 @@ void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) | |||
| 614 | sysfs_hash_and_remove(kobj->sd, attr->name); | 626 | sysfs_hash_and_remove(kobj->sd, attr->name); |
| 615 | } | 627 | } |
| 616 | 628 | ||
| 629 | void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr) | ||
| 630 | { | ||
| 631 | int i; | ||
| 632 | for (i = 0; ptr[i]; i++) | ||
| 633 | sysfs_remove_file(kobj, ptr[i]); | ||
| 634 | } | ||
| 617 | 635 | ||
| 618 | /** | 636 | /** |
| 619 | * sysfs_remove_file_from_group - remove an attribute file from a group. | 637 | * sysfs_remove_file_from_group - remove an attribute file from a group. |
| @@ -732,3 +750,5 @@ EXPORT_SYMBOL_GPL(sysfs_schedule_callback); | |||
| 732 | 750 | ||
| 733 | EXPORT_SYMBOL_GPL(sysfs_create_file); | 751 | EXPORT_SYMBOL_GPL(sysfs_create_file); |
| 734 | EXPORT_SYMBOL_GPL(sysfs_remove_file); | 752 | EXPORT_SYMBOL_GPL(sysfs_remove_file); |
| 753 | EXPORT_SYMBOL_GPL(sysfs_remove_files); | ||
| 754 | EXPORT_SYMBOL_GPL(sysfs_create_files); | ||
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index cfa83083a2d4..3e8526582146 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
| @@ -94,9 +94,12 @@ int __must_check sysfs_move_dir(struct kobject *kobj, | |||
| 94 | 94 | ||
| 95 | int __must_check sysfs_create_file(struct kobject *kobj, | 95 | int __must_check sysfs_create_file(struct kobject *kobj, |
| 96 | const struct attribute *attr); | 96 | const struct attribute *attr); |
| 97 | int __must_check sysfs_create_files(struct kobject *kobj, | ||
| 98 | const struct attribute **attr); | ||
| 97 | int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, | 99 | int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, |
| 98 | mode_t mode); | 100 | mode_t mode); |
| 99 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); | 101 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); |
| 102 | void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); | ||
| 100 | 103 | ||
| 101 | int __must_check sysfs_create_bin_file(struct kobject *kobj, | 104 | int __must_check sysfs_create_bin_file(struct kobject *kobj, |
| 102 | const struct bin_attribute *attr); | 105 | const struct bin_attribute *attr); |
| @@ -164,6 +167,12 @@ static inline int sysfs_create_file(struct kobject *kobj, | |||
| 164 | return 0; | 167 | return 0; |
| 165 | } | 168 | } |
| 166 | 169 | ||
| 170 | static inline int sysfs_create_files(struct kobject *kobj, | ||
| 171 | const struct attribute **attr) | ||
| 172 | { | ||
| 173 | return 0; | ||
| 174 | } | ||
| 175 | |||
| 167 | static inline int sysfs_chmod_file(struct kobject *kobj, | 176 | static inline int sysfs_chmod_file(struct kobject *kobj, |
| 168 | struct attribute *attr, mode_t mode) | 177 | struct attribute *attr, mode_t mode) |
| 169 | { | 178 | { |
| @@ -175,6 +184,11 @@ static inline void sysfs_remove_file(struct kobject *kobj, | |||
| 175 | { | 184 | { |
| 176 | } | 185 | } |
| 177 | 186 | ||
| 187 | static inline void sysfs_remove_files(struct kobject *kobj, | ||
| 188 | const struct attribute **attr) | ||
| 189 | { | ||
| 190 | } | ||
| 191 | |||
| 178 | static inline int sysfs_create_bin_file(struct kobject *kobj, | 192 | static inline int sysfs_create_bin_file(struct kobject *kobj, |
| 179 | const struct bin_attribute *attr) | 193 | const struct bin_attribute *attr) |
| 180 | { | 194 | { |
