public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: viresh kumar <viresh.kumar@linaro.org>
Cc: Lan Tianyu <tianyu.lan@intel.com>,
	"cpufreq@vger.kernel.org" <cpufreq@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Date: Sun, 17 Nov 2013 15:44:24 +0100	[thread overview]
Message-ID: <3555392.CLJaBWE9DL@vostro.rjw.lan> (raw)
In-Reply-To: <5288425A.6000501@linaro.org>

On Sunday, November 17, 2013 09:43:14 AM viresh kumar wrote:
> On 16 November 2013 21:06, Lan Tianyu <tianyu.lan@intel.com> wrote:
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > @@ -1818,9 +1818,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
> >                 mutex_unlock(&cpufreq_governor_lock);
> >         }
> >
> > -       if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) ||
> > -                       ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret))
> > +       if ((event == CPUFREQ_GOV_POLICY_INIT) && ret) {
> > +               module_put(policy->governor->owner);
> > +               if (ret == -EALREADY)
> > +                       return 0;
> > +       } else if ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret) {
> >                 module_put(policy->governor->owner);
> > +       }
> 
> This can still be written more efficiently I believe:
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 138ebe9..54e28e1 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1866,10 +1866,12 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
>         ret = policy->governor->governor(policy, event);
> 
>         if (!ret) {
> -               if (event == CPUFREQ_GOV_POLICY_INIT)
> +               if (event == CPUFREQ_GOV_POLICY_INIT) {
>                         policy->governor->initialized++;
> -               else if (event == CPUFREQ_GOV_POLICY_EXIT)
> +               } else if (event == CPUFREQ_GOV_POLICY_EXIT) {
>                         policy->governor->initialized--;
> +                       module_put(policy->governor->owner);
> +               }
>         } else {
>                 /* Restore original values */
>                 mutex_lock(&cpufreq_governor_lock);
> @@ -1877,13 +1879,14 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
>                         policy->governor_enabled = true;
>                 else if (event == CPUFREQ_GOV_START)
>                         policy->governor_enabled = false;
> +               else if (event == CPUFREQ_GOV_POLICY_INIT)
> +                       if (ret == -EALREADY) {

You can write this as

               else if (event == CPUFREQ_GOV_POLICY_INIT && ret == -EALREADY) {

> +                               module_put(policy->governor->owner);
> +                               ret = 0;
> +                       }
>                 mutex_unlock(&cpufreq_governor_lock);
>         }
> 
> -       if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) ||
> -                       ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret))
> -               module_put(policy->governor->owner);
> -
>         return ret;

Apart from the above I agree.

Thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

  reply	other threads:[~2013-11-17 14:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15  6:01 [PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system syspend/resume Lan Tianyu
2013-11-15  8:15 ` [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume Lan Tianyu
2013-11-15 10:22   ` Viresh Kumar
2013-11-16  4:33     ` Lan Tianyu
2013-11-15 10:54   ` Viresh Kumar
2013-11-16  5:24     ` viresh kumar
2013-11-16  0:38   ` Rafael J. Wysocki
2013-11-16  3:59     ` Lan Tianyu
2013-11-16 14:41       ` Rafael J. Wysocki
2013-11-16 14:57         ` Viresh Kumar
2013-11-16 15:10           ` Rafael J. Wysocki
2013-11-16 15:09         ` Rafael J. Wysocki
2013-11-16 15:23         ` Lan Tianyu
2013-11-16 15:36         ` [PATCH V2] " Lan Tianyu
2013-11-17  4:13           ` viresh kumar
2013-11-17 14:44             ` Rafael J. Wysocki [this message]
2013-11-17 16:23               ` Viresh Kumar
2013-11-22  7:49             ` viresh kumar
2013-11-22  8:19               ` Lan Tianyu
2013-11-22  8:39                 ` Viresh Kumar
2013-11-21 14:43           ` Rafael J. Wysocki
2013-11-21 15:54             ` Viresh Kumar
2013-11-21 21:43               ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3555392.CLJaBWE9DL@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=cpufreq@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=tianyu.lan@intel.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox