aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sysfs.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-28 14:54:30 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-29 20:55:10 -0500
commitccf73cf336dc55bc52748205dee998d2fd4a8808 (patch)
tree8e3a3b9891e6b9d4804299cd23110c91d8f8016e /include/linux/sysfs.h
parent517e64f57883bd63c5a4ab8b3d0d3ed68c55d0cf (diff)
sysfs, kernfs: introduce kernfs[_find_and]_get() and kernfs_put()
Introduce kernfs interface for finding, getting and putting sysfs_dirents. * sysfs_find_dirent() is renamed to kernfs_find_ns() and lockdep assertion for sysfs_mutex is added. * sysfs_get_dirent_ns() is renamed to kernfs_find_and_get(). * Macro inline dancing around __sysfs_get/put() are removed and kernfs_get/put() are made proper functions implemented in fs/sysfs/dir.c. While the conversions are mostly equivalent, there's one difference - kernfs_get() doesn't return the input param as its return value. This change is intentional. While passing through the input increases writability in some areas, it is unnecessary and has been shown to cause confusion regarding how the last ref is handled. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/sysfs.h')
-rw-r--r--include/linux/sysfs.h35
1 files changed, 14 insertions, 21 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 0ab2b023b613..cd8f90bf51a7 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -243,11 +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
245void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); 245void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
246struct sysfs_dirent *sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd,
247 const unsigned char *name,
248 const void *ns);
249struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
250void sysfs_put(struct sysfs_dirent *sd);
251 246
252int __must_check sysfs_init(void); 247int __must_check sysfs_init(void);
253 248
@@ -417,19 +412,6 @@ static inline void sysfs_notify(struct kobject *kobj, const char *dir,
417 const char *attr) 412 const char *attr)
418{ 413{
419} 414}
420static inline struct sysfs_dirent *
421sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd, const unsigned char *name,
422 const void *ns)
423{
424 return NULL;
425}
426static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
427{
428 return NULL;
429}
430static inline void sysfs_put(struct sysfs_dirent *sd)
431{
432}
433 415
434static inline int __must_check sysfs_init(void) 416static inline int __must_check sysfs_init(void)
435{ 417{
@@ -456,15 +438,26 @@ static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target
456 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL); 438 return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
457} 439}
458 440
441static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
442{
443 kernfs_notify(sd);
444}
445
459static inline struct sysfs_dirent * 446static inline struct sysfs_dirent *
460sysfs_get_dirent(struct sysfs_dirent *parent_sd, const unsigned char *name) 447sysfs_get_dirent(struct sysfs_dirent *parent_sd, const unsigned char *name)
461{ 448{
462 return sysfs_get_dirent_ns(parent_sd, name, NULL); 449 return kernfs_find_and_get(parent_sd, name);
463} 450}
464 451
465static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) 452static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
466{ 453{
467 kernfs_notify(sd); 454 kernfs_get(sd);
455 return sd;
456}
457
458static inline void sysfs_put(struct sysfs_dirent *sd)
459{
460 kernfs_put(sd);
468} 461}
469 462
470#endif /* _SYSFS_H_ */ 463#endif /* _SYSFS_H_ */