ARM: 7847/1: mcpm: Factor out logical-to-physical CPU translation
[firefly-linux-kernel-4.4.55.git] / arch / arm / common / mcpm_platsmp.c
index 1bc34c7567fdf890a5eea685c04d70f7de89ffbf..c0c3cd799ccc9a37c04484dbaddd8dc614b5d6d7 100644 (file)
 #include <asm/smp.h>
 #include <asm/smp_plat.h>
 
+static void cpu_to_pcpu(unsigned int cpu,
+                       unsigned int *pcpu, unsigned int *pcluster)
+{
+       unsigned int mpidr;
+
+       mpidr = cpu_logical_map(cpu);
+       *pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
+       *pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
+}
+
 static int mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
-       unsigned int mpidr, pcpu, pcluster, ret;
+       unsigned int pcpu, pcluster, ret;
        extern void secondary_startup(void);
 
-       mpidr = cpu_logical_map(cpu);
-       pcpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
-       pcluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
+       cpu_to_pcpu(cpu, &pcpu, &pcluster);
+
        pr_debug("%s: logical CPU %d is physical CPU %d cluster %d\n",
                 __func__, cpu, pcpu, pcluster);