diff options
author | Liao Pingfang <winndows@163.com> | 2021-02-06 15:10:55 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-02-10 09:38:39 -0700 |
commit | a2d52a6c1b6764031b6cac7cc156530cbb38248c (patch) | |
tree | 7c33049f369d3c360e4e289a50b30dc1293b41fd /drivers | |
parent | 6751c1e3cff3aa763c760c08862627069a37b50e (diff) | |
download | linux-stable-a2d52a6c1b6764031b6cac7cc156530cbb38248c.tar.gz linux-stable-a2d52a6c1b6764031b6cac7cc156530cbb38248c.tar.bz2 linux-stable-a2d52a6c1b6764031b6cac7cc156530cbb38248c.zip |
nbd: Convert to DEFINE_SHOW_ATTRIBUTE
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
Signed-off-by: Liao Pingfang <winndows@163.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/nbd.c | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 6727358e147d..b076a0a53fb1 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1521,17 +1521,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) { @@ -1556,17 +1546,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) { @@ -1584,11 +1564,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; } |