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

ARC: add helpers to sanitize config options

We'll use this macro in coming patches extensively.

Reviewed-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

authored by

Eugeniy Paltsev and committed by
Vineet Gupta
240c84b1 f61f530c

+36 -13
+24
arch/arc/include/asm/asserts.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (C) 2020 Synopsys, Inc. (www.synopsys.com) 4 + * 5 + * Author: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> 6 + */ 7 + #ifndef __ASM_ARC_ASSERTS_H 8 + #define __ASM_ARC_ASSERTS_H 9 + 10 + /* Helpers to sanitize config options. */ 11 + 12 + void chk_opt_strict(char *opt_name, bool hw_exists, bool opt_ena); 13 + 14 + /* 15 + * Check required config option: 16 + * - panic in case of OPT enabled but corresponding HW absent. 17 + * - warn in case of OPT disabled but corresponding HW exists. 18 + */ 19 + #define CHK_OPT_STRICT(opt_name, hw_exists) \ 20 + ({ \ 21 + chk_opt_strict(#opt_name, hw_exists, IS_ENABLED(opt_name)); \ 22 + }) 23 + 24 + #endif /* __ASM_ARC_ASSERTS_H */
+12 -13
arch/arc/kernel/setup.c
··· 19 19 #include <uapi/linux/mount.h> 20 20 #include <asm/sections.h> 21 21 #include <asm/arcregs.h> 22 + #include <asm/asserts.h> 22 23 #include <asm/tlb.h> 23 24 #include <asm/setup.h> 24 25 #include <asm/page.h> ··· 390 389 return buf; 391 390 } 392 391 392 + void chk_opt_strict(char *opt_name, bool hw_exists, bool opt_ena) 393 + { 394 + if (hw_exists && !opt_ena) 395 + pr_warn(" ! Enable %s for working apps\n", opt_name); 396 + else if (!hw_exists && opt_ena) 397 + panic("Disable %s, hardware NOT present\n", opt_name); 398 + } 399 + 393 400 static void arc_chk_core_config(void) 394 401 { 395 402 struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()]; 396 - int saved = 0, present = 0; 397 - char *opt_nm = NULL; 403 + int present = 0; 398 404 399 405 if (!cpu->extn.timer0) 400 406 panic("Timer0 is not present!\n"); ··· 433 425 */ 434 426 435 427 if (is_isa_arcompact()) { 436 - opt_nm = "CONFIG_ARC_FPU_SAVE_RESTORE"; 437 - saved = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE); 438 - 439 428 /* only DPDP checked since SP has no arch visible regs */ 440 429 present = cpu->extn.fpu_dp; 430 + CHK_OPT_STRICT(CONFIG_ARC_FPU_SAVE_RESTORE, present); 441 431 } else { 442 - opt_nm = "CONFIG_ARC_HAS_ACCL_REGS"; 443 - saved = IS_ENABLED(CONFIG_ARC_HAS_ACCL_REGS); 444 - 445 432 /* Accumulator Low:High pair (r58:59) present if DSP MPY or FPU */ 446 433 present = cpu->extn_mpy.dsp | cpu->extn.fpu_sp | cpu->extn.fpu_dp; 434 + CHK_OPT_STRICT(CONFIG_ARC_HAS_ACCL_REGS, present); 447 435 } 448 - 449 - if (present && !saved) 450 - pr_warn("Enable %s for working apps\n", opt_nm); 451 - else if (!present && saved) 452 - panic("Disable %s, hardware NOT present\n", opt_nm); 453 436 } 454 437 455 438 /*