linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops()
@ 2018-12-15  8:45 Yangtao Li
  2018-12-17  8:19 ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Yangtao Li @ 2018-12-15  8:45 UTC (permalink / raw)
  To: rjw, khilman, ulf.hansson, len.brown, pavel, gregkh
  Cc: linux-pm, linux-kernel, Yangtao Li

We already have the DEFINE_SHOW_ATTRIBUTE, There is no need to define
such a macro, so remove define_genpd_open_function and
define_genpd_debugfs_fops.

Convert them to DEFINE_SHOW_ATTRIBUTE.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/base/power/domain.c | 71 +++++++++++++------------------------
 1 file changed, 24 insertions(+), 47 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 7f38a92b444a..10a61d6147d0 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2671,7 +2671,7 @@ static int genpd_summary_one(struct seq_file *s,
 	return 0;
 }
 
-static int genpd_summary_show(struct seq_file *s, void *data)
+static int summary_show(struct seq_file *s, void *data)
 {
 	struct generic_pm_domain *genpd;
 	int ret = 0;
@@ -2694,7 +2694,7 @@ static int genpd_summary_show(struct seq_file *s, void *data)
 	return ret;
 }
 
-static int genpd_status_show(struct seq_file *s, void *data)
+static int status_show(struct seq_file *s, void *data)
 {
 	static const char * const status_lookup[] = {
 		[GPD_STATE_ACTIVE] = "on",
@@ -2721,7 +2721,7 @@ static int genpd_status_show(struct seq_file *s, void *data)
 	return ret;
 }
 
-static int genpd_sub_domains_show(struct seq_file *s, void *data)
+static int sub_domains_show(struct seq_file *s, void *data)
 {
 	struct generic_pm_domain *genpd = s->private;
 	struct gpd_link *link;
@@ -2738,7 +2738,7 @@ static int genpd_sub_domains_show(struct seq_file *s, void *data)
 	return ret;
 }
 
-static int genpd_idle_states_show(struct seq_file *s, void *data)
+static int idle_states_show(struct seq_file *s, void *data)
 {
 	struct generic_pm_domain *genpd = s->private;
 	unsigned int i;
@@ -2767,7 +2767,7 @@ static int genpd_idle_states_show(struct seq_file *s, void *data)
 	return ret;
 }
 
-static int genpd_active_time_show(struct seq_file *s, void *data)
+static int active_time_show(struct seq_file *s, void *data)
 {
 	struct generic_pm_domain *genpd = s->private;
 	ktime_t delta = 0;
@@ -2787,7 +2787,7 @@ static int genpd_active_time_show(struct seq_file *s, void *data)
 	return ret;
 }
 
-static int genpd_total_idle_time_show(struct seq_file *s, void *data)
+static int total_idle_time_show(struct seq_file *s, void *data)
 {
 	struct generic_pm_domain *genpd = s->private;
 	ktime_t delta = 0, total = 0;
@@ -2815,7 +2815,7 @@ static int genpd_total_idle_time_show(struct seq_file *s, void *data)
 }
 
 
-static int genpd_devices_show(struct seq_file *s, void *data)
+static int devices_show(struct seq_file *s, void *data)
 {
 	struct generic_pm_domain *genpd = s->private;
 	struct pm_domain_data *pm_data;
@@ -2841,7 +2841,7 @@ static int genpd_devices_show(struct seq_file *s, void *data)
 	return ret;
 }
 
-static int genpd_perf_state_show(struct seq_file *s, void *data)
+static int perf_state_show(struct seq_file *s, void *data)
 {
 	struct generic_pm_domain *genpd = s->private;
 
@@ -2854,37 +2854,14 @@ static int genpd_perf_state_show(struct seq_file *s, void *data)
 	return 0;
 }
 
-#define define_genpd_open_function(name) \
-static int genpd_##name##_open(struct inode *inode, struct file *file) \
-{ \
-	return single_open(file, genpd_##name##_show, inode->i_private); \
-}
-
-define_genpd_open_function(summary);
-define_genpd_open_function(status);
-define_genpd_open_function(sub_domains);
-define_genpd_open_function(idle_states);
-define_genpd_open_function(active_time);
-define_genpd_open_function(total_idle_time);
-define_genpd_open_function(devices);
-define_genpd_open_function(perf_state);
-
-#define define_genpd_debugfs_fops(name) \
-static const struct file_operations genpd_##name##_fops = { \
-	.open = genpd_##name##_open, \
-	.read = seq_read, \
-	.llseek = seq_lseek, \
-	.release = single_release, \
-}
-
-define_genpd_debugfs_fops(summary);
-define_genpd_debugfs_fops(status);
-define_genpd_debugfs_fops(sub_domains);
-define_genpd_debugfs_fops(idle_states);
-define_genpd_debugfs_fops(active_time);
-define_genpd_debugfs_fops(total_idle_time);
-define_genpd_debugfs_fops(devices);
-define_genpd_debugfs_fops(perf_state);
+DEFINE_SHOW_ATTRIBUTE(summary);
+DEFINE_SHOW_ATTRIBUTE(status);
+DEFINE_SHOW_ATTRIBUTE(sub_domains);
+DEFINE_SHOW_ATTRIBUTE(idle_states);
+DEFINE_SHOW_ATTRIBUTE(active_time);
+DEFINE_SHOW_ATTRIBUTE(total_idle_time);
+DEFINE_SHOW_ATTRIBUTE(devices);
+DEFINE_SHOW_ATTRIBUTE(perf_state);
 
 static int __init genpd_debug_init(void)
 {
@@ -2897,7 +2874,7 @@ static int __init genpd_debug_init(void)
 		return -ENOMEM;
 
 	d = debugfs_create_file("pm_genpd_summary", S_IRUGO,
-			genpd_debugfs_dir, NULL, &genpd_summary_fops);
+			genpd_debugfs_dir, NULL, &summary_fops);
 	if (!d)
 		return -ENOMEM;
 
@@ -2907,20 +2884,20 @@ static int __init genpd_debug_init(void)
 			return -ENOMEM;
 
 		debugfs_create_file("current_state", 0444,
-				d, genpd, &genpd_status_fops);
+				d, genpd, &status_fops);
 		debugfs_create_file("sub_domains", 0444,
-				d, genpd, &genpd_sub_domains_fops);
+				d, genpd, &sub_domains_fops);
 		debugfs_create_file("idle_states", 0444,
-				d, genpd, &genpd_idle_states_fops);
+				d, genpd, &idle_states_fops);
 		debugfs_create_file("active_time", 0444,
-				d, genpd, &genpd_active_time_fops);
+				d, genpd, &active_time_fops);
 		debugfs_create_file("total_idle_time", 0444,
-				d, genpd, &genpd_total_idle_time_fops);
+				d, genpd, &total_idle_time_fops);
 		debugfs_create_file("devices", 0444,
-				d, genpd, &genpd_devices_fops);
+				d, genpd, &devices_fops);
 		if (genpd->set_performance_state)
 			debugfs_create_file("perf_state", 0444,
-					    d, genpd, &genpd_perf_state_fops);
+					    d, genpd, &perf_state_fops);
 	}
 
 	return 0;
