linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro
@ 2018-02-14 15:43 Andy Shevchenko
  2018-02-14 15:43 ` [PATCH v1 2/2] x86/platform/quark: " Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-02-14 15:43 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
  Cc: Andy Shevchenko

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

While here, replace permissions by explicit octal value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/platform/atom/punit_atom_debug.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/arch/x86/platform/atom/punit_atom_debug.c b/arch/x86/platform/atom/punit_atom_debug.c
index d49d3be81953..156b445bcf4d 100644
--- a/arch/x86/platform/atom/punit_atom_debug.c
+++ b/arch/x86/platform/atom/punit_atom_debug.c
@@ -109,18 +109,7 @@ static int punit_dev_state_show(struct seq_file *seq_file, void *unused)
 
 	return 0;
 }
-
-static int punit_dev_state_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, punit_dev_state_show, inode->i_private);
-}
-
-static const struct file_operations punit_dev_state_ops = {
-	.open		= punit_dev_state_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(punit_dev_state);
 
 static struct dentry *punit_dbg_file;
 
-- 
2.15.1

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

* [PATCH v1 2/2] x86/platform/quark: Re-use DEFINE_SHOW_ATTRIBUTE() macro
  2018-02-14 15:43 [PATCH v1 1/2] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
@ 2018-02-14 15:43 ` Andy Shevchenko
  2018-02-16  9:47   ` [tip:x86/platform] " tip-bot for Andy Shevchenko
  2018-02-16  9:10 ` [PATCH v1 1/2] x86/platform/atom: " Ingo Molnar
  2018-02-16  9:47 ` [tip:x86/platform] " tip-bot for Andy Shevchenko
  2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2018-02-14 15:43 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
  Cc: Andy Shevchenko

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

While here, replace permissions by explicit octal value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/platform/intel-quark/imr.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/arch/x86/platform/intel-quark/imr.c b/arch/x86/platform/intel-quark/imr.c
index 17d6d2296e4d..49828c2707ac 100644
--- a/arch/x86/platform/intel-quark/imr.c
+++ b/arch/x86/platform/intel-quark/imr.c
@@ -224,25 +224,7 @@ static int imr_dbgfs_state_show(struct seq_file *s, void *unused)
 	mutex_unlock(&idev->lock);
 	return ret;
 }
-
-/**
- * imr_state_open - debugfs open callback.
- *
- * @inode:	pointer to struct inode.
- * @file:	pointer to struct file.
- * @return:	result of single open.
- */
-static int imr_state_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, imr_dbgfs_state_show, inode->i_private);
-}
-
-static const struct file_operations imr_state_ops = {
-	.open		= imr_state_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(imr_dbgfs_state);
 
 /**
  * imr_debugfs_register - register debugfs hooks.
@@ -252,8 +234,8 @@ static const struct file_operations imr_state_ops = {
  */
 static int imr_debugfs_register(struct imr_device *idev)
 {
-	idev->file = debugfs_create_file("imr_state", S_IFREG | S_IRUGO, NULL,
-					 idev, &imr_state_ops);
+	idev->file = debugfs_create_file("imr_state", 0444, NULL, idev,
+					 &imr_dbgfs_state_fops);
 	return PTR_ERR_OR_ZERO(idev->file);
 }
 
-- 
2.15.1

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

* Re: [PATCH v1 1/2] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro
  2018-02-14 15:43 [PATCH v1 1/2] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
  2018-02-14 15:43 ` [PATCH v1 2/2] x86/platform/quark: " Andy Shevchenko
