xfs_sysfs.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2014 Red Hat, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_SYSFS_H__
  7. #define __XFS_SYSFS_H__
  8. extern struct kobj_type xfs_mp_ktype; /* xfs_mount */
  9. extern struct kobj_type xfs_dbg_ktype; /* debug */
  10. extern struct kobj_type xfs_log_ktype; /* xlog */
  11. extern struct kobj_type xfs_stats_ktype; /* stats */
  12. static inline struct xfs_kobj *
  13. to_kobj(struct kobject *kobject)
  14. {
  15. return container_of(kobject, struct xfs_kobj, kobject);
  16. }
  17. static inline void
  18. xfs_sysfs_release(struct kobject *kobject)
  19. {
  20. struct xfs_kobj *kobj = to_kobj(kobject);
  21. complete(&kobj->complete);
  22. }
  23. static inline int
  24. xfs_sysfs_init(
  25. struct xfs_kobj *kobj,
  26. struct kobj_type *ktype,
  27. struct xfs_kobj *parent_kobj,
  28. const char *name)
  29. {
  30. struct kobject *parent;
  31. parent = parent_kobj ? &parent_kobj->kobject : NULL;
  32. init_completion(&kobj->complete);
  33. return kobject_init_and_add(&kobj->kobject, ktype, parent, "%s", name);
  34. }
  35. static inline void
  36. xfs_sysfs_del(
  37. struct xfs_kobj *kobj)
  38. {
  39. kobject_del(&kobj->kobject);
  40. kobject_put(&kobj->kobject);
  41. wait_for_completion(&kobj->complete);
  42. }
  43. int xfs_error_sysfs_init(struct xfs_mount *mp);
  44. void xfs_error_sysfs_del(struct xfs_mount *mp);
  45. #endif /* __XFS_SYSFS_H__ */