arm64: Introduce get_cpu_ops() helper function
PATCH 3/4 arm64: Introduce get_cpu_ops() helper function
This introduces get_cpu_ops() to return the CPU operations according to the given CPU index. For now, it simply returns the @cpu_ops[cpu] as before. So it shouldn't introduce any functional changes.
Signed-off-by Gavin Shan <[email protected]>
--- arch/arm64/include/asm/cpu_ops.h | 2 +- arch/arm64/kernel/cpu_ops.c | 7 +++- arch/arm64/kernel/cpuidle.c | 9 ++--- arch/arm64/kernel/setup.c | 6 ++-- arch/arm64/kernel/smp.c | 57 ++++++++++++++++++++++---------- 5 files changed, 55 insertions(+), 26 deletions(-)
arch/arm64/include/asm/cpu_ops.h +1 -1
@@ -55,8 +55,8 @@ struct cpu_operations {#endif }; -extern const struct cpu_operations *cpu_ops[NR_CPUS ];int __init init_cpu_ops (int cpu); +extern const struct cpu_operations *get_cpu_ops (int cpu);static inline void __init init_bootcpu_ops (void ) {
arch/arm64/kernel/cpu_ops.c +6 -1
@@ -20,7 +20,7 @@ extern const struct cpu_operations acpi_parking_protocol_ops;#endif extern const struct cpu_operations cpu_psci_ops; -const struct cpu_operations *cpu_ops[NR_CPUS ]__ro_after_init ; +static const struct cpu_operations *cpu_ops[NR_CPUS ]__ro_after_init ;static const struct cpu_operations *const dt_supported_cpu_ops[]__initconst = { &smp_spin_table_ops,
@@ -111,3 +111,8 @@ int __init init_cpu_ops(int cpu)return 0 ; } + +const struct cpu_operations *get_cpu_ops (int cpu) +{ +return cpu_ops[cpu]; +}
arch/arm64/kernel/cpuidle.c +5 -4
@@ -18,11 +18,11 @@int arm_cpuidle_init (unsigned int cpu) { +const struct cpu_operations *ops =get_cpu_ops (cpu);int ret = -EOPNOTSUPP ; -if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend && - cpu_ops[cpu]->cpu_init_idle) - ret = cpu_ops[cpu]->cpu_init_idle (cpu); +if (ops && ops->cpu_suspend && ops->cpu_init_idle) + ret = ops->cpu_init_idle (cpu);return ret; }
@@ -37,8 +37,9 @@ int arm_cpuidle_init(unsigned int cpu)int arm_cpuidle_suspend (int index) {int cpu =smp_processor_id (); +const struct cpu_operations *ops =get_cpu_ops (cpu); -return cpu_ops[cpu]->cpu_suspend (index); +return ops->cpu_suspend (index); }#ifdef CONFIG_ACPI
arch/arm64/kernel/setup.c +4 -2
@@ -366,8 +366,10 @@ void __init setup_arch(char **cmdline_p)static inline bool cpu_can_disable (unsigned int cpu) {#ifdef CONFIG_HOTPLUG_CPU -if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_can_disable) -return cpu_ops[cpu]->cpu_can_disable (cpu); +const struct cpu_operations *ops =get_cpu_ops (cpu); + +if (ops && ops->cpu_can_disable) +return ops->cpu_can_disable (cpu);#endif return false; }
arch/arm64/kernel/smp.c +39 -18
170 lines not on this page · raw message
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel