powerpc: Deindentify identify_cpu()

The for-loop body of identify_cpu() has gotten a little big, so move the
loop body logic into a separate function. No other changes.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
Michael Ellerman 2009-02-22 16:25:43 +00:00 коммит произвёл Benjamin Herrenschmidt
Родитель 1cdab55d8a
Коммит 666435bbf3
1 изменённых файлов: 64 добавлений и 58 удалений

Просмотреть файл

@ -1785,22 +1785,15 @@ static struct cpu_spec __initdata cpu_specs[] = {
static struct cpu_spec the_cpu_spec; static struct cpu_spec the_cpu_spec;
struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr) static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s)
{ {
struct cpu_spec *s = cpu_specs;
struct cpu_spec *t = &the_cpu_spec; struct cpu_spec *t = &the_cpu_spec;
int i;
s = PTRRELOC(s);
t = PTRRELOC(t); t = PTRRELOC(t);
for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++)
if ((pvr & s->pvr_mask) == s->pvr_value) {
/* /*
* If we are overriding a previous value derived * If we are overriding a previous value derived from the real
* from the real PVR with a new value obtained * PVR with a new value obtained using a logical PVR value,
* using a logical PVR value, don't modify the * don't modify the performance monitor fields.
* performance monitor fields.
*/ */
if (t->num_pmcs && !s->num_pmcs) { if (t->num_pmcs && !s->num_pmcs) {
t->cpu_name = s->cpu_name; t->cpu_name = s->cpu_name;
@ -1812,24 +1805,23 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
t->cpu_restore = s->cpu_restore; t->cpu_restore = s->cpu_restore;
t->platform = s->platform; t->platform = s->platform;
/* /*
* If we have passed through this logic once * If we have passed through this logic once before and
* before and have pulled the default case * have pulled the default case because the real PVR was
* because the real PVR was not found inside * not found inside cpu_specs[], then we are possibly
* cpu_specs[], then we are possibly running in * running in compatibility mode. In that case, let the
* compatibility mode. In that case, let the * oprofiler know which set of compatibility counters to
* oprofiler know which set of compatibility * pull from by making sure the oprofile_cpu_type string
* counters to pull from by making sure the * is set to that of compatibility mode. If the
* oprofile_cpu_type string is set to that of * oprofile_cpu_type already has a value, then we are
* compatibility mode. If the oprofile_cpu_type * possibly overriding a real PVR with a logical one,
* already has a value, then we are possibly * and, in that case, keep the current value for
* overriding a real PVR with a logical one, and,
* in that case, keep the current value for
* oprofile_cpu_type. * oprofile_cpu_type.
*/ */
if (t->oprofile_cpu_type == NULL) if (t->oprofile_cpu_type == NULL)
t->oprofile_cpu_type = s->oprofile_cpu_type; t->oprofile_cpu_type = s->oprofile_cpu_type;
} else } else
*t = *s; *t = *s;
*PTRRELOC(&cur_cpu_spec) = &the_cpu_spec; *PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
/* /*
@ -1840,19 +1832,33 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
*PTRRELOC(&powerpc_base_platform) = t->platform; *PTRRELOC(&powerpc_base_platform) = t->platform;
#if defined(CONFIG_PPC64) || defined(CONFIG_BOOKE) #if defined(CONFIG_PPC64) || defined(CONFIG_BOOKE)
/* ppc64 and booke expect identify_cpu to also call /* ppc64 and booke expect identify_cpu to also call setup_cpu for
* setup_cpu for that processor. I will consolidate * that processor. I will consolidate that at a later time, for now,
* that at a later time, for now, just use #ifdef. * just use #ifdef. We also don't need to PTRRELOC the function
* we also don't need to PTRRELOC the function pointer * pointer on ppc64 and booke as we are running at 0 in real mode
* on ppc64 and booke as we are running at 0 in real * on ppc64 and reloc_offset is always 0 on booke.
* mode on ppc64 and reloc_offset is always 0 on booke.
*/ */
if (s->cpu_setup) { if (s->cpu_setup) {
s->cpu_setup(offset, s); s->cpu_setup(offset, s);
} }
#endif /* CONFIG_PPC64 || CONFIG_BOOKE */ #endif /* CONFIG_PPC64 || CONFIG_BOOKE */
}
struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
{
struct cpu_spec *s = cpu_specs;
int i;
s = PTRRELOC(s);
for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++) {
if ((pvr & s->pvr_mask) == s->pvr_value) {
setup_cpu_spec(offset, s);
return s; return s;
} }
}
BUG(); BUG();
return NULL; return NULL;
} }