]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - arch/x86/kernel/cpu/mcheck/mce_amd_64.c
x86, mce: trivial clean up for mce_amd_64.c
[mirror_ubuntu-jammy-kernel.git] / arch / x86 / kernel / cpu / mcheck / mce_amd_64.c
index 083f270251fae9522761ab456697051b358246a3..ddae21620bda67a8c0fecf724bf2456821659c5f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/interrupt.h>
 #include <linux/notifier.h>
 #include <linux/kobject.h>
+#include <linux/percpu.h>
 #include <linux/sysdev.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
@@ -24,7 +25,6 @@
 #include <linux/cpu.h>
 #include <linux/smp.h>
 
-#include <asm/percpu.h>
 #include <asm/apic.h>
 #include <asm/idle.h>
 #include <asm/mce.h>
@@ -269,14 +269,12 @@ SHOW_FIELDS(interrupt_enable)
 SHOW_FIELDS(threshold_limit)
 
 static ssize_t
-store_interrupt_enable(struct threshold_block *b, const char *buf, size_t count)
+store_interrupt_enable(struct threshold_block *b, const char *buf, size_t size)
 {
        struct thresh_restart tr;
        unsigned long new;
-       char *end;
 
-       new = simple_strtoul(buf, &end, 0);
-       if (end == buf)
+       if (strict_strtoul(buf, 0, &new) < 0)
                return -EINVAL;
 
        b->interrupt_enable = !!new;
@@ -287,18 +285,16 @@ store_interrupt_enable(struct threshold_block *b, const char *buf, size_t count)
 
        smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1);
 
-       return end - buf;
+       return size;
 }
 
 static ssize_t
-store_threshold_limit(struct threshold_block *b, const char *buf, size_t count)
+store_threshold_limit(struct threshold_block *b, const char *buf, size_t size)
 {
        struct thresh_restart tr;
        unsigned long new;
-       char *end;
 
-       new = simple_strtoul(buf, &end, 0);
-       if (end == buf)
+       if (strict_strtoul(buf, 0, &new) < 0)
                return -EINVAL;
 
        if (new > THRESHOLD_MAX)
@@ -313,7 +309,7 @@ store_threshold_limit(struct threshold_block *b, const char *buf, size_t count)
 
        smp_call_function_single(b->cpu, threshold_restart_bank, &tr, 1);
 
-       return end - buf;
+       return size;
 }
 
 struct threshold_block_cross_cpu {
@@ -348,17 +344,13 @@ static ssize_t store_error_count(struct threshold_block *b,
        return 1;
 }
 
-#define THRESHOLD_ATTR(_name, _mode, _show, _store)                    \
-{                                                                      \
-       .attr   = {.name = __stringify(_name), .mode = _mode },         \
-       .show   = _show,                                                \
-       .store  = _store,                                               \
+#define RW_ATTR(val)                                                   \
+static struct threshold_attr val = {                                   \
+       .attr   = {.name = __stringify(val), .mode = 0644 },            \
+       .show   = show_## val,                                          \
+       .store  = store_## val,                                         \
 };
 
-#define RW_ATTR(name)                                                  \
-static struct threshold_attr name =                                    \
-       THRESHOLD_ATTR(name, 0644, show_## name, store_## name)
-
 RW_ATTR(interrupt_enable);
 RW_ATTR(threshold_limit);
 RW_ATTR(error_count);
@@ -679,9 +671,6 @@ static void threshold_remove_device(unsigned int cpu)
 static void __cpuinit
 amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu)
 {
-       if (cpu >= NR_CPUS)
-               return;
-
        switch (action) {
        case CPU_ONLINE:
        case CPU_ONLINE_FROZEN: