mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM list <linux-pm@vger.kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>
Subject: [PATCH] cpufreq: Replace recover_policy with new_policy in cpufreq_online()
Date: Wed, 29 Jul 2015 03:08:57 +0200	[thread overview]
Message-ID: <2952411.gjDWaFdOqs@vostro.rjw.lan> (raw)
In-Reply-To: <3091538.g8dYBumqSx@vostro.rjw.lan>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The recover_policy is unsed in cpufreq_online() to indicate whether
a new policy object is created or an existing one is reinitialized.

The "recover" part of the name is slightly confusing (it should be
"reinitialization" rather than "recovery") and the logical not (!)
operator is applied to it in almost all of the checks it is used in,
so replace that variable with a new one called "new_policy" that
will be true in the case of a new policy creation.

While at it, drop one of the labels that is jumped to from only
one spot.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

One extra cleanup on top of https://patchwork.kernel.org/patch/6888751/

---
 drivers/cpufreq/cpufreq.c |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Index: linux-pm/drivers/cpufreq/cpufreq.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq.c
+++ linux-pm/drivers/cpufreq/cpufreq.c
@@ -1194,7 +1194,7 @@ static void cpufreq_policy_free(struct c
 static int cpufreq_online(unsigned int cpu)
 {
 	struct cpufreq_policy *policy;
-	bool recover_policy;
+	bool new_policy;
 	unsigned long flags;
 	unsigned int j;
 	int ret;
@@ -1209,13 +1209,13 @@ static int cpufreq_online(unsigned int c
 			return cpufreq_add_policy_cpu(policy, cpu);
 
 		/* This is the only online CPU for the policy.  Start over. */
-		recover_policy = true;
+		new_policy = false;
 		down_write(&policy->rwsem);
 		policy->cpu = cpu;
 		policy->governor = NULL;
 		up_write(&policy->rwsem);
 	} else {
-		recover_policy = false;
+		new_policy = true;
 		policy = cpufreq_policy_alloc(cpu);
 		if (!policy)
 			return -ENOMEM;
@@ -1234,7 +1234,7 @@ static int cpufreq_online(unsigned int c
 
 	down_write(&policy->rwsem);
 
-	if (!recover_policy) {
+	if (new_policy) {
 		/* related_cpus should at least include policy->cpus. */
 		cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
 		/* Remember CPUs present at the policy creation time. */
@@ -1247,7 +1247,7 @@ static int cpufreq_online(unsigned int c
 	 */
 	cpumask_and(policy->cpus, policy->cpus, cpu_online_mask);
 
-	if (!recover_policy) {
+	if (new_policy) {
 		policy->user_policy.min = policy->min;
 		policy->user_policy.max = policy->max;
 
@@ -1308,7 +1308,7 @@ static int cpufreq_online(unsigned int c
 	blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
 				     CPUFREQ_START, policy);
 
-	if (!recover_policy) {
+	if (new_policy) {
 		ret = cpufreq_add_dev_interface(policy);
 		if (ret)
 			goto out_exit_policy;
@@ -1324,10 +1324,12 @@ static int cpufreq_online(unsigned int c
 	if (ret) {
 		pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n",
 		       __func__, cpu, ret);
-		goto out_remove_policy_notify;
+		/* cpufreq_policy_free() will notify based on this */
+		new_policy = false;
+		goto out_exit_policy;
 	}
 
-	if (!recover_policy) {
+	if (new_policy) {
 		policy->user_policy.policy = policy->policy;
 		policy->user_policy.governor = policy->governor;
 	}
@@ -1343,16 +1345,13 @@ static int cpufreq_online(unsigned int c
 
 	return 0;
 
-out_remove_policy_notify:
-	/* cpufreq_policy_free() will notify based on this */
-	recover_policy = true;
 out_exit_policy:
 	up_write(&policy->rwsem);
 
 	if (cpufreq_driver->exit)
 		cpufreq_driver->exit(policy);
 out_free_policy:
-	cpufreq_policy_free(policy, recover_policy);
+	cpufreq_policy_free(policy, !new_policy);
 	return ret;
 }
 


  reply	other threads:[~2015-07-29  0:42 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23  0:00 [PATCH 0/2] cpufreq: Better separation of device addition/removal and online/offline paths Rafael J. Wysocki
2015-07-23  0:01 ` [PATCH 1/2] cpufreq: Rename two functions related to CPU offline Rafael J. Wysocki
2015-07-23  6:40   ` Viresh Kumar
2015-07-23  0:04 ` [PATCH 2/2] cpufreq: Separate CPU device removal from CPU online Rafael J. Wysocki
2015-07-23  6:39   ` Viresh Kumar
2015-07-23 20:56     ` Rafael J. Wysocki
2015-07-24  2:19       ` Viresh Kumar
2015-07-24 19:54         ` Rafael J. Wysocki
2015-07-27 14:01 ` [PATCH 0/7] cpufreq: Better separation of device addition/removal and online/offline paths Rafael J. Wysocki
2015-07-27 14:03   ` [PATCH 1/7] cpufreq: Rework two functions related to CPU offline Rafael J. Wysocki
2015-07-27 14:42     ` Viresh Kumar
2015-07-27 14:03   ` [PATCH 2/7] cpufreq: Drop cpufreq_policy_restore() Rafael J. Wysocki
2015-07-27 14:48     ` Viresh Kumar
2015-07-27 14:04   ` [PATCH 3/7] cpufreq: Drop unnecessary label from cpufreq_add_dev() Rafael J. Wysocki
2015-07-27 14:52     ` Viresh Kumar
2015-07-27 14:05   ` [PATCH 4/7] cpufreq: Drop unused dev argument from two functions Rafael J. Wysocki
2015-07-27 14:53     ` Viresh Kumar
2015-07-27 14:06   ` [PATCH 5/7] cpufreq: Do not update related_cpus on every policy activation Rafael J. Wysocki
2015-07-27 14:56     ` Viresh Kumar
2015-07-27 14:07   ` [PATCH 6/7] cpufreq: Pass CPU number to cpufreq_policy_alloc() Rafael J. Wysocki
2015-07-27 14:58     ` Viresh Kumar
2015-07-27 14:09   ` [PATCH 7/7] cpufreq: Separate CPU device removal from CPU online Rafael J. Wysocki
2015-07-27 15:06     ` Viresh Kumar
2015-07-27 20:56       ` Rafael J. Wysocki
2015-07-27 21:56         ` Rafael J. Wysocki
2015-07-28  2:06           ` Viresh Kumar
2015-07-28 14:22             ` Rafael J. Wysocki
2015-07-27 21:55     ` [Update][PATCH 7/7] cpufreq: Separate CPU device registration " Rafael J. Wysocki
2015-07-28  2:20       ` Viresh Kumar
2015-07-28 14:13         ` Rafael J. Wysocki
2015-07-29  1:03       ` [Update 2x][PATCH " Rafael J. Wysocki
2015-07-29  1:08         ` Rafael J. Wysocki [this message]
2015-07-29  5:38           ` [PATCH] cpufreq: Replace recover_policy with new_policy in cpufreq_online() Viresh Kumar
2015-07-29  5:32         ` [Update 2x][PATCH 7/7] cpufreq: Separate CPU device registration from CPU online Viresh Kumar
2015-07-29 14:02           ` Rafael J. Wysocki
2015-07-29 14:07             ` Viresh Kumar

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=2952411.gjDWaFdOqs@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --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

all inboxes | Powered by JetHome®