File Index
Files and directories
Sign in
FILE

xfs_sysfs.h

File preview with syntax highlighting.

linux-6.19.14/fs/xfs/xfs_sysfs.h C
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (c) 2014 Red Hat, Inc.
 4 * All Rights Reserved.
 5 */
 6
 7#ifndef __XFS_SYSFS_H__
 8#define __XFS_SYSFS_H__
 9
10extern const struct kobj_type xfs_dbg_ktype;	/* debug */
11extern const struct kobj_type xfs_log_ktype;	/* xlog */
12extern const struct kobj_type xfs_stats_ktype;	/* stats */
13
14static inline struct xfs_kobj *
15to_kobj(struct kobject *kobject)
16{
17	return container_of(kobject, struct xfs_kobj, kobject);
18}
19
20static inline void
21xfs_sysfs_release(struct kobject *kobject)
22{
23	struct xfs_kobj *kobj = to_kobj(kobject);
24	complete(&kobj->complete);
25}
26
27static inline int
28xfs_sysfs_init(
29	struct xfs_kobj		*kobj,
30	const struct kobj_type	*ktype,
31	struct xfs_kobj		*parent_kobj,
32	const char		*name)
33{
34	struct kobject		*parent;
35	int err;
36
37	parent = parent_kobj ? &parent_kobj->kobject : NULL;
38	init_completion(&kobj->complete);
39	err = kobject_init_and_add(&kobj->kobject, ktype, parent, "%s", name);
40	if (err)
41		kobject_put(&kobj->kobject);
42
43	return err;
44}
45
46static inline void
47xfs_sysfs_del(
48	struct xfs_kobj	*kobj)
49{
50	kobject_del(&kobj->kobject);
51	kobject_put(&kobj->kobject);
52	wait_for_completion(&kobj->complete);
53}
54
55int	xfs_mount_sysfs_init(struct xfs_mount *mp);
56void	xfs_mount_sysfs_del(struct xfs_mount *mp);
57
58#endif	/* __XFS_SYSFS_H__ */
~/ Read-only file preview.