@ 2018-02-16  9:10 ` Ingo Molnar
  2018-02-16  9:41   ` Andy Shevchenko
  2018-02-16  9:47 ` [tip:x86/platform] " tip-bot for Andy Shevchenko
  2 siblings, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2018-02-16  9:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel


* Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> ...instead of open coding file operations followed by custom ->open()
> callbacks per each attribute.
> 
> While here, replace permissions by explicit octal value.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  arch/x86/platform/atom/punit_atom_debug.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/arch/x86/platform/atom/punit_atom_debug.c b/arch/x86/platform/atom/punit_atom_debug.c
> index d49d3be81953..156b445bcf4d 100644
> --- a/arch/x86/platform/atom/punit_atom_debug.c
> +++ b/arch/x86/platform/atom/punit_atom_debug.c
> @@ -109,18 +109,7 @@ static int punit_dev_state_show(struct seq_file *seq_file, void *unused)
>  
>  	return 0;
>  }
> -
> -static int punit_dev_state_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, punit_dev_state_show, inode->i_private);
> -}
> -
> -static const struct file_operations punit_dev_state_ops = {
> -	.open		= punit_dev_state_open,
> -	.read		= seq_read,
> -	.llseek		= seq_lseek,
> -	.release	= single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(punit_dev_state);
>  
>  static struct dentry *punit_dbg_file;

Hm, that octal value replacement does not seem to be part of this patch, only the 
next patch.

Also, the debugfs_create_file() call still uses the old &punit_dev_state_ops 
callback array.

Did a patch hunk go missing?

I've added the fixes below to the patch.

Thanks,

	Ingo

--- tip.orig/arch/x86/platform/atom/punit_atom_debug.c
+++ tip/arch/x86/platform/atom/punit_atom_debug.c
@@ -132,9 +121,9 @@ static int punit_dbgfs_register(struct p
 	if (!punit_dbg_file)
 		return -ENXIO;
 
-	dev_state = debugfs_create_file("dev_power_state", S_IFREG | S_IRUGO,
+	dev_state = debugfs_create_file("dev_power_state", 0444,
 					punit_dbg_file, punit_device,
-					&punit_dev_state_ops);
+					&punit_dev_state_fops);
 	if (!dev_state) {
 		pr_err("punit_dev_state register failed\n");
 		debugfs_remove(punit_dbg_file);

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

* Re: [PATCH v1 1/2] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro
  2018-02-16  9:10 ` [PATCH v1 1/2] x86/platform/atom: " Ingo Molnar
@ 2018-02-16  9:41   ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-02-16  9:41 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel

On Fri, 2018-02-16 at 10:10 +0100, Ingo Molnar wrote:
> * Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
> > ...instead of open coding file operations followed by custom
> > ->open()
> > callbacks per each attribute.
> > 
> > While here, replace permissions by explicit octal value.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  arch/x86/platform/atom/punit_atom_debug.c | 13 +------------
> >  1 file changed, 1 insertion(+), 12 deletions(-)
> > 
> > diff --git a/arch/x86/platform/atom/punit_atom_debug.c
> > b/arch/x86/platform/atom/punit_atom_debug.c
> > index d49d3be81953..156b445bcf4d 100644
> > --- a/arch/x86/platform/atom/punit_atom_debug.c
> > +++ b/arch/x86/platform/atom/punit_atom_debug.c
> > @@ -109,18 +109,7 @@ static int punit_dev_state_show(struct seq_file
> > *seq_file, void *unused)
> >  
> >  	return 0;
> >  }
> > -
> > -static int punit_dev_state_open(struct inode *inode, struct file
> > *file)
> > -{
> > -	return single_open(file, punit_dev_state_show, inode-
> > >i_private);
> > -}
> > -
> > -static const struct file_operations punit_dev_state_ops = {
> > -	.open		= punit_dev_state_open,
> > -	.read		= seq_read,
> > -	.llseek		= seq_lseek,
> > -	.release	= single_release,
> > -};
> > +DEFINE_SHOW_ATTRIBUTE(punit_dev_state);
> >  
> >  static struct dentry *punit_dbg_file;
> 
> Hm, that octal value replacement does not seem to be part of this
> patch, only the 
> next patch.
> 
> Also, the debugfs_create_file() call still uses the old
> &punit_dev_state_ops 
> callback array.
> 
> Did a patch hunk go missing?

Ooops, sorry.
Indeed, it happened to be half baked.

> 
> I've added the fixes below to the patch.

Thanks!

