diff options
| author | Thorsten Blum <thorsten.blum@linux.dev> | 2026-07-01 13:44:28 +0200 |
|---|---|---|
| committer | Madhavan Srinivasan <maddy@linux.ibm.com> | 2026-07-31 17:04:10 +0530 |
| commit | b6cfbfd6b2992e3f34d255c983dc9f20ef0f5cd8 (patch) | |
| tree | dde730cb6f560a045aaf26231d7cd4a463fefbb7 | |
| parent | 351496d6aea664f25cbd6411bf5567210328e419 (diff) | |
| download | linux-next-b6cfbfd6b2992e3f34d255c983dc9f20ef0f5cd8.tar.gz linux-next-b6cfbfd6b2992e3f34d255c983dc9f20ef0f5cd8.zip | |
powerpc/dt_cpu_ftrs: Avoid separate strlen() in scan_callback()
Check only the first byte instead of scanning the entire string with
strlen(). While at it, keep dt_cpu_name static, but move it into
dt_cpu_ftrs_scan_callback(), where it is assigned.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260701114428.818748-3-thorsten.blum@linux.dev
| -rw-r--r-- | arch/powerpc/kernel/dt_cpu_ftrs.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c index e5853daa6a48..1b15e47e5340 100644 --- a/arch/powerpc/kernel/dt_cpu_ftrs.c +++ b/arch/powerpc/kernel/dt_cpu_ftrs.c @@ -90,8 +90,6 @@ static void __restore_cpu_cpufeatures(void) init_pmu_registers(); } -static char dt_cpu_name[64]; - static struct cpu_spec __initdata base_cpu_spec = { .cpu_name = NULL, .cpu_features = CPU_FTRS_DT_CPU_BASE, @@ -1078,6 +1076,7 @@ static int __init count_cpufeatures_subnodes(unsigned long node, static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char *uname, int depth, void *data) { + static char dt_cpu_name[64]; const __be32 *prop; int count, i; u32 isa; @@ -1115,8 +1114,8 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char } prop = of_get_flat_dt_prop(node, "display-name", NULL); - if (prop && strlen((char *)prop) != 0) { - strscpy(dt_cpu_name, (char *)prop, sizeof(dt_cpu_name)); + if (prop && *(char *)prop != 0) { + strscpy(dt_cpu_name, (char *)prop); cur_cpu_spec->cpu_name = dt_cpu_name; } |
