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


Groups > linux.kernel > #1671332

[PATCH V2 3/5] arch_topology: Covert switch block to if block

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject [PATCH V2 3/5] arch_topology: Covert switch block to if block
Date 2017-06-21 06:50 +0200
Message-ID <tUFKy-1oG-7@gated-at.bofh.it> (permalink)
References <tUFKy-1oG-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


We only need to take care of one case here (CPUFREQ_NOTIFY) and there is
no need to add an extra level of indentation to the case specific code
by using a switch block. Use an if block instead.

Also add some blank lines to make the code look better.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/base/arch_topology.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 2f1d9921ee54..07784ba666a7 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -173,26 +173,29 @@ init_cpu_capacity_callback(struct notifier_block *nb,
 	if (cap_parsing_failed)
 		return 0;
 
-	switch (val) {
-	case CPUFREQ_NOTIFY:
-		pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n",
-				cpumask_pr_args(policy->related_cpus),
-				cpumask_pr_args(cpus_to_visit));
-		cpumask_andnot(cpus_to_visit, cpus_to_visit,
-			       policy->related_cpus);
-		for_each_cpu(cpu, policy->related_cpus) {
-			raw_capacity[cpu] = topology_get_cpu_scale(NULL, cpu) *
-					    policy->cpuinfo.max_freq / 1000UL;
-			capacity_scale = max(raw_capacity[cpu], capacity_scale);
-		}
-		if (cpumask_empty(cpus_to_visit)) {
-			topology_normalize_cpu_scale();
-			kfree(raw_capacity);
-			pr_debug("cpu_capacity: parsing done\n");
-			cap_parsing_failed = true;
-			schedule_work(&parsing_done_work);
-		}
+	if (val != CPUFREQ_NOTIFY)
+		return 0;
+
+	pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n",
+		 cpumask_pr_args(policy->related_cpus),
+		 cpumask_pr_args(cpus_to_visit));
+
+	cpumask_andnot(cpus_to_visit, cpus_to_visit, policy->related_cpus);
+
+	for_each_cpu(cpu, policy->related_cpus) {
+		raw_capacity[cpu] = topology_get_cpu_scale(NULL, cpu) *
+				    policy->cpuinfo.max_freq / 1000UL;
+		capacity_scale = max(raw_capacity[cpu], capacity_scale);
 	}
+
+	if (cpumask_empty(cpus_to_visit)) {
+		topology_normalize_cpu_scale();
+		kfree(raw_capacity);
+		pr_debug("cpu_capacity: parsing done\n");
+		cap_parsing_failed = true;
+		schedule_work(&parsing_done_work);
+	}
+
 	return 0;
 }
 
-- 
2.13.0.71.gd7076ec9c9cb

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2 0/5] arch_topology: Minor cleanups Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-21 06:50 +0200
  [PATCH V2 3/5] arch_topology: Covert switch block to if block Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-21 06:50 +0200
  [PATCH V2 4/5] arch_topology: Return 0 or -ve errors from topology_parse_cpu_capacity() Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-21 06:50 +0200
    Re: [PATCH V2 4/5] arch_topology: Return 0 or -ve errors from  topology_parse_cpu_capacity() Juri Lelli <juri.lelli@arm.com> - 2017-06-22 11:50 +0200
      Re: [PATCH V2 4/5] arch_topology: Return 0 or -ve errors from  topology_parse_cpu_capacity() Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-22 16:30 +0200
        Re: [PATCH V2 4/5] arch_topology: Return 0 or -ve errors from  topology_parse_cpu_capacity() Juri Lelli <juri.lelli@arm.com> - 2017-06-22 18:50 +0200
  [PATCH V2 5/5] arch_topology: Localize cap_parsing_failed to topology_parse_cpu_capacity() Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-21 06:50 +0200
  [PATCH V2 2/5] arch_topology: Don't break lines unnecessarily Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-21 06:50 +0200
  [PATCH V2 1/5] arch_topology: Get rid of "cap_parsing_done" Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-21 06:50 +0200
    Re: [PATCH V2 1/5] arch_topology: Get rid of "cap_parsing_done" Juri Lelli <juri.lelli@arm.com> - 2017-06-22 11:50 +0200
      Re: [PATCH V2 1/5] arch_topology: Get rid of "cap_parsing_done" Viresh Kumar <viresh.kumar@linaro.org> - 2017-06-22 16:30 +0200
        Re: [PATCH V2 1/5] arch_topology: Get rid of "cap_parsing_done" Juri Lelli <juri.lelli@arm.com> - 2017-06-22 18:50 +0200

csiph-web