[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3555392.CLJaBWE9DL@vostro.rjw.lan>
Date: Sun, 17 Nov 2013 15:44:24 +0100
From: "Rafael J. Wysocki" <rjw@...ysocki.net>
To: viresh kumar <viresh.kumar@...aro.org>
Cc: Lan Tianyu <tianyu.lan@...el.com>,
"cpufreq@...r.kernel.org" <cpufreq@...r.kernel.org>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
On Sunday, November 17, 2013 09:43:14 AM viresh kumar wrote:
> On 16 November 2013 21:06, Lan Tianyu <tianyu.lan@...el.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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists