No real difference since V1. Just removed some whitespace.


On 13 March 2014 00:21, Ashwin Chaugule <ashwin.chaugule@linaro.org> wrote:
Except for getting the enable_method, the rest
of the operations are similar for DT and ACPI and
thus can be unified.

Signed-off-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
---
 arch/arm64/include/asm/cpu_ops.h |  2 +-
 arch/arm64/kernel/cpu_ops.c      | 57 +++++++++++-----------------------------
 arch/arm64/kernel/smp.c          |  4 +--
 3 files changed, 18 insertions(+), 45 deletions(-)

diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h
index 14e5fc7..1524130 100644
--- a/arch/arm64/include/asm/cpu_ops.h
+++ b/arch/arm64/include/asm/cpu_ops.h
@@ -59,7 +59,7 @@ struct cpu_operations {
 };

 extern const struct cpu_operations *cpu_ops[NR_CPUS];
-extern int __init cpu_of_read_ops(struct device_node *dn, int cpu);
+extern int __init cpu_read_ops(struct device_node *dn, int cpu);
 extern void __init cpu_read_bootcpu_ops(void);

 #endif /* ifndef __ASM_CPU_OPS_H */
diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
index c93ae18..4d96ec3 100644
--- a/arch/arm64/kernel/cpu_ops.c
+++ b/arch/arm64/kernel/cpu_ops.c
@@ -45,37 +45,9 @@ static const struct cpu_operations * __init cpu_get_ops(const char *name)

                ops++;
        }
-
        return NULL;
 }

-/*
- * Read a cpu's enable method from the device tree and record it in cpu_ops.
- */
-int __init cpu_of_read_ops(struct device_node *dn, int cpu)
-{
-       const char *enable_method = of_get_property(dn, "enable-method", NULL);
-       if (!enable_method) {
-               /*
-                * The boot CPU may not have an enable method (e.g. when
-                * spin-table is used for secondaries). Don't warn spuriously.
-                */
-               if (cpu != 0)
-                       pr_err("%s: missing enable-method property\n",
-                               dn->full_name);
-               return -ENOENT;
-       }
-
-       cpu_ops[cpu] = cpu_get_ops(enable_method);
-       if (!cpu_ops[cpu]) {
-               pr_warn("%s: unsupported enable-method property: %s\n",
-                       dn->full_name, enable_method);
-               return -EOPNOTSUPP;
-       }
-
-       return 0;
-}
-
 #ifdef CONFIG_ACPI
 /*
  * This is place holder for code which investigates bootup method for
@@ -88,13 +60,22 @@ static const char *cpu_acpi_get_enable_method(int cpu)
 {
        return "psci";
 }
+#else
+static const char *cpu_acpi_get_enable_method(int cpu)
+{
+       return NULL;
+}
+#endif

-/*
- * Read a cpu's enable method in the ACPI way and record it in cpu_ops.
- */
-int __init cpu_acpi_read_ops(int cpu)
+int __init cpu_read_ops(struct device_node *dn, int cpu)
 {
-       const char *enable_method = cpu_acpi_get_enable_method(cpu);
+       const char *enable_method = NULL;
+       /* If you get a valid dn, then we're using OF, else ACPI. */
+       if (dn)
+               enable_method = of_get_property(dn, "enable-method", NULL);
+       else
+               enable_method = cpu_acpi_get_enable_method(cpu);
+
        if (!enable_method) {
                /*
                 * The boot CPU may not have an enable method (e.g. when
@@ -111,19 +92,11 @@ int __init cpu_acpi_read_ops(int cpu)
                        cpu, enable_method);
                return -EOPNOTSUPP;
        }
-
        return 0;
 }
-#endif
-

 void __init cpu_read_bootcpu_ops(void)
 {
        struct device_node *dn = of_get_cpu_node(0, NULL);
-       if (dn) {
-               cpu_of_read_ops(dn, 0);
-               return;
-       }
-
-       cpu_acpi_read_ops(0);
+       cpu_read_ops(dn, 0);
 }
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index e6ed0cc..78b49dd 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -351,7 +351,7 @@ static int __init of_smp_init_cpus(void)
                if (cpu >= NR_CPUS)
                        goto next;

-               if (cpu_of_read_ops(dn, cpu) != 0)
+               if (cpu_read_ops(dn, cpu) != 0)
                        goto next;

                if (cpu_ops[cpu]->cpu_init(dn, cpu))
@@ -475,7 +475,7 @@ acpi_smp_parse_madt(struct acpi_subtable_header *header, const unsigned long end
                if (cpu >= NR_CPUS)
                        continue;

-               if (cpu_acpi_read_ops(cpu) != 0)
+               if (cpu_read_ops(NULL, cpu) != 0)
                        continue;

                if (cpu_ops[cpu]->cpu_init(NULL, cpu))
--
1.8.3.2