block: aoe: use DEFINE_SHOW_ATTRIBUTE to simplify aoe_debugfs
authorLiu Shixin <liushixin2@huawei.com>
Thu, 15 Sep 2022 02:34:24 +0000 (10:34 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 22 Sep 2022 01:49:24 +0000 (19:49 -0600)
Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Link: https://lore.kernel.org/r/20220915023424.3198940-1-liushixin2@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/aoe/aoeblk.c

index 12b3ca8f6f4a91277c76f9f357e291b78987c5b6..128722cf6c3cad69dede6a2b3f3748f0ed5e00b8 100644 (file)
@@ -108,7 +108,7 @@ static ssize_t aoedisk_show_payload(struct device *dev,
        return sysfs_emit(page, "%lu\n", d->maxbcnt);
 }
 
-static int aoedisk_debugfs_show(struct seq_file *s, void *ignored)
+static int aoe_debugfs_show(struct seq_file *s, void *ignored)
 {
        struct aoedev *d;
        struct aoetgt **t, **te;
@@ -151,11 +151,7 @@ static int aoedisk_debugfs_show(struct seq_file *s, void *ignored)
 
        return 0;
 }
-
-static int aoe_debugfs_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, aoedisk_debugfs_show, inode->i_private);
-}
+DEFINE_SHOW_ATTRIBUTE(aoe_debugfs);
 
 static DEVICE_ATTR(state, 0444, aoedisk_show_state, NULL);
 static DEVICE_ATTR(mac, 0444, aoedisk_show_mac, NULL);
@@ -184,13 +180,6 @@ static const struct attribute_group *aoe_attr_groups[] = {
        NULL,
 };
 
-static const struct file_operations aoe_debugfs_fops = {
-       .open = aoe_debugfs_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
-
 static void
 aoedisk_add_debugfs(struct aoedev *d)
 {