Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2014 Red Hat, Inc.
0004  * All Rights Reserved.
0005  */
0006 
0007 #ifndef __XFS_SYSFS_H__
0008 #define __XFS_SYSFS_H__
0009 
0010 extern struct kobj_type xfs_mp_ktype;   /* xfs_mount */
0011 extern struct kobj_type xfs_dbg_ktype;  /* debug */
0012 extern struct kobj_type xfs_log_ktype;  /* xlog */
0013 extern struct kobj_type xfs_stats_ktype;    /* stats */
0014 
0015 static inline struct xfs_kobj *
0016 to_kobj(struct kobject *kobject)
0017 {
0018     return container_of(kobject, struct xfs_kobj, kobject);
0019 }
0020 
0021 static inline void
0022 xfs_sysfs_release(struct kobject *kobject)
0023 {
0024     struct xfs_kobj *kobj = to_kobj(kobject);
0025     complete(&kobj->complete);
0026 }
0027 
0028 static inline int
0029 xfs_sysfs_init(
0030     struct xfs_kobj     *kobj,
0031     struct kobj_type    *ktype,
0032     struct xfs_kobj     *parent_kobj,
0033     const char      *name)
0034 {
0035     struct kobject      *parent;
0036 
0037     parent = parent_kobj ? &parent_kobj->kobject : NULL;
0038     init_completion(&kobj->complete);
0039     return kobject_init_and_add(&kobj->kobject, ktype, parent, "%s", name);
0040 }
0041 
0042 static inline void
0043 xfs_sysfs_del(
0044     struct xfs_kobj *kobj)
0045 {
0046     kobject_del(&kobj->kobject);
0047     kobject_put(&kobj->kobject);
0048     wait_for_completion(&kobj->complete);
0049 }
0050 
0051 int xfs_error_sysfs_init(struct xfs_mount *mp);
0052 void    xfs_error_sysfs_del(struct xfs_mount *mp);
0053 
0054 #endif  /* __XFS_SYSFS_H__ */