diff mbox series

[v2,4/5] usb: dwc3: debugfs: Introduce DEFINE_SHOW_STORE_ATTRIBUTE

Message ID 1604046722-15531-5-git-send-email-luojiaxing@huawei.com (mailing list archive)
State Superseded
Headers show
Series Introduce a new helper marco DEFINE_SHOW_STORE_ATTRIBUTE at seq_file.c | expand

Commit Message

luojiaxing Oct. 30, 2020, 8:32 a.m. UTC
Seq instroduce a new helper marco DEFINE_SHOW_STORE_ATTRIBUTE for
Read-Write file, So we apply it at dwc3 debugfs to reduce some duplicate
code.

Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
---
 drivers/usb/dwc3/debugfs.c | 52 ++++------------------------------------------
 1 file changed, 4 insertions(+), 48 deletions(-)

Comments

Felipe Balbi Oct. 30, 2020, 8:59 a.m. UTC | #1
Luo Jiaxing <luojiaxing@huawei.com> writes:

> Seq instroduce a new helper marco DEFINE_SHOW_STORE_ATTRIBUTE for
      ^^^^^^^^^^              ^^^^^
      introduce               macro

> Read-Write file, So we apply it at dwc3 debugfs to reduce some duplicate
                   ^^                                            ^^^^^^^^^
                   so                                            duplicated

> code.

to be fair, your commit is doing more than what it claims. Maybe update
commit log with a "while at that, also use DEFINE_SHOW_ATTRIBUTE() where
possible".

> Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>

other than that, this looks okay. Since it depends on the definition of
DEFINE_SHOW_STORE_ATTRIBUTE:

Acked-by: Felipe Balbi <balbi@kernel.org>
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index 5da4f60..2b5de8d 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -348,11 +348,6 @@  static int dwc3_lsp_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static int dwc3_lsp_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, dwc3_lsp_show, inode->i_private);
-}
-
 static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf,
 			      size_t count, loff_t *ppos)
 {
@@ -377,13 +372,7 @@  static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf,
 	return count;
 }
 
-static const struct file_operations dwc3_lsp_fops = {
-	.open			= dwc3_lsp_open,
-	.write			= dwc3_lsp_write,
-	.read			= seq_read,
-	.llseek			= seq_lseek,
-	.release		= single_release,
-};
+DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_lsp);
 
 static int dwc3_mode_show(struct seq_file *s, void *unused)
 {
@@ -412,11 +401,6 @@  static int dwc3_mode_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static int dwc3_mode_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, dwc3_mode_show, inode->i_private);
-}
-
 static ssize_t dwc3_mode_write(struct file *file,
 		const char __user *ubuf, size_t count, loff_t *ppos)
 {
@@ -445,13 +429,7 @@  static ssize_t dwc3_mode_write(struct file *file,
 	return count;
 }
 
-static const struct file_operations dwc3_mode_fops = {
-	.open			= dwc3_mode_open,
-	.write			= dwc3_mode_write,
-	.read			= seq_read,
-	.llseek			= seq_lseek,
-	.release		= single_release,
-};
+DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_mode);
 
 static int dwc3_testmode_show(struct seq_file *s, void *unused)
 {
@@ -491,11 +469,6 @@  static int dwc3_testmode_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static int dwc3_testmode_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, dwc3_testmode_show, inode->i_private);
-}
-
 static ssize_t dwc3_testmode_write(struct file *file,
 		const char __user *ubuf, size_t count, loff_t *ppos)
 {
@@ -528,13 +501,7 @@  static ssize_t dwc3_testmode_write(struct file *file,
 	return count;
 }
 
-static const struct file_operations dwc3_testmode_fops = {
-	.open			= dwc3_testmode_open,
-	.write			= dwc3_testmode_write,
-	.read			= seq_read,
-	.llseek			= seq_lseek,
-	.release		= single_release,
-};
+DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_testmode);
 
 static int dwc3_link_state_show(struct seq_file *s, void *unused)
 {
@@ -564,11 +531,6 @@  static int dwc3_link_state_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static int dwc3_link_state_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, dwc3_link_state_show, inode->i_private);
-}
-
 static ssize_t dwc3_link_state_write(struct file *file,
 		const char __user *ubuf, size_t count, loff_t *ppos)
 {
@@ -620,13 +582,7 @@  static ssize_t dwc3_link_state_write(struct file *file,
 	return count;
 }
 
-static const struct file_operations dwc3_link_state_fops = {
-	.open			= dwc3_link_state_open,
-	.write			= dwc3_link_state_write,
-	.read			= seq_read,
-	.llseek			= seq_lseek,
-	.release		= single_release,
-};
+DEFINE_SHOW_STORE_ATTRIBUTE(dwc3_link_state);
 
 struct dwc3_ep_file_map {
 	const char name[25];