Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Remove duplicate/unnecessary ifdefs

When an ifdef is used in the below manner, second one could be considered
as duplicate.

ifdef DEFINE_A
...code block...
ifdef DEFINE_A <-- This is a duplicate.
...code block...
endif
else
ifndef DEFINE_A <-- This is also duplicate.
...code block...
endif
endif

More details about the script and methods used to find these code
patterns are in cover letter of [1].

Few places in arch/powerpc where this pattern was seen:

paca.h:
Hunk1: Code is under check of CONFIG_PPC64 from line 13, hence the
second CONFIG_PPC64 at line 166 is a duplicate.
Hunk2: CONFIG_PPC_BOOK3S_64 was defined back to back. Merged the two
ifdefs.

asm-offsets.c:
Code is under check of CONFIG_PPC64 from line 176 hence second
CONFIG_PPC64 at line 249 is a duplicate.

powermac/feature.c:
#ifndef CONFIG_PPC64 is used at line 2066. And then in #else again
#ifdef CONFIG_PPC64 is used. Which is a duplicate since in #else means
CONFIG_PPC64 is defined.

xmon.c:
Code is under the check of CONFIG_SMP from line 521 hence the same
check of CONFIG_SMP at line 646 is a duplicate.

No functional change is intended here. It only aims to improve code
readability.

[1] https://lore.kernel.org/all/20240118080326.13137-1-sshegde@linux.ibm.com/

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240216053016.528906-1-sshegde@linux.ibm.com

authored by

Shrikanth Hegde and committed by
Michael Ellerman
8c328de8 97a5253d

-10
-4
arch/powerpc/include/asm/paca.h
··· 163 163 u64 kstack; /* Saved Kernel stack addr */ 164 164 u64 saved_r1; /* r1 save for RTAS calls or PM or EE=0 */ 165 165 u64 saved_msr; /* MSR saved here by enter_rtas */ 166 - #ifdef CONFIG_PPC64 167 166 u64 exit_save_r1; /* Syscall/interrupt R1 save */ 168 - #endif 169 167 #ifdef CONFIG_PPC_BOOK3E_64 170 168 u16 trap_save; /* Used when bad stack is encountered */ 171 169 #endif ··· 212 214 /* Non-maskable exceptions that are not performance critical */ 213 215 u64 exnmi[EX_SIZE]; /* used for system reset (nmi) */ 214 216 u64 exmc[EX_SIZE]; /* used for machine checks */ 215 - #endif 216 - #ifdef CONFIG_PPC_BOOK3S_64 217 217 /* Exclusive stacks for system reset and machine check exception. */ 218 218 void *nmi_emergency_sp; 219 219 void *mc_emergency_sp;
-2
arch/powerpc/kernel/asm-offsets.c
··· 246 246 OFFSET(PACAHWCPUID, paca_struct, hw_cpu_id); 247 247 OFFSET(PACAKEXECSTATE, paca_struct, kexec_state); 248 248 OFFSET(PACA_DSCR_DEFAULT, paca_struct, dscr_default); 249 - #ifdef CONFIG_PPC64 250 249 OFFSET(PACA_EXIT_SAVE_R1, paca_struct, exit_save_r1); 251 - #endif 252 250 #ifdef CONFIG_PPC_BOOK3E_64 253 251 OFFSET(PACA_TRAP_SAVE, paca_struct, trap_save); 254 252 #endif
-2
arch/powerpc/platforms/powermac/feature.c
··· 2333 2333 PMAC_TYPE_POWERMAC_G5, g5_features, 2334 2334 0, 2335 2335 }, 2336 - #ifdef CONFIG_PPC64 2337 2336 { "PowerMac7,3", "PowerMac G5", 2338 2337 PMAC_TYPE_POWERMAC_G5, g5_features, 2339 2338 0, ··· 2357 2358 PMAC_TYPE_XSERVE_G5, g5_features, 2358 2359 0, 2359 2360 }, 2360 - #endif /* CONFIG_PPC64 */ 2361 2361 #endif /* CONFIG_PPC64 */ 2362 2362 }; 2363 2363
-2
arch/powerpc/xmon/xmon.c
··· 643 643 touch_nmi_watchdog(); 644 644 } else { 645 645 cmd = 1; 646 - #ifdef CONFIG_SMP 647 646 if (xmon_batch) 648 647 cmd = batch_cmds(regs); 649 - #endif 650 648 if (!locked_down && cmd) 651 649 cmd = cmds(regs); 652 650 if (locked_down || cmd != 0) {