Skip to content

Commit c845cb8

Browse files
qzhuo2bp3tk0v
authored andcommitted
x86/mce: Make several functions return bool
Make several functions that return 0 or 1 return a boolean value for better readability. No functional changes are intended. Signed-off-by: Qiuxu Zhuo <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Tony Luck <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: Sohil Mehta <[email protected]> Reviewed-by: Yazen Ghannam <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fc033cf commit c845cb8

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

arch/x86/include/asm/mce.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static inline void cmci_rediscover(void) {}
276276
static inline void cmci_recheck(void) {}
277277
#endif
278278

279-
int mce_available(struct cpuinfo_x86 *c);
279+
bool mce_available(struct cpuinfo_x86 *c);
280280
bool mce_is_memory_error(struct mce *m);
281281
bool mce_is_correctable(struct mce *m);
282282
bool mce_usable_address(struct mce *m);
@@ -296,7 +296,7 @@ enum mcp_flags {
296296

297297
void machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
298298

299-
int mce_notify_irq(void);
299+
bool mce_notify_irq(void);
300300

301301
DECLARE_PER_CPU(struct mce, injectm);
302302

arch/x86/kernel/cpu/mce/amd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,15 @@ static bool lvt_interrupt_supported(unsigned int bank, u32 msr_high_bits)
381381
return msr_high_bits & BIT(28);
382382
}
383383

384-
static int lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)
384+
static bool lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)
385385
{
386386
int msr = (hi & MASK_LVTOFF_HI) >> 20;
387387

388388
if (apic < 0) {
389389
pr_err(FW_BUG "cpu %d, failed to setup threshold interrupt "
390390
"for bank %d, block %d (MSR%08X=0x%x%08x)\n", b->cpu,
391391
b->bank, b->block, b->address, hi, lo);
392-
return 0;
392+
return false;
393393
}
394394

395395
if (apic != msr) {
@@ -399,15 +399,15 @@ static int lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)
399399
* was set is reserved. Return early here:
400400
*/
401401
if (mce_flags.smca)
402-
return 0;
402+
return false;
403403

404404
pr_err(FW_BUG "cpu %d, invalid threshold interrupt offset %d "
405405
"for bank %d, block %d (MSR%08X=0x%x%08x)\n",
406406
b->cpu, apic, b->bank, b->block, b->address, hi, lo);
407-
return 0;
407+
return false;
408408
}
409409

410-
return 1;
410+
return true;
411411
};
412412

413413
/* Reprogram MCx_MISC MSR behind this threshold bank. */

arch/x86/kernel/cpu/mce/core.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,10 @@ static noinstr void mce_gather_info(struct mce_hw_err *err, struct pt_regs *regs
492492
}
493493
}
494494

495-
int mce_available(struct cpuinfo_x86 *c)
495+
bool mce_available(struct cpuinfo_x86 *c)
496496
{
497497
if (mca_cfg.disabled)
498-
return 0;
498+
return false;
499499
return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA);
500500
}
501501

@@ -1778,7 +1778,7 @@ static void mce_timer_delete_all(void)
17781778
* Can be called from interrupt context, but not from machine check/NMI
17791779
* context.
17801780
*/
1781-
int mce_notify_irq(void)
1781+
bool mce_notify_irq(void)
17821782
{
17831783
/* Not more than two messages every minute */
17841784
static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2);
@@ -1789,9 +1789,9 @@ int mce_notify_irq(void)
17891789
if (__ratelimit(&ratelimit))
17901790
pr_info(HW_ERR "Machine check events logged\n");
17911791

1792-
return 1;
1792+
return true;
17931793
}
1794-
return 0;
1794+
return false;
17951795
}
17961796
EXPORT_SYMBOL_GPL(mce_notify_irq);
17971797

@@ -2015,25 +2015,25 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
20152015
return 0;
20162016
}
20172017

2018-
static int __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
2018+
static bool __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
20192019
{
20202020
if (c->x86 != 5)
2021-
return 0;
2021+
return false;
20222022

20232023
switch (c->x86_vendor) {
20242024
case X86_VENDOR_INTEL:
20252025
intel_p5_mcheck_init(c);
20262026
mce_flags.p5 = 1;
2027-
return 1;
2027+
return true;
20282028
case X86_VENDOR_CENTAUR:
20292029
winchip_mcheck_init(c);
20302030
mce_flags.winchip = 1;
2031-
return 1;
2031+
return true;
20322032
default:
2033-
return 0;
2033+
return false;
20342034
}
20352035

2036-
return 0;
2036+
return false;
20372037
}
20382038

20392039
/*

arch/x86/kernel/cpu/mce/intel.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ static u16 cmci_threshold[MAX_NR_BANKS];
7575
*/
7676
#define CMCI_STORM_THRESHOLD 32749
7777

78-
static int cmci_supported(int *banks)
78+
static bool cmci_supported(int *banks)
7979
{
8080
u64 cap;
8181

8282
if (mca_cfg.cmci_disabled || mca_cfg.ignore_ce)
83-
return 0;
83+
return false;
8484

8585
/*
8686
* Vendor check is not strictly needed, but the initial
@@ -89,10 +89,11 @@ static int cmci_supported(int *banks)
8989
*/
9090
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL &&
9191
boot_cpu_data.x86_vendor != X86_VENDOR_ZHAOXIN)
92-
return 0;
92+
return false;
9393

9494
if (!boot_cpu_has(X86_FEATURE_APIC) || lapic_get_maxlvt() < 6)
95-
return 0;
95+
return false;
96+
9697
rdmsrl(MSR_IA32_MCG_CAP, cap);
9798
*banks = min_t(unsigned, MAX_NR_BANKS, cap & MCG_BANKCNT_MASK);
9899
return !!(cap & MCG_CMCI_P);

0 commit comments

Comments
 (0)