nbd: Convert to DEFINE_SHOW_ATTRIBUTE
Subsystems (2)
PATCH 1/1 nbd: Convert to DEFINE_SHOW_ATTRIBUTE
From: Liao Pingfang <[email protected]>
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
Signed-off-by Liao Pingfang <[email protected]>
--- drivers/block/nbd.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-)
drivers/block/nbd.c +4 -24
@@ -1529,17 +1529,7 @@ static int nbd_dbg_tasks_show(struct seq_file *s, void *unused)return 0 ; } -static int nbd_dbg_tasks_open (struct inode *inode,struct file *file) -{ -return single_open (file, nbd_dbg_tasks_show, inode->i_private); -} - -static const struct file_operations nbd_dbg_tasks_ops = { - .open = nbd_dbg_tasks_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (nbd_dbg_tasks);static int nbd_dbg_flags_show (struct seq_file *s,void *unused) {
@@ -1564,17 +1554,7 @@ static int nbd_dbg_flags_show(struct seq_file *s, void *unused)return 0 ; } -static int nbd_dbg_flags_open (struct inode *inode,struct file *file) -{ -return single_open (file, nbd_dbg_flags_show, inode->i_private); -} - -static const struct file_operations nbd_dbg_flags_ops = { - .open = nbd_dbg_flags_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE (nbd_dbg_flags);static int nbd_dev_dbg_init (struct nbd_device *nbd) {
@@ -1592,11 +1572,11 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd) } config->dbg_dir = dir; -debugfs_create_file ("tasks" ,0444 , dir, nbd, &nbd_dbg_tasks_ops); +debugfs_create_file ("tasks" ,0444 , dir, nbd, &nbd_dbg_tasks_fops);debugfs_create_u64 ("size_bytes" ,0444 , dir, &config->bytesize);debugfs_create_u32 ("timeout" ,0444 , dir, &nbd->tag_set.timeout);debugfs_create_u64 ("blocksize" ,0444 , dir, &config->blksize); -debugfs_create_file ("flags" ,0444 , dir, nbd, &nbd_dbg_flags_ops); +debugfs_create_file ("flags" ,0444 , dir, nbd, &nbd_dbg_flags_fops);return 0 ; }
Signature · 1 line
1.8.3.1
Quoted 5 lines · On 2/6/21 2:10 AM, [email protected] wrote:
From: Liao Pingfang <[email protected]>
Use
DEFINE_SHOW_ATTRIBUTEmacro to simplify the code.Signed-off-by Liao Pingfang <[email protected]>
Reviewed-by Josef Bacik <[email protected]>
Thanks,
Josef
Quoted 3 lines · On 2/6/21 12:10 AM, [email protected] wrote:
From: Liao Pingfang <[email protected]>
Use
DEFINE_SHOW_ATTRIBUTEmacro to simplify the code.
Applied, thanks.
Signature · 1 line
Jens Axboe