From: Al Viro <viro@zeniv.linux.org.uk>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-fsdevel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 01/11] zynqmp: don't bother with debugfs_file_{get,put}() in proxied fops
Date: Wed, 2 Jul 2025 22:14:08 +0100 [thread overview]
Message-ID: <20250702211408.GA3406663@ZenIV> (raw)
In-Reply-To: <20250702211305.GE1880847@ZenIV>
When debugfs file has been created by debugfs_create_file_unsafe(),
we do need the file_operations methods to use debugfs_file_{get,put}()
to prevent concurrent removal; for files created by debugfs_create_file()
that is done in the wrappers that call underlying methods, so there's
no point whatsoever duplicating that in the underlying methods themselves.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
drivers/gpu/drm/xlnx/zynqmp_dp.c | 38 ++++----------------------------
1 file changed, 4 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 238cbb49963e..197defe4f928 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -1869,20 +1869,14 @@ static int zynqmp_dp_test_setup(struct zynqmp_dp *dp)
static ssize_t zynqmp_dp_pattern_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
- struct dentry *dentry = file->f_path.dentry;
struct zynqmp_dp *dp = file->private_data;
char buf[16];
ssize_t ret;
- ret = debugfs_file_get(dentry);
- if (unlikely(ret))
- return ret;
-
scoped_guard(mutex, &dp->lock)
ret = snprintf(buf, sizeof(buf), "%s\n",
test_pattern_str[dp->test.pattern]);
- debugfs_file_put(dentry);
return simple_read_from_buffer(user_buf, count, ppos, buf, ret);
}
@@ -1890,27 +1884,20 @@ static ssize_t zynqmp_dp_pattern_write(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
{
- struct dentry *dentry = file->f_path.dentry;
struct zynqmp_dp *dp = file->private_data;
char buf[16];
ssize_t ret;
int pattern;
- ret = debugfs_file_get(dentry);
- if (unlikely(ret))
- return ret;
-
ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf,
count);
if (ret < 0)
- goto out;
+ return ret;
buf[ret] = '\0';
pattern = sysfs_match_string(test_pattern_str, buf);
- if (pattern < 0) {
- ret = -EINVAL;
- goto out;
- }
+ if (pattern < 0)
+ return -EINVAL;
mutex_lock(&dp->lock);
dp->test.pattern = pattern;
@@ -1919,8 +1906,6 @@ static ssize_t zynqmp_dp_pattern_write(struct file *file,
dp->test.custom) ?: ret;
mutex_unlock(&dp->lock);
-out:
- debugfs_file_put(dentry);
return ret;
}
@@ -2026,20 +2011,13 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_zynqmp_dp_active, zynqmp_dp_active_get,
static ssize_t zynqmp_dp_custom_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
- struct dentry *dentry = file->f_path.dentry;
struct zynqmp_dp *dp = file->private_data;
ssize_t ret;
- ret = debugfs_file_get(dentry);
- if (unlikely(ret))
- return ret;
-
mutex_lock(&dp->lock);
ret = simple_read_from_buffer(user_buf, count, ppos, &dp->test.custom,
sizeof(dp->test.custom));
mutex_unlock(&dp->lock);
-
- debugfs_file_put(dentry);
return ret;
}
@@ -2047,18 +2025,13 @@ static ssize_t zynqmp_dp_custom_write(struct file *file,
const char __user *user_buf,
size_t count, loff_t *ppos)
{
- struct dentry *dentry = file->f_path.dentry;
struct zynqmp_dp *dp = file->private_data;
ssize_t ret;
char buf[sizeof(dp->test.custom)];
- ret = debugfs_file_get(dentry);
- if (unlikely(ret))
- return ret;
-
ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
if (ret < 0)
- goto out;
+ return ret;
mutex_lock(&dp->lock);
memcpy(dp->test.custom, buf, ret);
@@ -2066,9 +2039,6 @@ static ssize_t zynqmp_dp_custom_write(struct file *file,
ret = zynqmp_dp_set_test_pattern(dp, dp->test.pattern,
dp->test.custom) ?: ret;
mutex_unlock(&dp->lock);
-
-out:
- debugfs_file_put(dentry);
return ret;
}
--
2.39.5
next prev parent reply other threads:[~2025-07-02 21:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 21:13 [PATCHES] assorted debugfs stuff Al Viro
2025-07-02 21:14 ` Al Viro [this message]
2025-07-02 21:15 ` [PATCH 02/11] hfi1: get rid of redundant debugfs_file_{get,put}() Al Viro
2025-07-02 21:16 ` [PATCH 03/11] regmap: " Al Viro
2025-07-03 11:10 ` Mark Brown
2025-07-02 21:16 ` [PATCH 04/11] resctrl: get rid of pointless debugfs_file_{get,put}() Al Viro
2025-07-02 21:24 ` Luck, Tony
2025-07-02 23:45 ` Reinette Chatre
2025-07-03 0:24 ` Al Viro
2025-07-03 5:40 ` Greg Kroah-Hartman
2025-07-03 15:10 ` Reinette Chatre
2025-07-02 21:17 ` [PATCH 05/11] vmscan: don't bother with debugfs_real_fops() Al Viro
2025-07-03 11:51 ` Matthew Wilcox
2025-07-04 4:07 ` Al Viro
2025-07-02 21:22 ` [PATCH 06/11] netronome: " Al Viro
2025-07-03 7:11 ` Louis Peens
2025-07-02 21:24 ` [PATCH 07/11] debugfs: split short and full proxy wrappers, kill debugfs_real_fops() Al Viro
2025-07-02 21:25 ` [PATCH 08/11] fix tt_command_write() Al Viro
2025-07-03 11:14 ` Rafael J. Wysocki
2025-07-02 21:26 ` [PATCH 09/11] debugfs_get_aux(): allow storing non-const void * Al Viro
2025-07-02 21:28 ` [PATCH 10/11] blk-mq-debugfs: use debugfs_get_aux() Al Viro
2025-07-02 21:29 ` [PATCH 11/11] lpfc: don't use file->f_path.dentry for comparisons Al Viro
[not found] ` <b3ff59d4-c6c3-4b48-97e3-d32e98c12de7@broadcom.com>
[not found] ` <CAAmqgVMmgW4PWy289P4a8N0FSZA+cHybNkKbLzFx_qBQtu8ZHA@mail.gmail.com>
2025-07-03 20:37 ` Justin Tee
2025-07-04 4:25 ` Al Viro
2025-07-04 18:33 ` Justin Tee
2025-07-04 20:10 ` Al Viro
2025-07-07 19:29 ` Justin Tee
2025-07-08 2:57 ` Al Viro
2025-07-08 17:17 ` Justin Tee
2025-07-02 23:19 ` (subset) [PATCH 01/11] zynqmp: don't bother with debugfs_file_{get,put}() in proxied fops Jens Axboe
2025-07-03 0:23 ` Al Viro
2025-07-03 0:56 ` Jens Axboe
2025-07-03 11:37 ` Greg Kroah-Hartman
2025-07-03 15:10 ` Al Viro
2025-07-04 15:34 ` Mark Brown
2025-07-09 11:35 ` [PATCHES] assorted debugfs stuff Greg Kroah-Hartman
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=20250702211408.GA3406663@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fsdevel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.