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.

hfi1: get rid of redundant debugfs_file_{get,put}()

All files in question are created via debugfs_create_file(), so
exclusion with removals is provided by debugfs wrappers; as the matter
of fact, hfi1-private wrappers had been redundant at least since 2017...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250702211508.GB3406663@ZenIV
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Al Viro and committed by
Greg Kroah-Hartman
2b4b80cf 327a206c

+2 -44
-28
drivers/infiniband/hw/hfi1/debugfs.c
··· 22 22 23 23 static struct dentry *hfi1_dbg_root; 24 24 25 - /* wrappers to enforce srcu in seq file */ 26 - ssize_t hfi1_seq_read(struct file *file, char __user *buf, size_t size, 27 - loff_t *ppos) 28 - { 29 - struct dentry *d = file->f_path.dentry; 30 - ssize_t r; 31 - 32 - r = debugfs_file_get(d); 33 - if (unlikely(r)) 34 - return r; 35 - r = seq_read(file, buf, size, ppos); 36 - debugfs_file_put(d); 37 - return r; 38 - } 39 - 40 - loff_t hfi1_seq_lseek(struct file *file, loff_t offset, int whence) 41 - { 42 - struct dentry *d = file->f_path.dentry; 43 - loff_t r; 44 - 45 - r = debugfs_file_get(d); 46 - if (unlikely(r)) 47 - return r; 48 - r = seq_lseek(file, offset, whence); 49 - debugfs_file_put(d); 50 - return r; 51 - } 52 - 53 25 #define private2dd(file) (file_inode(file)->i_private) 54 26 #define private2ppd(file) (file_inode(file)->i_private) 55 27
+2 -7
drivers/infiniband/hw/hfi1/debugfs.h
··· 33 33 static const struct file_operations _##name##_file_ops = { \ 34 34 .owner = THIS_MODULE, \ 35 35 .open = _##name##_open, \ 36 - .read = hfi1_seq_read, \ 37 - .llseek = hfi1_seq_lseek, \ 36 + .read = seq_read, \ 37 + .llseek = seq_lseek, \ 38 38 .release = seq_release \ 39 39 } 40 - 41 - 42 - ssize_t hfi1_seq_read(struct file *file, char __user *buf, size_t size, 43 - loff_t *ppos); 44 - loff_t hfi1_seq_lseek(struct file *file, loff_t offset, int whence); 45 40 46 41 #ifdef CONFIG_DEBUG_FS 47 42 void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd);
-9
drivers/infiniband/hw/hfi1/fault.c
··· 104 104 goto free_data; 105 105 } 106 106 107 - ret = debugfs_file_get(file->f_path.dentry); 108 - if (unlikely(ret)) 109 - goto free_data; 110 107 ptr = data; 111 108 token = ptr; 112 109 for (ptr = data; *ptr; ptr = end + 1, token = ptr) { ··· 151 154 } 152 155 ret = len; 153 156 154 - debugfs_file_put(file->f_path.dentry); 155 157 free_data: 156 158 kfree(data); 157 159 return ret; ··· 169 173 data = kcalloc(datalen, sizeof(*data), GFP_KERNEL); 170 174 if (!data) 171 175 return -ENOMEM; 172 - ret = debugfs_file_get(file->f_path.dentry); 173 - if (unlikely(ret)) 174 - goto free_data; 175 176 bit = find_first_bit(fault->opcodes, bitsize); 176 177 while (bit < bitsize) { 177 178 zero = find_next_zero_bit(fault->opcodes, bitsize, bit); ··· 182 189 bit); 183 190 bit = find_next_bit(fault->opcodes, bitsize, zero); 184 191 } 185 - debugfs_file_put(file->f_path.dentry); 186 192 data[size - 1] = '\n'; 187 193 data[size] = '\0'; 188 194 ret = simple_read_from_buffer(buf, len, pos, data, size); 189 - free_data: 190 195 kfree(data); 191 196 return ret; 192 197 }