mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] [3/3] MCE: Convert the mce code to use generic sysdev attributes.
Date: Tue,  2 Sep 2008 13:26:36 +0200 (CEST)	[thread overview]
Message-ID: <20080902112636.42F463E69FF@basil.firstfloor.org> (raw)
In-Reply-To: <20080902126.215915333@firstfloor.org>


This avoids some code duplication by using more generic sysdev
infrastructure. Also no custom macros anymore.

Should be applied on top of the new x86/unify-mce patch.

Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
 arch/x86/kernel/cpu/mcheck/mce_64.c |   36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

Index: linux/arch/x86/kernel/cpu/mcheck/mce_64.c
===================================================================
--- linux.orig/arch/x86/kernel/cpu/mcheck/mce_64.c
+++ linux/arch/x86/kernel/cpu/mcheck/mce_64.c
@@ -405,7 +405,7 @@ void mce_log_therm_throt_event(unsigned 
  * errors, poll 2x slower (up to check_interval seconds).
  */
 
-static int check_interval = 5 * 60; /* 5 minutes */
+static long check_interval = 5 * 60; /* 5 minutes */
 static int next_interval; /* in jiffies */
 static void mcheck_timer(struct work_struct *work);
 static DECLARE_DELAYED_WORK(mcheck_work, mcheck_timer);
@@ -839,25 +839,6 @@ static struct sysdev_class mce_sysclass 
 DEFINE_PER_CPU(struct sys_device, device_mce);
 void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu) __cpuinitdata;
 
-/* Why are there no generic functions for this? */
-#define ACCESSOR(name, var, start) \
-	static ssize_t show_ ## name(struct sys_device *s,		\
-				     struct sysdev_attribute *attr,	\
-				     char *buf) {			\
-		return sprintf(buf, "%Lx\n", (u64)var); 		\
-	}								\
-	static ssize_t set_ ## name(struct sys_device *s,		\
-				    struct sysdev_attribute *attr,	\
-				    const char *buf, size_t siz) {	\
-		u64 new;						\
-		int err = strict_strtoull(buf, 0, &new);		\
-		if (err) return err;					\
-		var = new;						\
-		start;							\
-		return strlen(buf);					\
-	}								\
-	static SYSDEV_ATTR(name, 0644, show_ ## name, set_ ## name);
-
 static struct sysdev_attribute *bank_attrs;
 
 static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr,
@@ -900,11 +881,22 @@ static ssize_t set_trigger(struct sys_de
 	return len;
 }
 
+static ssize_t interval_store(struct sys_device *s, struct sysdev_attribute *attr,
+			      const char *buf, size_t size)
+{
+	ssize_t ret = sysdev_store_ulong(s, attr, buf, size);
+	if (!ret)
+		mce_restart();
+	return ret;
+}
+
 static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger);
 static SYSDEV_INT_ATTR(tolerant, 0644, tolerant);
-ACCESSOR(check_interval,check_interval,mce_restart())
+static SYSDEV_EXT_ATTR(check_interval, 0644, check_interval,
+			sysdev_show_ulong, interval_store);
+
 static struct sysdev_attribute *mce_attributes[] = {
-	&attr_tolerant.attr, &attr_check_interval, &attr_trigger,
+	&attr_tolerant.attr, &attr_check_interval.attr, &attr_trigger,
 	NULL
 };
 

      parent reply	other threads:[~2008-09-02 11:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-02 11:26 [PATCH] [1/3] MCE: Implement dynamic machine check banks support Andi Kleen
2008-09-02 11:26 ` [PATCH] [2/3] sysfs: Add utility macros for declaring generic extended sysdev attributes Andi Kleen
2008-09-02 11:26 ` Andi Kleen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080902112636.42F463E69FF@basil.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome