arm,arm64,drivers: reduce scope of cap_parsing_failed
authorJuri Lelli <juri.lelli@arm.com>
Wed, 31 May 2017 16:59:29 +0000 (17:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Jun 2017 10:10:09 +0000 (19:10 +0900)
Reduce the scope of cap_parsing_failed (making it static in
drivers/base/arch_topology.c) by slightly changing {arm,arm64} DT
parsing code.

For arm checking for !cap_parsing_failed before calling normalize_
cpu_capacity() is superfluous, as returning an error from parse_
cpu_capacity() (above) means cap_from _dt is set to false.

For arm64 we can simply check if raw_capacity points to something,
which is not if capacity parsing has failed.

Suggested-by: Morten Rasmussen <morten.rasmussen@arm.com>
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/kernel/topology.c
arch/arm64/kernel/topology.c
drivers/base/arch_topology.c

index 49ef025ffaa01df6d36b8e5e8daef861ee961783..1e35a3265ddf0c578241bc4ec0a906185458cdcc 100644 (file)
@@ -76,7 +76,6 @@ static unsigned long *__cpu_capacity;
 
 static unsigned long middle_capacity = 1;
 static bool cap_from_dt = true;
-extern bool cap_parsing_failed;
 extern void normalize_cpu_capacity(void);
 extern int __init parse_cpu_capacity(struct device_node *cpu_node, int cpu);
 
@@ -165,7 +164,7 @@ static void __init parse_dt_topology(void)
                middle_capacity = ((max_capacity / 3)
                                >> (SCHED_CAPACITY_SHIFT-1)) + 1;
 
-       if (cap_from_dt && !cap_parsing_failed)
+       if (cap_from_dt)
                normalize_cpu_capacity();
 }
 
index c5bc31eb97e8103dd0c05ec624aa7f7c78de8f14..7e1f6f75185b0f2f12fbec1ebd9431580a29f31c 100644 (file)
@@ -27,7 +27,6 @@
 #include <asm/cputype.h>
 #include <asm/topology.h>
 
-extern bool cap_parsing_failed;
 extern void normalize_cpu_capacity(void);
 extern int __init parse_cpu_capacity(struct device_node *cpu_node, int cpu);
 
@@ -187,10 +186,8 @@ static int __init parse_dt_topology(void)
         * cluster with restricted subnodes.
         */
        map = of_get_child_by_name(cn, "cpu-map");
-       if (!map) {
-               cap_parsing_failed = true;
+       if (!map)
                goto out;
-       }
 
        ret = parse_cluster(map, 0);
        if (ret != 0)
index 097834f0fcd7ce01a0f352da4e5f5c796f4384bd..acf99372c5cf340a9fbd0683776d9eab815cd4c9 100644 (file)
@@ -95,7 +95,7 @@ subsys_initcall(register_cpu_capacity_sysctl);
 
 static u32 capacity_scale;
 static u32 *raw_capacity;
-bool cap_parsing_failed;
+static bool cap_parsing_failed;
 
 void normalize_cpu_capacity(void)
 {
@@ -210,7 +210,7 @@ static int __init register_cpufreq_notifier(void)
         * until we have the necessary code to parse the cpu capacity, so
         * skip registering cpufreq notifier.
         */
-       if (!acpi_disabled || cap_parsing_failed)
+       if (!acpi_disabled || !raw_capacity)
                return -EINVAL;
 
        if (!alloc_cpumask_var(&cpus_to_visit, GFP_KERNEL)) {