All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] usb: ulpi: use DEFINE_SHOW_ATTRIBUTE to simplify ulpi_regs
  2022-09-22 14:25 [PATCH] usb: ulpi: use DEFINE_SHOW_ATTRIBUTE to simplify ulpi_regs Liu Shixin
@ 2022-09-22 14:23 ` Heikki Krogerus
  0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2022-09-22 14:23 UTC (permalink / raw)
  To: Liu Shixin; +Cc: Greg Kroah-Hartman, linux-usb

On Thu, Sep 22, 2022 at 10:25:05PM +0800, Liu Shixin wrote:
> Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.
> No functional change.
> 
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/common/ulpi.c | 20 +++-----------------
>  1 file changed, 3 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
> index 0a4f441aff8f..d7c8461976ce 100644
> --- a/drivers/usb/common/ulpi.c
> +++ b/drivers/usb/common/ulpi.c
> @@ -233,7 +233,7 @@ static int ulpi_read_id(struct ulpi *ulpi)
>  	return 0;
>  }
>  
> -static int ulpi_regs_read(struct seq_file *seq, void *data)
> +static int ulpi_regs_show(struct seq_file *seq, void *data)
>  {
>  	struct ulpi *ulpi = seq->private;
>  
> @@ -269,21 +269,7 @@ static int ulpi_regs_read(struct seq_file *seq, void *data)
>  
>  	return 0;
>  }
> -
> -static int ulpi_regs_open(struct inode *inode, struct file *f)
> -{
> -	struct ulpi *ulpi = inode->i_private;
> -
> -	return single_open(f, ulpi_regs_read, ulpi);
> -}
> -
> -static const struct file_operations ulpi_regs_ops = {
> -	.owner = THIS_MODULE,
> -	.open = ulpi_regs_open,
> -	.release = single_release,
> -	.read = seq_read,
> -	.llseek = seq_lseek
> -};
> +DEFINE_SHOW_ATTRIBUTE(ulpi_regs);
>  
>  #define ULPI_ROOT debugfs_lookup(KBUILD_MODNAME, NULL)
>  
> @@ -316,7 +302,7 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
>  	}
>  
>  	root = debugfs_create_dir(dev_name(dev), ULPI_ROOT);
> -	debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_ops);
> +	debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_fops);
>  
>  	dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n",
>  		ulpi->id.vendor, ulpi->id.product);
> -- 
> 2.25.1

-- 
heikki

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] usb: ulpi: use DEFINE_SHOW_ATTRIBUTE to simplify ulpi_regs
@ 2022-09-22 14:25 Liu Shixin
  2022-09-22 14:23 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Shixin @ 2022-09-22 14:25 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman; +Cc: linux-usb, Liu Shixin

Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.
No functional change.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 drivers/usb/common/ulpi.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index 0a4f441aff8f..d7c8461976ce 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -233,7 +233,7 @@ static int ulpi_read_id(struct ulpi *ulpi)
 	return 0;
 }
 
-static int ulpi_regs_read(struct seq_file *seq, void *data)
+static int ulpi_regs_show(struct seq_file *seq, void *data)
 {
 	struct ulpi *ulpi = seq->private;
 
@@ -269,21 +269,7 @@ static int ulpi_regs_read(struct seq_file *seq, void *data)
 
 	return 0;
 }
-
-static int ulpi_regs_open(struct inode *inode, struct file *f)
-{
-	struct ulpi *ulpi = inode->i_private;
-
-	return single_open(f, ulpi_regs_read, ulpi);
-}
-
-static const struct file_operations ulpi_regs_ops = {
-	.owner = THIS_MODULE,
-	.open = ulpi_regs_open,
-	.release = single_release,
-	.read = seq_read,
-	.llseek = seq_lseek
-};
+DEFINE_SHOW_ATTRIBUTE(ulpi_regs);
 
 #define ULPI_ROOT debugfs_lookup(KBUILD_MODNAME, NULL)
 
@@ -316,7 +302,7 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
 	}
 
 	root = debugfs_create_dir(dev_name(dev), ULPI_ROOT);
-	debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_ops);
+	debugfs_create_file("regs", 0444, root, ulpi, &ulpi_regs_fops);
 
 	dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n",
 		ulpi->id.vendor, ulpi->id.product);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-22 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-22 14:25 [PATCH] usb: ulpi: use DEFINE_SHOW_ATTRIBUTE to simplify ulpi_regs Liu Shixin
2022-09-22 14:23 ` Heikki Krogerus

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.