summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMeador Inge <meador_inge@mentor.com>2011-03-14 10:01:07 +0000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-03-21 11:01:32 +1100
commitd6a2639b887fcf90b422caccca4aee216bd1120e (patch)
treeca3a72a579fbc05a24726aba89a162b990d6a235 /arch
parentdfec2202729e2460d67649a04756f0c3d8dcd8a6 (diff)
downloadop-kernel-dev-d6a2639b887fcf90b422caccca4aee216bd1120e.zip
op-kernel-dev-d6a2639b887fcf90b422caccca4aee216bd1120e.tar.gz
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.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 3bf7103..0f7c671 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -147,6 +147,16 @@ static u32 mpic_infos[][MPIC_IDX_END] = {
#endif /* CONFIG_MPIC_WEIRD */
+static inline unsigned int mpic_processor_id(struct mpic *mpic)
+{
+ unsigned int cpu = 0;
+
+ if (mpic->flags & MPIC_PRIMARY)
+ cpu = hard_smp_processor_id();
+
+ return cpu;
+}
+
/*
* Register accessor functions
*/
@@ -210,19 +220,14 @@ static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 valu
static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
{
- unsigned int cpu = 0;
+ unsigned int cpu = mpic_processor_id(mpic);
- if (mpic->flags & MPIC_PRIMARY)
- cpu = hard_smp_processor_id();
return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg);
}
static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value)
{
- unsigned int cpu = 0;
-
- if (mpic->flags & MPIC_PRIMARY)
- cpu = hard_smp_processor_id();
+ unsigned int cpu = mpic_processor_id(mpic);
_mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value);
}
@@ -1012,13 +1017,8 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
* is done here.
*/
if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
- unsigned int cpu = 0;
-
- if (mpic->flags & MPIC_PRIMARY)
- cpu = hard_smp_processor_id();
-
mpic_set_vector(virq, hw);
- mpic_set_destination(virq, cpu);
+ mpic_set_destination(virq, mpic_processor_id(mpic));
mpic_irq_set_priority(virq, 8);
}
@@ -1362,10 +1362,7 @@ void __init mpic_init(struct mpic *mpic)
mpic_pasemi_msi_init(mpic);
- if (mpic->flags & MPIC_PRIMARY)
- cpu = hard_smp_processor_id();
- else
- cpu = 0;
+ cpu = mpic_processor_id(mpic);
if (!(mpic->flags & MPIC_NO_RESET)) {
for (i = 0; i < mpic->num_sources; i++) {
OpenPOWER on IntegriCloud