mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
zynqmp: don't bother with debugfs_file_{get,put}() in proxied fops
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>
Link: https://lore.kernel.org/r/20250702211408.GA3406663@ZenIV
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5f512533b7
commit
327a206c0e
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user