diff options
author | Meador Inge <meador_inge@mentor.com> | 2011-03-14 06:01:07 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-03-20 20:01:32 -0400 |
commit | d6a2639b887fcf90b422caccca4aee216bd1120e (patch) | |
tree | ca3a72a579fbc05a24726aba89a162b990d6a235 /arch | |
parent | dfec2202729e2460d67649a04756f0c3d8dcd8a6 (diff) |
powerpc: Factoring mpic cpu id fetching into a function
The following code snippet:
unsigned int cpu = 0;
if (mpic->flags & MPIC_PRIMARY)
cpu = hard_smp_processor_id();
is seen in several places in the 'mpic.c' code. This changeset factors
that pattern out into a helper function called 'mpic_processor_id'.
Signed-off-by: Meador Inge <meador_inge@mentor.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/sysdev/mpic.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index 3bf71035ff50..0f7c6718d261 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c | |||
@@ -147,6 +147,16 @@ static u32 mpic_infos[][MPIC_IDX_END] = { | |||
147 | 147 | ||
148 | #endif /* CONFIG_MPIC_WEIRD */ | 148 | #endif /* CONFIG_MPIC_WEIRD */ |
149 | 149 | ||
150 | static inline unsigned int mpic_processor_id(struct mpic *mpic) | ||
151 | { | ||
152 | unsigned int cpu = 0; | ||
153 | |||
154 | if (mpic->flags & MPIC_PRIMARY) | ||
155 | cpu = hard_smp_processor_id(); | ||
156 | |||
157 | return cpu; | ||
158 | } | ||
159 | |||
150 | /* | 160 | /* |
151 | * Register accessor functions | 161 | * Register accessor functions |
152 | */ | 162 | */ |
@@ -210,19 +220,14 @@ static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 valu | |||
210 | 220 | ||
211 | static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg) | 221 | static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg) |
212 | { | 222 | { |
213 | unsigned int cpu = 0; | 223 | unsigned int cpu = mpic_processor_id(mpic); |
214 | 224 | ||
215 | if (mpic->flags & MPIC_PRIMARY) | ||
216 | cpu = hard_smp_processor_id(); | ||
217 | return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg); | 225 | return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg); |
218 | } | 226 | } |
219 | 227 | ||
220 | static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value) | 228 | static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value) |
221 | { | 229 | { |
222 | unsigned int cpu = 0; | 230 | unsigned int cpu = mpic_processor_id(mpic); |
223 | |||
224 | if (mpic->flags & MPIC_PRIMARY) | ||
225 | cpu = hard_smp_processor_id(); | ||
226 | 231 | ||
227 | _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value); | 232 | _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value); |
228 | } | 233 | } |
@@ -1012,13 +1017,8 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq, | |||
1012 | * is done here. | 1017 | * is done here. |
1013 | */ | 1018 | */ |
1014 | if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) { | 1019 | if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) { |
1015 | unsigned int cpu = 0; | ||
1016 | |||
1017 | if (mpic->flags & MPIC_PRIMARY) | ||
1018 | cpu = hard_smp_processor_id(); | ||
1019 | |||
1020 | mpic_set_vector(virq, hw); | 1020 | mpic_set_vector(virq, hw); |
1021 | mpic_set_destination(virq, cpu); | 1021 | mpic_set_destination(virq, mpic_processor_id(mpic)); |
1022 | mpic_irq_set_priority(virq, 8); | 1022 | mpic_irq_set_priority(virq, 8); |
1023 | } | 1023 | } |
1024 | 1024 | ||
@@ -1362,10 +1362,7 @@ void __init mpic_init(struct mpic *mpic) | |||
1362 | 1362 | ||
1363 | mpic_pasemi_msi_init(mpic); | 1363 | mpic_pasemi_msi_init(mpic); |
1364 | 1364 | ||
1365 | if (mpic->flags & MPIC_PRIMARY) | 1365 | cpu = mpic_processor_id(mpic); |
1366 | cpu = hard_smp_processor_id(); | ||
1367 | else | ||
1368 | cpu = 0; | ||
1369 | 1366 | ||
1370 | if (!(mpic->flags & MPIC_NO_RESET)) { | 1367 | if (!(mpic->flags & MPIC_NO_RESET)) { |
1371 | for (i = 0; i < mpic->num_sources; i++) { | 1368 | for (i = 0; i < mpic->num_sources; i++) { |