All of lore.kernel.org
 help / color / mirror / Atom feed
* [v1,04/14] USB: gadget: bcm63xx: Re-use DEFINE_SHOW_ATTRIBUTE() macro
@ 2018-02-14 16:08 Andy Shevchenko
  0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2018-02-14 16:08 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb, Greg Kroah-Hartman
  Cc: Andy Shevchenko, Kevin Cernekee, Florian Fainelli,
	bcm-kernel-feedback-list

...instead of open coding file operations followed by custom ->open()
callbacks per each attribute.

Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/gadget/udc/bcm63xx_udc.c | 33 ++++-----------------------------
 1 file changed, 4 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c
index 465ccd1104de..3a8df8601074 100644
--- a/drivers/usb/gadget/udc/bcm63xx_udc.c
+++ b/drivers/usb/gadget/udc/bcm63xx_udc.c
@@ -2158,6 +2158,7 @@ static int bcm63xx_usbd_dbg_show(struct seq_file *s, void *p)
 
 	return 0;
 }
+DEFINE_SHOW_ATTRIBUTE(bcm63xx_usbd_dbg);
 
 /*
  * bcm63xx_iudma_dbg_show - Show IUDMA status and descriptors.
@@ -2238,33 +2239,7 @@ static int bcm63xx_iudma_dbg_show(struct seq_file *s, void *p)
 
 	return 0;
 }
-
-static int bcm63xx_usbd_dbg_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, bcm63xx_usbd_dbg_show, inode->i_private);
-}
-
-static int bcm63xx_iudma_dbg_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, bcm63xx_iudma_dbg_show, inode->i_private);
-}
-
-static const struct file_operations usbd_dbg_fops = {
-	.owner		= THIS_MODULE,
-	.open		= bcm63xx_usbd_dbg_open,
-	.llseek		= seq_lseek,
-	.read		= seq_read,
-	.release	= single_release,
-};
-
-static const struct file_operations iudma_dbg_fops = {
-	.owner		= THIS_MODULE,
-	.open		= bcm63xx_iudma_dbg_open,
-	.llseek		= seq_lseek,
-	.read		= seq_read,
-	.release	= single_release,
-};
-
+DEFINE_SHOW_ATTRIBUTE(bcm63xx_iudma_dbg);
 
 /**
  * bcm63xx_udc_init_debugfs - Create debugfs entries.
@@ -2282,11 +2257,11 @@ static void bcm63xx_udc_init_debugfs(struct bcm63xx_udc *udc)
 		goto err_root;
 
 	usbd = debugfs_create_file("usbd", 0400, root, udc,
-			&usbd_dbg_fops);
+			&bcm63xx_usbd_dbg_fops);
 	if (!usbd)
 		goto err_usbd;
 	iudma = debugfs_create_file("iudma", 0400, root, udc,
-			&iudma_dbg_fops);
+			&bcm63xx_iudma_dbg_fops);
 	if (!iudma)
 		goto err_iudma;
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-14 16:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 16:08 [v1,04/14] USB: gadget: bcm63xx: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.