]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/mce: Make several functions return bool
authorQiuxu Zhuo <qiuxu.zhuo@intel.com>
Thu, 12 Dec 2024 14:00:57 +0000 (22:00 +0800)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 30 Dec 2024 18:05:50 +0000 (19:05 +0100)
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
arch/x86/include/asm/mce.h
arch/x86/kernel/cpu/mce/amd.c
arch/x86/kernel/cpu/mce/core.c
arch/x86/kernel/cpu/mce/intel.c

index 4543cf2eb5e8ff4741a2e7a27fcfcdf944cee1f4..ea9ca7689f6b0291752a6ee75481bbed6c0197f4 100644 (file)
@@ -276,7 +276,7 @@ static inline void cmci_rediscover(void) {}
 static inline void cmci_recheck(void) {}
 #endif
 
-int mce_available(struct cpuinfo_x86 *c);
+bool mce_available(struct cpuinfo_x86 *c);
 bool mce_is_memory_error(struct mce *m);
 bool mce_is_correctable(struct mce *m);
 bool mce_usable_address(struct mce *m);
@@ -296,7 +296,7 @@ enum mcp_flags {
 
 void machine_check_poll(enum mcp_flags flags, mce_banks_t *b);
 
-int mce_notify_irq(void);
+bool mce_notify_irq(void);
 
 DECLARE_PER_CPU(struct mce, injectm);
 
index 6ca80fff1fea946df3310c8c473961cba4bea750..018874b554cbfa8c4cac9b9e99e32c701243b17e 100644 (file)
@@ -381,7 +381,7 @@ static bool lvt_interrupt_supported(unsigned int bank, u32 msr_high_bits)
        return msr_high_bits & BIT(28);
 }
 
-static int lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)
+static bool lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)
 {
        int msr = (hi & MASK_LVTOFF_HI) >> 20;
 
@@ -389,7 +389,7 @@ static int lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)
                pr_err(FW_BUG "cpu %d, failed to setup threshold interrupt "
                       "for bank %d, block %d (MSR%08X=0x%x%08x)\n", b->cpu,
                       b->bank, b->block, b->address, hi, lo);
-               return 0;
+               return false;
        }
 
        if (apic != msr) {
@@ -399,15 +399,15 @@ static int lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi)
                 * was set is reserved. Return early here:
                 */
                if (mce_flags.smca)
-                       return 0;
+                       return false;
 
                pr_err(FW_BUG "cpu %d, invalid threshold interrupt offset %d "
                       "for bank %d, block %d (MSR%08X=0x%x%08x)\n",
                       b->cpu, apic, b->bank, b->block, b->address, hi, lo);
-               return 0;
+               return false;
        }
 
-       return 1;
+       return true;
 };
 
 /* Reprogram MCx_MISC MSR behind this threshold bank. */
index 7fb5556a0b53d0ad8827b10ebdab6e39529494b8..167965bd2ac05250ba56dc17f1175182c3e98e60 100644 (file)
@@ -492,10 +492,10 @@ static noinstr void mce_gather_info(struct mce_hw_err *err, struct pt_regs *regs
        }
 }
 
-int mce_available(struct cpuinfo_x86 *c)
+bool mce_available(struct cpuinfo_x86 *c)
 {
        if (mca_cfg.disabled)
-               return 0;
+               return false;
        return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA);
 }
 
@@ -1778,7 +1778,7 @@ static void mce_timer_delete_all(void)
  * Can be called from interrupt context, but not from machine check/NMI
  * context.
  */
-int mce_notify_irq(void)
+bool mce_notify_irq(void)
 {
        /* Not more than two messages every minute */
        static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2);
@@ -1789,9 +1789,9 @@ int mce_notify_irq(void)
                if (__ratelimit(&ratelimit))
                        pr_info(HW_ERR "Machine check events logged\n");
 
-               return 1;
+               return true;
        }
-       return 0;
+       return false;
 }
 EXPORT_SYMBOL_GPL(mce_notify_irq);
 
@@ -2015,25 +2015,25 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
        return 0;
 }
 
-static int __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
+static bool __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
 {
        if (c->x86 != 5)
-               return 0;
+               return false;
 
        switch (c->x86_vendor) {
        case X86_VENDOR_INTEL:
                intel_p5_mcheck_init(c);
                mce_flags.p5 = 1;
-               return 1;
+               return true;
        case X86_VENDOR_CENTAUR:
                winchip_mcheck_init(c);
                mce_flags.winchip = 1;
-               return 1;
+               return true;
        default:
-               return 0;
+               return false;
        }
 
-       return 0;
+       return false;
 }
 
 /*
index b3cd2c61b11d2263b5128eb5ea2211e5005a9d46..f863df0ff42ce87a9e9a08149bf73380ffd30ed8 100644 (file)
@@ -75,12 +75,12 @@ static u16 cmci_threshold[MAX_NR_BANKS];
  */
 #define CMCI_STORM_THRESHOLD   32749
 
-static int cmci_supported(int *banks)
+static bool cmci_supported(int *banks)
 {
        u64 cap;
 
        if (mca_cfg.cmci_disabled || mca_cfg.ignore_ce)
-               return 0;
+               return false;
 
        /*
         * Vendor check is not strictly needed, but the initial
@@ -89,10 +89,11 @@ static int cmci_supported(int *banks)
         */
        if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL &&
            boot_cpu_data.x86_vendor != X86_VENDOR_ZHAOXIN)
-               return 0;
+               return false;
 
        if (!boot_cpu_has(X86_FEATURE_APIC) || lapic_get_maxlvt() < 6)
-               return 0;
+               return false;
+
        rdmsrl(MSR_IA32_MCG_CAP, cap);
        *banks = min_t(unsigned, MAX_NR_BANKS, cap & MCG_BANKCNT_MASK);
        return !!(cap & MCG_CMCI_P);