Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Al Viro and committed by
Greg Kroah-Hartman
327a206c 5f512533

+4 -34
+4 -34
drivers/gpu/drm/xlnx/zynqmp_dp.c
··· 1869 1869 static ssize_t zynqmp_dp_pattern_read(struct file *file, char __user *user_buf, 1870 1870 size_t count, loff_t *ppos) 1871 1871 { 1872 - struct dentry *dentry = file->f_path.dentry; 1873 1872 struct zynqmp_dp *dp = file->private_data; 1874 1873 char buf[16]; 1875 1874 ssize_t ret; 1876 - 1877 - ret = debugfs_file_get(dentry); 1878 - if (unlikely(ret)) 1879 - return ret; 1880 1875 1881 1876 scoped_guard(mutex, &dp->lock) 1882 1877 ret = snprintf(buf, sizeof(buf), "%s\n", 1883 1878 test_pattern_str[dp->test.pattern]); 1884 1879 1885 - debugfs_file_put(dentry); 1886 1880 return simple_read_from_buffer(user_buf, count, ppos, buf, ret); 1887 1881 } 1888 1882 ··· 1884 1890 const char __user *user_buf, 1885 1891 size_t count, loff_t *ppos) 1886 1892 { 1887 - struct dentry *dentry = file->f_path.dentry; 1888 1893 struct zynqmp_dp *dp = file->private_data; 1889 1894 char buf[16]; 1890 1895 ssize_t ret; 1891 1896 int pattern; 1892 1897 1893 - ret = debugfs_file_get(dentry); 1894 - if (unlikely(ret)) 1895 - return ret; 1896 - 1897 1898 ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, 1898 1899 count); 1899 1900 if (ret < 0) 1900 - goto out; 1901 + return ret; 1901 1902 buf[ret] = '\0'; 1902 1903 1903 1904 pattern = sysfs_match_string(test_pattern_str, buf); 1904 - if (pattern < 0) { 1905 - ret = -EINVAL; 1906 - goto out; 1907 - } 1905 + if (pattern < 0) 1906 + return -EINVAL; 1908 1907 1909 1908 mutex_lock(&dp->lock); 1910 1909 dp->test.pattern = pattern; ··· 1906 1919 dp->test.custom) ?: ret; 1907 1920 mutex_unlock(&dp->lock); 1908 1921 1909 - out: 1910 - debugfs_file_put(dentry); 1911 1922 return ret; 1912 1923 } 1913 1924 ··· 2011 2026 static ssize_t zynqmp_dp_custom_read(struct file *file, char __user *user_buf, 2012 2027 size_t count, loff_t *ppos) 2013 2028 { 2014 - struct dentry *dentry = file->f_path.dentry; 2015 2029 struct zynqmp_dp *dp = file->private_data; 2016 2030 ssize_t ret; 2017 - 2018 - ret = debugfs_file_get(dentry); 2019 - if (unlikely(ret)) 2020 - return ret; 2021 2031 2022 2032 mutex_lock(&dp->lock); 2023 2033 ret = simple_read_from_buffer(user_buf, count, ppos, &dp->test.custom, 2024 2034 sizeof(dp->test.custom)); 2025 2035 mutex_unlock(&dp->lock); 2026 - 2027 - debugfs_file_put(dentry); 2028 2036 return ret; 2029 2037 } 2030 2038 ··· 2025 2047 const char __user *user_buf, 2026 2048 size_t count, loff_t *ppos) 2027 2049 { 2028 - struct dentry *dentry = file->f_path.dentry; 2029 2050 struct zynqmp_dp *dp = file->private_data; 2030 2051 ssize_t ret; 2031 2052 char buf[sizeof(dp->test.custom)]; 2032 2053 2033 - ret = debugfs_file_get(dentry); 2034 - if (unlikely(ret)) 2035 - return ret; 2036 - 2037 2054 ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count); 2038 2055 if (ret < 0) 2039 - goto out; 2056 + return ret; 2040 2057 2041 2058 mutex_lock(&dp->lock); 2042 2059 memcpy(dp->test.custom, buf, ret); ··· 2039 2066 ret = zynqmp_dp_set_test_pattern(dp, dp->test.pattern, 2040 2067 dp->test.custom) ?: ret; 2041 2068 mutex_unlock(&dp->lock); 2042 - 2043 - out: 2044 - debugfs_file_put(dentry); 2045 2069 return ret; 2046 2070 } 2047 2071