aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/cputable.c
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2009-02-22 11:25:43 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-03-11 02:10:14 -0400
commit666435bbf31bfc2aec2afccb2fb54951e573c5c1 (patch)
treeaaecd56330eef32abf0541cb86d3fd6332419412 /arch/powerpc/kernel/cputable.c
parent1cdab55d8a8313f77a95fb8ca966dc4334f8e810 (diff)
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>
Diffstat (limited to 'arch/powerpc/kernel/cputable.c')
-rw-r--r--arch/powerpc/kernel/cputable.c122
1 files changed, 64 insertions, 58 deletions
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index b2938e0ef2f3..401f973a74a0 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -1785,74 +1785,80 @@ static struct cpu_spec __initdata cpu_specs[] = {
1785 1785
1786static struct cpu_spec the_cpu_spec; 1786static struct cpu_spec the_cpu_spec;
1787 1787
1788struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr) 1788static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s)
1789{ 1789{
1790 struct cpu_spec *s = cpu_specs;
1791 struct cpu_spec *t = &the_cpu_spec; 1790 struct cpu_spec *t = &the_cpu_spec;
1792 int i;
1793
1794 s = PTRRELOC(s);
1795 t = PTRRELOC(t); 1791 t = PTRRELOC(t);
1796 1792
1797 for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++) 1793 /*
1798 if ((pvr & s->pvr_mask) == s->pvr_value) { 1794 * If we are overriding a previous value derived from the real
1799 /* 1795 * PVR with a new value obtained using a logical PVR value,
1800 * If we are overriding a previous value derived 1796 * don't modify the performance monitor fields.
1801 * from the real PVR with a new value obtained 1797 */
1802 * using a logical PVR value, don't modify the 1798 if (t->num_pmcs && !s->num_pmcs) {
1803 * performance monitor fields. 1799 t->cpu_name = s->cpu_name;
1804 */ 1800 t->cpu_features = s->cpu_features;
1805 if (t->num_pmcs && !s->num_pmcs) { 1801 t->cpu_user_features = s->cpu_user_features;
1806 t->cpu_name = s->cpu_name; 1802 t->icache_bsize = s->icache_bsize;
1807 t->cpu_features = s->cpu_features; 1803 t->dcache_bsize = s->dcache_bsize;
1808 t->cpu_user_features = s->cpu_user_features; 1804 t->cpu_setup = s->cpu_setup;
1809 t->icache_bsize = s->icache_bsize; 1805 t->cpu_restore = s->cpu_restore;
1810 t->dcache_bsize = s->dcache_bsize; 1806 t->platform = s->platform;
1811 t->cpu_setup = s->cpu_setup; 1807 /*
1812 t->cpu_restore = s->cpu_restore; 1808 * If we have passed through this logic once before and
1813 t->platform = s->platform; 1809 * have pulled the default case because the real PVR was
1814 /* 1810 * not found inside cpu_specs[], then we are possibly
1815 * If we have passed through this logic once 1811 * running in compatibility mode. In that case, let the
1816 * before and have pulled the default case 1812 * oprofiler know which set of compatibility counters to
1817 * because the real PVR was not found inside 1813 * pull from by making sure the oprofile_cpu_type string
1818 * cpu_specs[], then we are possibly running in 1814 * is set to that of compatibility mode. If the
1819 * compatibility mode. In that case, let the 1815 * oprofile_cpu_type already has a value, then we are
1820 * oprofiler know which set of compatibility 1816 * possibly overriding a real PVR with a logical one,
1821 * counters to pull from by making sure the 1817 * and, in that case, keep the current value for
1822 * oprofile_cpu_type string is set to that of 1818 * oprofile_cpu_type.
1823 * compatibility mode. If the oprofile_cpu_type 1819 */
1824 * already has a value, then we are possibly 1820 if (t->oprofile_cpu_type == NULL)
1825 * overriding a real PVR with a logical one, and, 1821 t->oprofile_cpu_type = s->oprofile_cpu_type;
1826 * in that case, keep the current value for 1822 } else
1827 * oprofile_cpu_type. 1823 *t = *s;
1828 */ 1824
1829 if (t->oprofile_cpu_type == NULL) 1825 *PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
1830 t->oprofile_cpu_type = s->oprofile_cpu_type;
1831 } else
1832 *t = *s;
1833 *PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
1834 1826
1835 /* 1827 /*
1836 * Set the base platform string once; assumes 1828 * Set the base platform string once; assumes
1837 * we're called with real pvr first. 1829 * we're called with real pvr first.
1838 */ 1830 */
1839 if (*PTRRELOC(&powerpc_base_platform) == NULL) 1831 if (*PTRRELOC(&powerpc_base_platform) == NULL)
1840 *PTRRELOC(&powerpc_base_platform) = t->platform; 1832 *PTRRELOC(&powerpc_base_platform) = t->platform;
1841 1833
1842#if defined(CONFIG_PPC64) || defined(CONFIG_BOOKE) 1834#if defined(CONFIG_PPC64) || defined(CONFIG_BOOKE)
1843 /* ppc64 and booke expect identify_cpu to also call 1835 /* ppc64 and booke expect identify_cpu to also call setup_cpu for
1844 * setup_cpu for that processor. I will consolidate 1836 * that processor. I will consolidate that at a later time, for now,
1845 * that at a later time, for now, just use #ifdef. 1837 * just use #ifdef. We also don't need to PTRRELOC the function
1846 * we also don't need to PTRRELOC the function pointer 1838 * pointer on ppc64 and booke as we are running at 0 in real mode
1847 * on ppc64 and booke as we are running at 0 in real 1839 * on ppc64 and reloc_offset is always 0 on booke.
1848 * mode on ppc64 and reloc_offset is always 0 on booke. 1840 */
1849 */ 1841 if (s->cpu_setup) {
1850 if (s->cpu_setup) { 1842 s->cpu_setup(offset, s);
1851 s->cpu_setup(offset, s); 1843 }
1852 }
1853#endif /* CONFIG_PPC64 || CONFIG_BOOKE */ 1844#endif /* CONFIG_PPC64 || CONFIG_BOOKE */
1845}
1846
1847struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
1848{
1849 struct cpu_spec *s = cpu_specs;
1850 int i;
1851
1852 s = PTRRELOC(s);
1853
1854 for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++) {
1855 if ((pvr & s->pvr_mask) == s->pvr_value) {
1856 setup_cpu_spec(offset, s);
1854 return s; 1857 return s;
1855 } 1858 }
1859 }
1860
1856 BUG(); 1861 BUG();
1862
1857 return NULL; 1863 return NULL;
1858} 1864}