All of lore.kernel.org
 help / color / mirror / Atom feed
* [v1,13/14] USB: typec: Re-use DEFINE_SHOW_ATTRIBUTE() macro
@ 2018-02-14 16:38 Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2018-02-14 16:38 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Felipe Balbi, linux-usb, Greg Kroah-Hartman, Heikki Krogerus

On Wed, Feb 14, 2018 at 06:08:29PM +0200, Andy Shevchenko wrote:
> ...instead of open coding file operations followed by custom ->open()
> callbacks per each attribute.
> 
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/usb/typec/fusb302/fusb302.c | 17 +++--------------
>  drivers/usb/typec/tcpm.c            | 17 +++--------------
>  2 files changed, 6 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
> index 9ce4756adad6..da179aaf789e 100644
> --- a/drivers/usb/typec/fusb302/fusb302.c
> +++ b/drivers/usb/typec/fusb302/fusb302.c
> @@ -199,7 +199,7 @@ static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...)
>  	va_end(args);
>  }
>  
> -static int fusb302_seq_show(struct seq_file *s, void *v)
> +static int fusb302_debug_show(struct seq_file *s, void *v)
>  {
>  	struct fusb302_chip *chip = (struct fusb302_chip *)s->private;
>  	int tail;
> @@ -216,18 +216,7 @@ static int fusb302_seq_show(struct seq_file *s, void *v)
>  
>  	return 0;
>  }
> -
> -static int fusb302_debug_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, fusb302_seq_show, inode->i_private);
> -}
> -
> -static const struct file_operations fusb302_debug_operations = {
> -	.open		= fusb302_debug_open,
> -	.llseek		= seq_lseek,
> -	.read		= seq_read,
> -	.release	= single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(fusb302_debug);
>  
>  static struct dentry *rootdir;
>  
> @@ -242,7 +231,7 @@ static int fusb302_debugfs_init(struct fusb302_chip *chip)
>  
>  	chip->dentry = debugfs_create_file(dev_name(chip->dev),
>  					   S_IFREG | 0444, rootdir,
> -					   chip, &fusb302_debug_operations);
> +					   chip, &fusb302_debug_fops);
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index f4d563ee7690..a163ba55b061 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -506,7 +506,7 @@ static void tcpm_log_source_caps(struct tcpm_port *port)
>  	}
>  }
>  
> -static int tcpm_seq_show(struct seq_file *s, void *v)
> +static int tcpm_debug_show(struct seq_file *s, void *v)
>  {
>  	struct tcpm_port *port = (struct tcpm_port *)s->private;
>  	int tail;
> @@ -523,18 +523,7 @@ static int tcpm_seq_show(struct seq_file *s, void *v)
>  
>  	return 0;
>  }
> -
> -static int tcpm_debug_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, tcpm_seq_show, inode->i_private);
> -}
> -
> -static const struct file_operations tcpm_debug_operations = {
> -	.open		= tcpm_debug_open,
> -	.llseek		= seq_lseek,
> -	.read		= seq_read,
> -	.release	= single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(tcpm_debug);
>  
>  static struct dentry *rootdir;
>  
> @@ -550,7 +539,7 @@ static int tcpm_debugfs_init(struct tcpm_port *port)
>  
>  	port->dentry = debugfs_create_file(dev_name(port->dev),
>  					   S_IFREG | 0444, rootdir,
> -					   port, &tcpm_debug_operations);
> +					   port, &tcpm_debug_fops);
>  
>  	return 0;
>  }
> -- 
> 2.15.1
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [v1,13/14] USB: typec: Re-use DEFINE_SHOW_ATTRIBUTE() macro
@ 2018-02-15 10:19 Heikki Krogerus
  0 siblings, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2018-02-15 10:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Felipe Balbi, linux-usb, Greg Kroah-Hartman, Guenter Roeck

On Wed, Feb 14, 2018 at 06:08:29PM +0200, Andy Shevchenko wrote:
> ...instead of open coding file operations followed by custom ->open()
> callbacks per each attribute.
> 
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

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

> ---
>  drivers/usb/typec/fusb302/fusb302.c | 17 +++--------------
>  drivers/usb/typec/tcpm.c            | 17 +++--------------
>  2 files changed, 6 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
> index 9ce4756adad6..da179aaf789e 100644
> --- a/drivers/usb/typec/fusb302/fusb302.c
> +++ b/drivers/usb/typec/fusb302/fusb302.c
> @@ -199,7 +199,7 @@ static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...)
>  	va_end(args);
>  }
>  
> -static int fusb302_seq_show(struct seq_file *s, void *v)
> +static int fusb302_debug_show(struct seq_file *s, void *v)
>  {
>  	struct fusb302_chip *chip = (struct fusb302_chip *)s->private;
>  	int tail;
> @@ -216,18 +216,7 @@ static int fusb302_seq_show(struct seq_file *s, void *v)
>  
>  	return 0;
>  }
> -
> -static int fusb302_debug_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, fusb302_seq_show, inode->i_private);
> -}
> -
> -static const struct file_operations fusb302_debug_operations = {
> -	.open		= fusb302_debug_open,
> -	.llseek		= seq_lseek,
> -	.read		= seq_read,
> -	.release	= single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(fusb302_debug);
>  
>  static struct dentry *rootdir;
>  
> @@ -242,7 +231,7 @@ static int fusb302_debugfs_init(struct fusb302_chip *chip)
>  
>  	chip->dentry = debugfs_create_file(dev_name(chip->dev),
>  					   S_IFREG | 0444, rootdir,
> -					   chip, &fusb302_debug_operations);
> +					   chip, &fusb302_debug_fops);
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index f4d563ee7690..a163ba55b061 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -506,7 +506,7 @@ static void tcpm_log_source_caps(struct tcpm_port *port)
>  	}
>  }
>  
> -static int tcpm_seq_show(struct seq_file *s, void *v)
> +static int tcpm_debug_show(struct seq_file *s, void *v)
>  {
>  	struct tcpm_port *port = (struct tcpm_port *)s->private;
>  	int tail;
> @@ -523,18 +523,7 @@ static int tcpm_seq_show(struct seq_file *s, void *v)
>  
>  	return 0;
>  }
> -
> -static int tcpm_debug_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, tcpm_seq_show, inode->i_private);
> -}
> -
> -static const struct file_operations tcpm_debug_operations = {
> -	.open		= tcpm_debug_open,
> -	.llseek		= seq_lseek,
> -	.read		= seq_read,
> -	.release	= single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(tcpm_debug);
>  
>  static struct dentry *rootdir;
>  
> @@ -550,7 +539,7 @@ static int tcpm_debugfs_init(struct tcpm_port *port)
>  
>  	port->dentry = debugfs_create_file(dev_name(port->dev),
>  					   S_IFREG | 0444, rootdir,
> -					   port, &tcpm_debug_operations);
> +					   port, &tcpm_debug_fops);
>  
>  	return 0;
>  }
> -- 
> 2.15.1

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

* [v1,13/14] USB: typec: Re-use DEFINE_SHOW_ATTRIBUTE() macro
@ 2018-02-14 16:08 Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2018-02-14 16:08 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb, Greg Kroah-Hartman
  Cc: Andy Shevchenko, Heikki Krogerus, Guenter Roeck

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

Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/typec/fusb302/fusb302.c | 17 +++--------------
 drivers/usb/typec/tcpm.c            | 17 +++--------------
 2 files changed, 6 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
index 9ce4756adad6..da179aaf789e 100644
--- a/drivers/usb/typec/fusb302/fusb302.c
+++ b/drivers/usb/typec/fusb302/fusb302.c
@@ -199,7 +199,7 @@ static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...)
 	va_end(args);
 }
 
-static int fusb302_seq_show(struct seq_file *s, void *v)
+static int fusb302_debug_show(struct seq_file *s, void *v)
 {
 	struct fusb302_chip *chip = (struct fusb302_chip *)s->private;
 	int tail;
@@ -216,18 +216,7 @@ static int fusb302_seq_show(struct seq_file *s, void *v)
 
 	return 0;
 }
-
-static int fusb302_debug_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, fusb302_seq_show, inode->i_private);
-}
-
-static const struct file_operations fusb302_debug_operations = {
-	.open		= fusb302_debug_open,
-	.llseek		= seq_lseek,
-	.read		= seq_read,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(fusb302_debug);
 
 static struct dentry *rootdir;
 
@@ -242,7 +231,7 @@ static int fusb302_debugfs_init(struct fusb302_chip *chip)
 
 	chip->dentry = debugfs_create_file(dev_name(chip->dev),
 					   S_IFREG | 0444, rootdir,
-					   chip, &fusb302_debug_operations);
+					   chip, &fusb302_debug_fops);
 
 	return 0;
 }
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index f4d563ee7690..a163ba55b061 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -506,7 +506,7 @@ static void tcpm_log_source_caps(struct tcpm_port *port)
 	}
 }
 
-static int tcpm_seq_show(struct seq_file *s, void *v)
+static int tcpm_debug_show(struct seq_file *s, void *v)
 {
 	struct tcpm_port *port = (struct tcpm_port *)s->private;
 	int tail;
@@ -523,18 +523,7 @@ static int tcpm_seq_show(struct seq_file *s, void *v)
 
 	return 0;
 }
-
-static int tcpm_debug_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, tcpm_seq_show, inode->i_private);
-}
-
-static const struct file_operations tcpm_debug_operations = {
-	.open		= tcpm_debug_open,
-	.llseek		= seq_lseek,
-	.read		= seq_read,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(tcpm_debug);
 
 static struct dentry *rootdir;
 
@@ -550,7 +539,7 @@ static int tcpm_debugfs_init(struct tcpm_port *port)
 
 	port->dentry = debugfs_create_file(dev_name(port->dev),
 					   S_IFREG | 0444, rootdir,
-					   port, &tcpm_debug_operations);
+					   port, &tcpm_debug_fops);
 
 	return 0;
 }

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

end of thread, other threads:[~2018-02-15 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 16:38 [v1,13/14] USB: typec: Re-use DEFINE_SHOW_ATTRIBUTE() macro Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2018-02-15 10:19 Heikki Krogerus
2018-02-14 16:08 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.