Skip to content

Commit 1751ade

Browse files
KAGA-KOKOhansendc
authored andcommitted
x86/apic: Make some APIC init functions bool
Quite some APIC init functions are pure boolean, but use the success = 0, fail < 0 model. That's confusing as hell when reading through the code. Convert them to boolean. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Michael Kelley <[email protected]> Tested-by: Sohil Mehta <[email protected]> Tested-by: Juergen Gross <[email protected]> # Xen PV (dom0 and unpriv. guest)
1 parent 2906a67 commit 1751ade

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

arch/x86/include/asm/apic.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ extern void setup_secondary_APIC_clock(void);
135135
extern void lapic_update_tsc_freq(void);
136136

137137
#ifdef CONFIG_X86_64
138-
static inline int apic_force_enable(unsigned long addr)
138+
static inline bool apic_force_enable(unsigned long addr)
139139
{
140-
return -1;
140+
return false;
141141
}
142142
#else
143-
extern int apic_force_enable(unsigned long addr);
143+
extern bool apic_force_enable(unsigned long addr);
144144
#endif
145145

146146
extern void apic_ap_setup(void);

arch/x86/kernel/apic/apic.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,19 +2000,19 @@ void __init enable_IR_x2apic(void)
20002000
* On AMD64 we trust the BIOS - if it says no APIC it is likely
20012001
* not correctly set up (usually the APIC timer won't work etc.)
20022002
*/
2003-
static int __init detect_init_APIC(void)
2003+
static bool __init detect_init_APIC(void)
20042004
{
20052005
if (!boot_cpu_has(X86_FEATURE_APIC)) {
20062006
pr_info("No local APIC present\n");
2007-
return -1;
2007+
return false;
20082008
}
20092009

20102010
mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
2011-
return 0;
2011+
return true;
20122012
}
20132013
#else
20142014

2015-
static int __init apic_verify(void)
2015+
static bool __init apic_verify(void)
20162016
{
20172017
u32 features, h, l;
20182018

@@ -2023,7 +2023,7 @@ static int __init apic_verify(void)
20232023
features = cpuid_edx(1);
20242024
if (!(features & (1 << X86_FEATURE_APIC))) {
20252025
pr_warn("Could not enable APIC!\n");
2026-
return -1;
2026+
return false;
20272027
}
20282028
set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
20292029
mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
@@ -2036,15 +2036,15 @@ static int __init apic_verify(void)
20362036
}
20372037

20382038
pr_info("Found and enabled local APIC!\n");
2039-
return 0;
2039+
return true;
20402040
}
20412041

2042-
int __init apic_force_enable(unsigned long addr)
2042+
bool __init apic_force_enable(unsigned long addr)
20432043
{
20442044
u32 h, l;
20452045

20462046
if (apic_is_disabled)
2047-
return -1;
2047+
return false;
20482048

20492049
/*
20502050
* Some BIOSes disable the local APIC in the APIC_BASE
@@ -2067,11 +2067,11 @@ int __init apic_force_enable(unsigned long addr)
20672067
/*
20682068
* Detect and initialize APIC
20692069
*/
2070-
static int __init detect_init_APIC(void)
2070+
static bool __init detect_init_APIC(void)
20712071
{
20722072
/* Disabled by kernel option? */
20732073
if (apic_is_disabled)
2074-
return -1;
2074+
return false;
20752075

20762076
switch (boot_cpu_data.x86_vendor) {
20772077
case X86_VENDOR_AMD:
@@ -2098,22 +2098,22 @@ static int __init detect_init_APIC(void)
20982098
if (!force_enable_local_apic) {
20992099
pr_info("Local APIC disabled by BIOS -- "
21002100
"you can enable it with \"lapic\"\n");
2101-
return -1;
2101+
return false;
21022102
}
2103-
if (apic_force_enable(APIC_DEFAULT_PHYS_BASE))
2104-
return -1;
2103+
if (!apic_force_enable(APIC_DEFAULT_PHYS_BASE))
2104+
return false;
21052105
} else {
2106-
if (apic_verify())
2107-
return -1;
2106+
if (!apic_verify())
2107+
return false;
21082108
}
21092109

21102110
apic_pm_activate();
21112111

2112-
return 0;
2112+
return true;
21132113

21142114
no_apic:
21152115
pr_info("No local APIC present or hardware disabled\n");
2116-
return -1;
2116+
return false;
21172117
}
21182118
#endif
21192119

@@ -2129,7 +2129,7 @@ void __init init_apic_mappings(void)
21292129
return;
21302130

21312131
/* If no local APIC can be found return early */
2132-
if (!smp_found_config && detect_init_APIC()) {
2132+
if (!smp_found_config && !detect_init_APIC()) {
21332133
/* lets NOP'ify apic operations */
21342134
pr_info("APIC: disable apic facility\n");
21352135
apic_disable();

arch/x86/kernel/devicetree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static void __init dtb_lapic_setup(void)
158158
/* Did the boot loader setup the local APIC ? */
159159
if (!boot_cpu_has(X86_FEATURE_APIC)) {
160160
/* Try force enabling, which registers the APIC address */
161-
if (apic_force_enable(lapic_addr))
161+
if (!apic_force_enable(lapic_addr))
162162
return;
163163
} else {
164164
register_lapic_address(lapic_addr);

0 commit comments

Comments
 (0)