-- 
2.17.0


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

* Re: [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops()
  2018-12-15  8:45 [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops() Yangtao Li
@ 2018-12-17  8:19 ` Ulf Hansson
  2018-12-19  8:32   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2018-12-17  8:19 UTC (permalink / raw)
  To: Yangtao Li
  Cc: Rafael J. Wysocki, Kevin Hilman, Len Brown, Pavel Machek,
	Greg Kroah-Hartman, Linux PM, Linux Kernel Mailing List

On Sat, 15 Dec 2018 at 09:45, Yangtao Li <tiny.windzz@gmail.com> wrote:
>
> We already have the DEFINE_SHOW_ATTRIBUTE, There is no need to define
> such a macro, so remove define_genpd_open_function and
> define_genpd_debugfs_fops.
>
> Convert them to DEFINE_SHOW_ATTRIBUTE.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  drivers/base/power/domain.c | 71 +++++++++++++------------------------
>  1 file changed, 24 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 7f38a92b444a..10a61d6147d0 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2671,7 +2671,7 @@ static int genpd_summary_one(struct seq_file *s,
>         return 0;
>  }
>
> -static int genpd_summary_show(struct seq_file *s, void *data)
> +static int summary_show(struct seq_file *s, void *data)

Why rename the function(s)?

[...]

Kind regards
Uffe

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

* Re: [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops()
  2018-12-17  8:19 ` Ulf Hansson
@ 2018-12-19  8:32   ` Greg Kroah-Hartman
  2018-12-19  9:17     ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2018-12-19  8:32 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Yangtao Li, Rafael J. Wysocki, Kevin Hilman, Len Brown,
	Pavel Machek, Linux PM, Linux Kernel Mailing List

On Mon, Dec 17, 2018 at 09:19:07AM +0100, Ulf Hansson wrote:
> On Sat, 15 Dec 2018 at 09:45, Yangtao Li <tiny.windzz@gmail.com> wrote:
> >
> > We already have the DEFINE_SHOW_ATTRIBUTE, There is no need to define
> > such a macro, so remove define_genpd_open_function and
> > define_genpd_debugfs_fops.
> >
> > Convert them to DEFINE_SHOW_ATTRIBUTE.
> >
> > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> > ---
> >  drivers/base/power/domain.c | 71 +++++++++++++------------------------
> >  1 file changed, 24 insertions(+), 47 deletions(-)
> >
> > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > index 7f38a92b444a..10a61d6147d0 100644
> > --- a/drivers/base/power/domain.c
> > +++ b/drivers/base/power/domain.c
> > @@ -2671,7 +2671,7 @@ static int genpd_summary_one(struct seq_file *s,
> >         return 0;
> >  }
> >
> > -static int genpd_summary_show(struct seq_file *s, void *data)
> > +static int summary_show(struct seq_file *s, void *data)
> 
> Why rename the function(s)?

Because the macro requires it?

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

* Re: [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops()
  2018-12-19  8:32   ` Greg Kroah-Hartman
@ 2018-12-19  9:17     ` Rafael J. Wysocki
  2018-12-19  9:20       ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2018-12-19  9:17 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ulf Hansson
  Cc: tiny.windzz, Rafael J. Wysocki, Kevin Hilman, Len Brown,
	Pavel Machek, Linux PM, Linux Kernel Mailing List

On Wed, Dec 19, 2018 at 9:32 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Mon, Dec 17, 2018 at 09:19:07AM +0100, Ulf Hansson wrote:
> > On Sat, 15 Dec 2018 at 09:45, Yangtao Li <tiny.windzz@gmail.com> wrote:
> > >
> > > We already have the DEFINE_SHOW_ATTRIBUTE, There is no need to define
> > > such a macro, so remove define_genpd_open_function and
> > > define_genpd_debugfs_fops.
> > >
> > > Convert them to DEFINE_SHOW_ATTRIBUTE.
> > >
> > > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> > > ---
> > >  drivers/base/power/domain.c | 71 +++++++++++++------------------------
> > >  1 file changed, 24 insertions(+), 47 deletions(-)
> > >
> > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > > index 7f38a92b444a..10a61d6147d0 100644
> > > --- a/drivers/base/power/domain.c
> > > +++ b/drivers/base/power/domain.c
> > > @@ -2671,7 +2671,7 @@ static int genpd_summary_one(struct seq_file *s,
> > >         return 0;
> > >  }
> > >
> > > -static int genpd_summary_show(struct seq_file *s, void *data)
> > > +static int summary_show(struct seq_file *s, void *data)
> >
> > Why rename the function(s)?
>
> Because the macro requires it?

Yeah.

Ulf, this looks like a good cleanup to me, any objections to this one
given the explanation above?

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

* Re: [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops()
  2018-12-19  9:17     ` Rafael J. Wysocki
@ 2018-12-19  9:20       ` Ulf Hansson
  2018-12-20 21:13         ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2018-12-19  9:20 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Greg Kroah-Hartman, Yangtao Li, Rafael J. Wysocki, Kevin Hilman,
	Len Brown, Pavel Machek, Linux PM, Linux Kernel Mailing List

On Wed, 19 Dec 2018 at 10:17, Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Wed, Dec 19, 2018 at 9:32 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Dec 17, 2018 at 09:19:07AM +0100, Ulf Hansson wrote:
> > > On Sat, 15 Dec 2018 at 09:45, Yangtao Li <tiny.windzz@gmail.com> wrote:
> > > >
> > > > We already have the DEFINE_SHOW_ATTRIBUTE, There is no need to define
> > > > such a macro, so remove define_genpd_open_function and
> > > > define_genpd_debugfs_fops.
> > > >
> > > > Convert them to DEFINE_SHOW_ATTRIBUTE.
> > > >
> > > > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> > > > ---
> > > >  drivers/base/power/domain.c | 71 +++++++++++++------------------------
> > > >  1 file changed, 24 insertions(+), 47 deletions(-)
> > > >
> > > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > > > index 7f38a92b444a..10a61d6147d0 100644
> > > > --- a/drivers/base/power/domain.c
> > > > +++ b/drivers/base/power/domain.c
> > > > @@ -2671,7 +2671,7 @@ static int genpd_summary_one(struct seq_file *s,
> > > >         return 0;
> > > >  }
> > > >
> > > > -static int genpd_summary_show(struct seq_file *s, void *data)
> > > > +static int summary_show(struct seq_file *s, void *data)
> > >
> > > Why rename the function(s)?
> >
> > Because the macro requires it?
>
> Yeah.
>
> Ulf, this looks like a good cleanup to me, any objections to this one
> given the explanation above?

It looks good to me, I just didn't go into the details of how the
macro works. Now I know, so please add:

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

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

* Re: [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops()
  2018-12-19  9:20       ` Ulf Hansson
@ 2018-12-20 21:13         ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2018-12-20 21:13 UTC (permalink / raw)
  To: Ulf Hansson, Yangtao Li
  Cc: Rafael J. Wysocki, Greg Kroah-Hartman, Kevin Hilman, Len Brown,
	Pavel Machek, Linux PM, Linux Kernel Mailing List

On Wednesday, December 19, 2018 10:20:22 AM CET Ulf Hansson wrote:
> On Wed, 19 Dec 2018 at 10:17, Rafael J. Wysocki <rafael@kernel.org> wrote:
> >
> > On Wed, Dec 19, 2018 at 9:32 AM Greg Kroah-Hartman
> > <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Mon, Dec 17, 2018 at 09:19:07AM +0100, Ulf Hansson wrote:
> > > > On Sat, 15 Dec 2018 at 09:45, Yangtao Li <tiny.windzz@gmail.com> wrote:
> > > > >
> > > > > We already have the DEFINE_SHOW_ATTRIBUTE, There is no need to define
> > > > > such a macro, so remove define_genpd_open_function and
> > > > > define_genpd_debugfs_fops.
> > > > >
> > > > > Convert them to DEFINE_SHOW_ATTRIBUTE.
> > > > >
> > > > > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> > > > > ---
> > > > >  drivers/base/power/domain.c | 71 +++++++++++++------------------------
> > > > >  1 file changed, 24 insertions(+), 47 deletions(-)
> > > > >
> > > > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > > > > index 7f38a92b444a..10a61d6147d0 100644
> > > > > --- a/drivers/base/power/domain.c
> > > > > +++ b/drivers/base/power/domain.c
> > > > > @@ -2671,7 +2671,7 @@ static int genpd_summary_one(struct seq_file *s,
> > > > >         return 0;
> > > > >  }
> > > > >
> > > > > -static int genpd_summary_show(struct seq_file *s, void *data)
> > > > > +static int summary_show(struct seq_file *s, void *data)
> > > >
> > > > Why rename the function(s)?
> > >
> > > Because the macro requires it?
> >
> > Yeah.
> >
> > Ulf, this looks like a good cleanup to me, any objections to this one
> > given the explanation above?
> 
> It looks good to me, I just didn't go into the details of how the
> macro works. Now I know, so please add:
> 
> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

So the patch has been applied, thanks!


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

end of thread, other threads:[~2018-12-20 21:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-15  8:45 [RESEND] PM / Domains: remove define_genpd_open_function() and define_genpd_debugfs_fops() Yangtao Li
2018-12-17  8:19 ` Ulf Hansson
2018-12-19  8:32   ` Greg Kroah-Hartman
2018-12-19  9:17     ` Rafael J. Wysocki
2018-12-19  9:20       ` Ulf Hansson
2018-12-20 21:13         ` Rafael J. Wysocki

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).