Skip to content

Commit f856c35

Browse files
committed
x86/mce: Make several functions return bool
JIRA: https://issues.redhat.com/browse/RHEL-113399 commit c845cb8 Author: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Date: Thu Dec 12 22:00:57 2024 +0800 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 <qiuxu.zhuo@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Reviewed-by: Sohil Mehta <sohil.mehta@intel.com> Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com> Link: https://lore.kernel.org/r/20241212140103.66964-2-qiuxu.zhuo@intel.com Signed-off-by: Steve Best <sbest@redhat.com>
1 parent a83b039 commit f856c35

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
@@ -244,7 +244,7 @@ static inline void cmci_rediscover(void) {}
244244
static inline void cmci_recheck(void) {}
245245
#endif
246246

247-
int mce_available(struct cpuinfo_x86 *c);
247+
bool mce_available(struct cpuinfo_x86 *c);
248248
bool mce_is_memory_error(struct mce *m);
249249
bool mce_is_correctable(struct mce *m);
250250
bool mce_usable_address(struct mce *m);
@@ -264,7 +264,7 @@ enum mcp_flags {
264264

265265
void machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
266266

267-
int mce_notify_irq(void);
267+
bool mce_notify_irq(void);
268268

269269
DECLARE_PER_CPU(struct mce, injectm);
270270

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
@@ -479,10 +479,10 @@ static noinstr void mce_gather_info(struct mce *m, struct pt_regs *regs)
479479
}
480480
}
481481

482-
int mce_available(struct cpuinfo_x86 *c)
482+
bool mce_available(struct cpuinfo_x86 *c)
483483
{
484484
if (mca_cfg.disabled)
485-
return 0;
485+
return false;
486486
return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA);
487487
}
488488

@@ -1748,7 +1748,7 @@ static void mce_timer_delete_all(void)
17481748
* Can be called from interrupt context, but not from machine check/NMI
17491749
* context.
17501750
*/
1751-
int mce_notify_irq(void)
1751+
bool mce_notify_irq(void)
17521752
{
17531753
/* Not more than two messages every minute */
17541754
static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2);
@@ -1759,9 +1759,9 @@ int mce_notify_irq(void)
17591759
if (__ratelimit(&ratelimit))
17601760
pr_info(HW_ERR "Machine check events logged\n");
17611761

1762-
return 1;
1762+
return true;
17631763
}
1764-
return 0;
1764+
return false;
17651765
}
17661766
EXPORT_SYMBOL_GPL(mce_notify_irq);
17671767

@@ -1985,25 +1985,25 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
19851985
return 0;
19861986
}
19871987

1988-
static int __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
1988+
static bool __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
19891989
{
19901990
if (c->x86 != 5)
1991-
return 0;
1991+
return false;
19921992

19931993
switch (c->x86_vendor) {
19941994
case X86_VENDOR_INTEL:
19951995
intel_p5_mcheck_init(c);
19961996
mce_flags.p5 = 1;
1997-
return 1;
1997+
return true;
19981998
case X86_VENDOR_CENTAUR:
19991999
winchip_mcheck_init(c);
20002000
mce_flags.winchip = 1;
2001-
return 1;
2001+
return true;
20022002
default:
2003-
return 0;
2003+
return false;
20042004
}
20052005

2006-
return 0;
2006+
return false;
20072007
}
20082008

20092009
/*

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)