> 
> Thanks,
> 
> 	Ingo
> 
> --- tip.orig/arch/x86/platform/atom/punit_atom_debug.c
> +++ tip/arch/x86/platform/atom/punit_atom_debug.c
> @@ -132,9 +121,9 @@ static int punit_dbgfs_register(struct p
>  	if (!punit_dbg_file)
>  		return -ENXIO;
>  
> -	dev_state = debugfs_create_file("dev_power_state", S_IFREG |
> S_IRUGO,
> +	dev_state = debugfs_create_file("dev_power_state", 0444,
>  					punit_dbg_file, punit_device,
> -					&punit_dev_state_ops);
> +					&punit_dev_state_fops);
>  	if (!dev_state) {
>  		pr_err("punit_dev_state register failed\n");
>  		debugfs_remove(punit_dbg_file);

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* [tip:x86/platform] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro
  2018-02-14 15:43 [PATCH v1 1/2] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
  2018-02-14 15:43 ` [PATCH v1 2/2] x86/platform/quark: " Andy Shevchenko
  2018-02-16  9:10 ` [PATCH v1 1/2] x86/platform/atom: " Ingo Molnar
@ 2018-02-16  9:47 ` tip-bot for Andy Shevchenko
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Andy Shevchenko @ 2018-02-16  9:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, torvalds, andriy.shevchenko, linux-kernel, tglx, hpa, mingo

Commit-ID:  3130451e270960065e8de684c60b898e970c940c
Gitweb:     https://git.kernel.org/tip/3130451e270960065e8de684c60b898e970c940c
Author:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Wed, 14 Feb 2018 17:43:16 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 16 Feb 2018 10:10:14 +0100

x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro

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

While here, replace permissions by explicit octal value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180214154317.52290-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/atom/punit_atom_debug.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/arch/x86/platform/atom/punit_atom_debug.c b/arch/x86/platform/atom/punit_atom_debug.c
index d49d3be..034813d 100644
--- a/arch/x86/platform/atom/punit_atom_debug.c
+++ b/arch/x86/platform/atom/punit_atom_debug.c
@@ -109,18 +109,7 @@ static int punit_dev_state_show(struct seq_file *seq_file, void *unused)
 
 	return 0;
 }
-
-static int punit_dev_state_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, punit_dev_state_show, inode->i_private);
-}
-
-static const struct file_operations punit_dev_state_ops = {
-	.open		= punit_dev_state_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(punit_dev_state);
 
 static struct dentry *punit_dbg_file;
 
@@ -132,9 +121,9 @@ static int punit_dbgfs_register(struct punit_device *punit_device)
 	if (!punit_dbg_file)
 		return -ENXIO;
 
-	dev_state = debugfs_create_file("dev_power_state", S_IFREG | S_IRUGO,
+	dev_state = debugfs_create_file("dev_power_state", 0444,
 					punit_dbg_file, punit_device,
-					&punit_dev_state_ops);
+					&punit_dev_state_fops);
 	if (!dev_state) {
 		pr_err("punit_dev_state register failed\n");
 		debugfs_remove(punit_dbg_file);

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

* [tip:x86/platform] x86/platform/quark: Re-use DEFINE_SHOW_ATTRIBUTE() macro
  2018-02-14 15:43 ` [PATCH v1 2/2] x86/platform/quark: " Andy Shevchenko
@ 2018-02-16  9:47   ` tip-bot for Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Andy Shevchenko @ 2018-02-16  9:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, peterz, linux-kernel, hpa, torvalds, andriy.shevchenko, mingo

Commit-ID:  a66b86f0026b07b0ea7340e3690ac9fd5ac1499a
Gitweb:     https://git.kernel.org/tip/a66b86f0026b07b0ea7340e3690ac9fd5ac1499a
Author:     Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Wed, 14 Feb 2018 17:43:17 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 16 Feb 2018 10:10:14 +0100

x86/platform/quark: Re-use DEFINE_SHOW_ATTRIBUTE() macro

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

While here, replace permissions by explicit octal value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180214154317.52290-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/intel-quark/imr.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/arch/x86/platform/intel-quark/imr.c b/arch/x86/platform/intel-quark/imr.c
index 17d6d22..49828c2 100644
--- a/arch/x86/platform/intel-quark/imr.c
+++ b/arch/x86/platform/intel-quark/imr.c
@@ -224,25 +224,7 @@ static int imr_dbgfs_state_show(struct seq_file *s, void *unused)
 	mutex_unlock(&idev->lock);
 	return ret;
 }
-
-/**
- * imr_state_open - debugfs open callback.
- *
- * @inode:	pointer to struct inode.
- * @file:	pointer to struct file.
- * @return:	result of single open.
- */
-static int imr_state_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, imr_dbgfs_state_show, inode->i_private);
-}
-
-static const struct file_operations imr_state_ops = {
-	.open		= imr_state_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(imr_dbgfs_state);
 
 /**
  * imr_debugfs_register - register debugfs hooks.
@@ -252,8 +234,8 @@ static const struct file_operations imr_state_ops = {
  */
 static int imr_debugfs_register(struct imr_device *idev)
 {
-	idev->file = debugfs_create_file("imr_state", S_IFREG | S_IRUGO, NULL,
-					 idev, &imr_state_ops);
+	idev->file = debugfs_create_file("imr_state", 0444, NULL, idev,
+					 &imr_dbgfs_state_fops);
 	return PTR_ERR_OR_ZERO(idev->file);
 }
 

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

end of thread, other threads:[~2018-02-16  9:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 15:43 [PATCH v1 1/2] x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
2018-02-14 15:43 ` [PATCH v1 2/2] x86/platform/quark: " Andy Shevchenko
2018-02-16  9:47   ` [tip:x86/platform] " tip-bot for Andy Shevchenko
2018-02-16  9:10 ` [PATCH v1 1/2] x86/platform/atom: " Ingo Molnar
2018-02-16  9:41   ` Andy Shevchenko
2018-02-16  9:47 ` [tip:x86/platform] " tip-bot for Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).