[PATCH] drivers: visorbus: convert to DEFINE_SHOW_ATTRIBUTE

From: Yangtao Li
Date: Sat Dec 01 2018 - 05:21:32 EST


Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yangtao Li <tiny.windzz@xxxxxxxxx>
---
drivers/visorbus/visorbus_main.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/visorbus/visorbus_main.c b/drivers/visorbus/visorbus_main.c
index 0b2434cc4ecd..8f742dc9e62c 100644
--- a/drivers/visorbus/visorbus_main.c
+++ b/drivers/visorbus/visorbus_main.c
@@ -436,7 +436,7 @@ static void vbuschannel_print_devinfo(struct visor_vbus_deviceinfo *devinfo,
devinfo->infostrs);
}

-static int bus_info_debugfs_show(struct seq_file *seq, void *v)
+static int bus_info_show(struct seq_file *seq, void *v)
{
int i = 0;
unsigned long off;
@@ -471,18 +471,7 @@ static int bus_info_debugfs_show(struct seq_file *seq, void *v)
return 0;
}

-static int bus_info_debugfs_open(struct inode *inode, struct file *file)
-{
- return single_open(file, bus_info_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations bus_info_debugfs_fops = {
- .owner = THIS_MODULE,
- .open = bus_info_debugfs_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(bus_info);

static void dev_periodic_work(struct timer_list *t)
{
@@ -1022,7 +1011,7 @@ int visorbus_create_instance(struct visor_device *dev)
visorbus_debugfs_dir);
dev->debugfs_bus_info = debugfs_create_file("client_bus_info", 0440,
dev->debugfs_dir, dev,
- &bus_info_debugfs_fops);
+ &bus_info_fops);
dev_set_drvdata(&dev->device, dev);
err = get_vbus_header_info(dev->visorchannel, &dev->device, hdr_info);
if (err < 0)
--
2.17.0