Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1373000 > unrolled thread

[PATCH] cpufreq: Rearrange cpufreq_add_dev()

Started by"Rafael J. Wysocki" <rjw@rjwysocki.net>
First post2016-04-07 03:30 +0200
Last post2016-04-07 06:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] cpufreq: Rearrange cpufreq_add_dev() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-04-07 03:30 +0200
    Re: [PATCH] cpufreq: Rearrange cpufreq_add_dev() Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-07 06:40 +0200

#1373000 — [PATCH] cpufreq: Rearrange cpufreq_add_dev()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-04-07 03:30 +0200
Subject[PATCH] cpufreq: Rearrange cpufreq_add_dev()
Message-ID<rl6VI-4qg-5@gated-at.bofh.it>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Reorganize the code in cpufreq_add_dev() to avoid using the ret
variable and reduce the indentation level in it.

No functional changes.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq.c |   26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

Index: linux-pm/drivers/cpufreq/cpufreq.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq.c
+++ linux-pm/drivers/cpufreq/cpufreq.c
@@ -1311,26 +1311,24 @@ out_free_policy:
  */
 static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
 {
+	struct cpufreq_policy *policy;
 	unsigned cpu = dev->id;
-	int ret;
 
 	dev_dbg(dev, "%s: adding CPU%u\n", __func__, cpu);
 
-	if (cpu_online(cpu)) {
-		ret = cpufreq_online(cpu);
-	} else {
-		/*
-		 * A hotplug notifier will follow and we will handle it as CPU
-		 * online then.  For now, just create the sysfs link, unless
-		 * there is no policy or the link is already present.
-		 */
-		struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
+	if (cpu_online(cpu))
+		return cpufreq_online(cpu);
 
-		ret = policy && !cpumask_test_and_set_cpu(cpu, policy->real_cpus)
-			? add_cpu_dev_symlink(policy, cpu) : 0;
-	}
+	/*
+	 * A hotplug notifier will follow and we will handle it as CPU online
+	 * then.  For now, just create the sysfs link, unless there is no policy
+	 * or the link is already present.
+	 */
+	policy = per_cpu(cpufreq_cpu_data, cpu);
+	if (!policy || cpumask_test_and_set_cpu(cpu, policy->real_cpus))
+		return 0;
 
-	return ret;
+	return add_cpu_dev_symlink(policy, cpu);
 }
 
 static void cpufreq_offline(unsigned int cpu)

[toc] | [next] | [standalone]


#1373066

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-04-07 06:40 +0200
Message-ID<rl9TC-6RU-33@gated-at.bofh.it>
In reply to#1373000
On 07-04-16, 03:31, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Reorganize the code in cpufreq_add_dev() to avoid using the ret
> variable and reduce the indentation level in it.
> 
> No functional changes.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/cpufreq/cpufreq.c |   26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/cpufreq.c
> ===================================================================
> --- linux-pm.orig/drivers/cpufreq/cpufreq.c
> +++ linux-pm/drivers/cpufreq/cpufreq.c
> @@ -1311,26 +1311,24 @@ out_free_policy:
>   */
>  static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
>  {
> +	struct cpufreq_policy *policy;
>  	unsigned cpu = dev->id;
> -	int ret;
>  
>  	dev_dbg(dev, "%s: adding CPU%u\n", __func__, cpu);
>  
> -	if (cpu_online(cpu)) {
> -		ret = cpufreq_online(cpu);
> -	} else {
> -		/*
> -		 * A hotplug notifier will follow and we will handle it as CPU
> -		 * online then.  For now, just create the sysfs link, unless
> -		 * there is no policy or the link is already present.
> -		 */
> -		struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
> +	if (cpu_online(cpu))
> +		return cpufreq_online(cpu);
>  
> -		ret = policy && !cpumask_test_and_set_cpu(cpu, policy->real_cpus)
> -			? add_cpu_dev_symlink(policy, cpu) : 0;
> -	}
> +	/*
> +	 * A hotplug notifier will follow and we will handle it as CPU online
> +	 * then.  For now, just create the sysfs link, unless there is no policy
> +	 * or the link is already present.
> +	 */
> +	policy = per_cpu(cpufreq_cpu_data, cpu);
> +	if (!policy || cpumask_test_and_set_cpu(cpu, policy->real_cpus))
> +		return 0;
>  
> -	return ret;
> +	return add_cpu_dev_symlink(policy, cpu);
>  }
>  
>  static void cpufreq_offline(unsigned int cpu)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web