[PATCH v2 39/50] convert gadgetfs

Al Viro
2025-10-28T00:46:21Z

same as functionfs

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
drivers/usb/gadget/legacy/inode.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index bcc25f13483f..62566a8e7451 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1989,17 +1989,20 @@ static int gadgetfs_create_file (struct super_block *sb, char const *name,
struct dentry *dentry;
struct inode *inode;

- dentry = d_alloc_name(sb->s_root, name);
- if (!dentry)
- return -ENOMEM;
-
inode = gadgetfs_make_inode (sb, data, fops,
S_IFREG | (default_perm & S_IRWXUGO));
- if (!inode) {
- dput(dentry);
+ if (!inode)
return -ENOMEM;
+
+ dentry = simple_start_creating(sb->s_root, name);
+ if (IS_ERR(dentry)) {
+ iput(inode);
+ return PTR_ERR(dentry);
}
- d_add (dentry, inode);
+
+ d_make_persistent(dentry, inode);
+
+ simple_done_creating(dentry);
return 0;
}

@@ -2096,7 +2099,7 @@ static void
gadgetfs_kill_sb (struct super_block *sb)
{
mutex_lock(&sb_mutex);
- kill_litter_super (sb);
+ kill_anon_super (sb);
if (the_device) {
put_dev (the_device);
the_device = NULL;
--
2.47.3