diff options
-rw-r--r-- | fs/sysfs/file.c | 33 | ||||
-rw-r--r-- | include/linux/kernfs.h | 3 | ||||
-rw-r--r-- | include/linux/sysfs.h | 9 |
3 files changed, 30 insertions, 15 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 74e3478d9cb4..a68cbef3a674 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -851,7 +851,13 @@ static unsigned int kernfs_file_poll(struct file *filp, poll_table *wait) | |||
851 | return DEFAULT_POLLMASK|POLLERR|POLLPRI; | 851 | return DEFAULT_POLLMASK|POLLERR|POLLPRI; |
852 | } | 852 | } |
853 | 853 | ||
854 | void sysfs_notify_dirent(struct sysfs_dirent *sd) | 854 | /** |
855 | * kernfs_notify - notify a kernfs file | ||
856 | * @sd: file to notify | ||
857 | * | ||
858 | * Notify @sd such that poll(2) on @sd wakes up. | ||
859 | */ | ||
860 | void kernfs_notify(struct sysfs_dirent *sd) | ||
855 | { | 861 | { |
856 | struct sysfs_open_dirent *od; | 862 | struct sysfs_open_dirent *od; |
857 | unsigned long flags; | 863 | unsigned long flags; |
@@ -868,22 +874,27 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd) | |||
868 | 874 | ||
869 | spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags); | 875 | spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags); |
870 | } | 876 | } |
871 | EXPORT_SYMBOL_GPL(sysfs_notify_dirent); | 877 | EXPORT_SYMBOL_GPL(kernfs_notify); |
872 | 878 | ||
873 | void sysfs_notify(struct kobject *k, const char *dir, const char *attr) | 879 | void sysfs_notify(struct kobject *k, const char *dir, const char *attr) |
874 | { | 880 | { |
875 | struct sysfs_dirent *sd = k->sd; | 881 | struct sysfs_dirent *sd = k->sd, *tmp; |
876 | |||
877 | mutex_lock(&sysfs_mutex); | ||
878 | 882 | ||
879 | if (sd && dir) | 883 | if (sd && dir) |
880 | sd = sysfs_find_dirent(sd, dir, NULL); | 884 | sd = sysfs_get_dirent(sd, dir); |
881 | if (sd && attr) | 885 | else |
882 | sd = sysfs_find_dirent(sd, attr, NULL); | 886 | sysfs_get(sd); |
883 | if (sd) | ||
884 | sysfs_notify_dirent(sd); | ||
885 | 887 | ||
886 | mutex_unlock(&sysfs_mutex); | 888 | if (sd && attr) { |
889 | tmp = sysfs_get_dirent(sd, attr); | ||
890 | sysfs_put(sd); | ||
891 | sd = tmp; | ||
892 | } | ||
893 | |||
894 | if (sd) { | ||
895 | kernfs_notify(sd); | ||
896 | sysfs_put(sd); | ||
897 | } | ||
887 | } | 898 | } |
888 | EXPORT_SYMBOL_GPL(sysfs_notify); | 899 | EXPORT_SYMBOL_GPL(sysfs_notify); |
889 | 900 | ||
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index ba993ebcd81e..f20796ecc76e 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h | |||
@@ -84,6 +84,7 @@ int kernfs_rename_ns(struct sysfs_dirent *sd, struct sysfs_dirent *new_parent, | |||
84 | const char *new_name, const void *new_ns); | 84 | const char *new_name, const void *new_ns); |
85 | void kernfs_enable_ns(struct sysfs_dirent *sd); | 85 | void kernfs_enable_ns(struct sysfs_dirent *sd); |
86 | int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr); | 86 | int kernfs_setattr(struct sysfs_dirent *sd, const struct iattr *iattr); |
87 | void kernfs_notify(struct sysfs_dirent *sd); | ||
87 | 88 | ||
88 | #else /* CONFIG_SYSFS */ | 89 | #else /* CONFIG_SYSFS */ |
89 | 90 | ||
@@ -120,6 +121,8 @@ static inline int kernfs_setattr(struct sysfs_dirent *sd, | |||
120 | const struct iattr *iattr) | 121 | const struct iattr *iattr) |
121 | { return -ENOSYS; } | 122 | { return -ENOSYS; } |
122 | 123 | ||
124 | static inline void kernfs_notify(struct sysfs_dirent *sd) { } | ||
125 | |||
123 | #endif /* CONFIG_SYSFS */ | 126 | #endif /* CONFIG_SYSFS */ |
124 | 127 | ||
125 | static inline struct sysfs_dirent * | 128 | static inline struct sysfs_dirent * |
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 2bc735d3e938..0ab2b023b613 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
@@ -243,7 +243,6 @@ void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name, | |||
243 | const char *link_name); | 243 | const char *link_name); |
244 | 244 | ||
245 | void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); | 245 | void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); |
246 | void sysfs_notify_dirent(struct sysfs_dirent *sd); | ||
247 | struct sysfs_dirent *sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd, | 246 | struct sysfs_dirent *sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd, |
248 | const unsigned char *name, | 247 | const unsigned char *name, |
249 | const void *ns); | 248 | const void *ns); |
@@ -418,9 +417,6 @@ static inline void sysfs_notify(struct kobject *kobj, const char *dir, | |||
418 | const char *attr) | 417 | const char *attr) |
419 | { | 418 | { |
420 | } | 419 | } |
421 | static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) | ||
422 | { | ||
423 | } | ||
424 | static inline struct sysfs_dirent * | 420 | static inline struct sysfs_dirent * |
425 | sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd, const unsigned char *name, | 421 | sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd, const unsigned char *name, |
426 | const void *ns) | 422 | const void *ns) |
@@ -466,4 +462,9 @@ sysfs_get_dirent(struct sysfs_dirent *parent_sd, const unsigned char *name) | |||
466 | return sysfs_get_dirent_ns(parent_sd, name, NULL); | 462 | return sysfs_get_dirent_ns(parent_sd, name, NULL); |
467 | } | 463 | } |
468 | 464 | ||
465 | static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) | ||
466 | { | ||
467 | kernfs_notify(sd); | ||
468 | } | ||
469 | |||
469 | #endif /* _SYSFS_H_ */ | 470 | #endif /* _SYSFS_H_ */ |