mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shang XiaoJing <shangxiaojing@huawei.com>
To: <jlbec@evilplan.org>, <hch@lst.de>, <linux-kernel@vger.kernel.org>
Cc: <shangxiaojing@huawei.com>
Subject: [PATCH -next 3/3] configfs: Add subsys_to_item helper
Date: Fri, 9 Sep 2022 14:56:11 +0800	[thread overview]
Message-ID: <20220909065611.31695-4-shangxiaojing@huawei.com> (raw)
In-Reply-To: <20220909065611.31695-1-shangxiaojing@huawei.com>

Add helper function subsys_to_item, which get the corresponding
config_item of the configfs_subsystem.

Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
---
 fs/configfs/dir.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index b5614b66add2..e4386eab3428 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -281,7 +281,7 @@ static void configfs_remove_dirent(struct dentry *dentry)
 
 /**
  *	configfs_create_dir - create a directory for an config_item.
- *	@item:		config_itemwe're creating directory for.
+ *	@item:		config_item we're creating directory for.
  *	@dentry:	config_item's dentry.
  *	@frag:		config_item's fragment.
  *
@@ -616,6 +616,12 @@ static inline struct dentry *group_to_dentry(struct config_group *group)
 	return group->cg_item.ci_dentry;
 }
 
+static inline
+struct config_item *subsys_to_item(struct configfs_subsystem *subsys)
+{
+	return &subsys->su_group.cg_item;
+}
+
 static int configfs_attach_group(struct config_item *parent_item,
 				 struct config_item *item,
 				 struct dentry *dentry,
@@ -1119,7 +1125,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys,
 {
 	int ret;
 	struct configfs_dirent *subsys_sd;
-	struct config_item *s_item = &subsys->su_group.cg_item;
+	struct config_item *s_item = subsys_to_item(subsys);
 	struct dentry *root;
 
 	/*
@@ -1238,11 +1244,11 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys,
 		 */
 		subsys_sd = configfs_find_subsys_dentry(
 				group_to_dentry(root)->d_fsdata,
-				&target_subsys->su_group.cg_item);
+				subsys_to_item(target_subsys));
 		if (!subsys_sd)
 			goto out_root_unlock;
 	} else {
-		subsys_sd = target_subsys->su_group.cg_item.ci_dentry->d_fsdata;
+		subsys_sd = subsys_to_item(target_subsys)->ci_dentry->d_fsdata;
 	}
 
 	/* Now we can execute core of depend item */
@@ -1315,11 +1321,11 @@ static int configfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
 	 * being created.  We don't want to safely pin the new item but
 	 * fail to pin the subsystem it sits under.
 	 */
-	if (!subsys->su_group.cg_item.ci_type) {
+	if (!subsys_to_item(subsys)->ci_type) {
 		ret = -EINVAL;
 		goto out_put;
 	}
-	subsys_owner = subsys->su_group.cg_item.ci_type->ct_owner;
+	subsys_owner = subsys_to_item(subsys)->ci_type->ct_owner;
 	if (!try_module_get(subsys_owner)) {
 		ret = -EINVAL;
 		goto out_put;
@@ -1469,8 +1475,8 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
 	}
 
 	/* configfs_mkdir() shouldn't have allowed this */
-	BUG_ON(!subsys->su_group.cg_item.ci_type);
-	subsys_owner = subsys->su_group.cg_item.ci_type->ct_owner;
+	BUG_ON(!subsys_to_item(subsys)->ci_type);
+	subsys_owner = subsys_to_item(subsys)->ci_type->ct_owner;
 
 	/*
 	 * Ensure that no racing symlink() will make detach_prep() fail while
-- 
2.17.1


      parent reply	other threads:[~2022-09-09  6:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09  6:56 [PATCH -next 0/3] configfs: Clean up by adding helpers Shang XiaoJing
2022-09-09  6:56 ` [PATCH -next 1/3] configfs: Add configfs_remove_drop_dirent helper Shang XiaoJing
2022-09-09  6:56 ` [PATCH -next 2/3] configfs: Add group_to_dentry helper Shang XiaoJing
2022-09-09  6:56 ` Shang XiaoJing [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220909065611.31695-4-shangxiaojing@huawei.com \
    --to=shangxiaojing@huawei.com \
    --cc=hch@lst.de \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®