Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
Signed-off-by: Qinglang Miao <[email protected]>
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.
drivers/mfd/ab3100-otp.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/drivers/mfd/ab3100-otp.c b/drivers/mfd/ab3100-otp.c
index c393102e3..e5d294805 100644
--- a/drivers/mfd/ab3100-otp.c
+++ b/drivers/mfd/ab3100-otp.c
@@ -96,7 +96,7 @@ static int __init ab3100_otp_read(struct ab3100_otp *otp)
* the contents of the OTP.
*/
#ifdef CONFIG_DEBUG_FS
-static int ab3100_show_otp(struct seq_file *s, void *v)
+static int ab3100_otp_show(struct seq_file *s, void *v)
{
struct ab3100_otp *otp = s->private;
@@ -110,23 +110,13 @@ static int ab3100_show_otp(struct seq_file *s, void *v)
return 0;
}
-static int ab3100_otp_open(struct inode *inode, struct file *file)
-{
- return single_open(file, ab3100_show_otp, inode->i_private);
-}
-
-static const struct file_operations ab3100_otp_operations = {
- .open = ab3100_otp_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(ab3100_otp);
static void __init ab3100_otp_init_debugfs(struct device *dev,
struct ab3100_otp *otp)
{
otp->debugfs = debugfs_create_file("ab3100_otp", S_IFREG | S_IRUGO,
- NULL, otp, &ab3100_otp_operations);
+ NULL, otp, &ab3100_otp_fops);
}
static void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp)
--
2.23.0
On Sat, Sep 19, 2020 at 4:18 AM Qinglang Miao <[email protected]> wrote:
> Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
>
> Signed-off-by: Qinglang Miao <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Yours,
Linus Walleij