summaryrefslogtreecommitdiff
path: root/arch/x86/cpu/cpu.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-11-10 18:00:26 -0700
committerSimon Glass <sjg@chromium.org>2014-11-21 07:24:12 +0100
commit727c1a987147bb55ff41ab62f7e01293a38910b8 (patch)
treed859d062dc842c60c2c941fe38d6467a3319f1d1 /arch/x86/cpu/cpu.c
parent003504b6fe2296f581191b77fd2f1e98c4f4720c (diff)
downloadu-boot-imx-727c1a987147bb55ff41ab62f7e01293a38910b8.zip
u-boot-imx-727c1a987147bb55ff41ab62f7e01293a38910b8.tar.gz
u-boot-imx-727c1a987147bb55ff41ab62f7e01293a38910b8.tar.bz2
x86: Replace fill_processor_name() with cpu_get_name()
This implementation has a 'cpu' prefix and returns a pointer to the string, avoiding the need for copying. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'arch/x86/cpu/cpu.c')
-rw-r--r--arch/x86/cpu/cpu.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index 3583619..97c77ba 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -492,14 +492,14 @@ const char *cpu_vendor_name(int vendor)
return name;
}
-void fill_processor_name(char *processor_name)
+char *cpu_get_name(char *name)
{
+ unsigned int *name_as_ints = (unsigned int *)name;
struct cpuid_result regs;
- char temp_processor_name[49];
- char *processor_name_start;
- unsigned int *name_as_ints = (unsigned int *)temp_processor_name;
+ char *ptr;
int i;
+ /* This bit adds up to 48 bytes */
for (i = 0; i < 3; i++) {
regs = cpuid(0x80000002 + i);
name_as_ints[i * 4 + 0] = regs.eax;
@@ -507,19 +507,17 @@ void fill_processor_name(char *processor_name)
name_as_ints[i * 4 + 2] = regs.ecx;
name_as_ints[i * 4 + 3] = regs.edx;
}
-
- temp_processor_name[48] = 0;
+ name[CPU_MAX_NAME_LEN - 1] = '\0';
/* Skip leading spaces. */
- processor_name_start = temp_processor_name;
- while (*processor_name_start == ' ')
- processor_name_start++;
+ ptr = name;
+ while (*ptr == ' ')
+ ptr++;
- memset(processor_name, 0, 49);
- strcpy(processor_name, processor_name_start);
+ return ptr;
}
-int print_cpuinfo(void)
+int default_print_cpuinfo(void)
{
printf("CPU: %s, vendor %s, device %xh\n",
cpu_has_64bit() ? "x86_64" : "x86",