public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: "x86@kernel.org" <x86@kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Borislav Petkov <bp@amd64.org>, Tony Luck <tony.luck@gmail.com>
Subject: [PATCH 11/12] x86, mce: use prefix mce_chrdev_ to group functions
Date: Wed, 08 Jun 2011 11:00:45 +0900	[thread overview]
Message-ID: <4DEED7CD.3040500@jp.fujitsu.com> (raw)
In-Reply-To: <4DEED509.1040504@jp.fujitsu.com>

There are many functions named mce_*, so use new prefix for
subset of functions that related to character device /dev/mcelog.

This change doesn't impact mce-inject module, because the exported
symbol mce_chrdev_ops already has the prefix so not changed.

  Before:			After:
   mce_wait			 mce_chrdev_wait
   mce_state_lock		 mce_chrdev_state_lock
   open_count   		 mce_chrdev_open_count
   open_exclu   		 mce_chrdev_open_exclu
   mce_open			 mce_chrdev_open
   mce_release  		 mce_chrdev_release
   mce_read_mutex		 mce_chrdev_read_mutex
   mce_read			 mce_chrdev_read
   mce_poll			 mce_chrdev_poll
   mce_ioctl    		 mce_chrdev_ioctl
   mce_log_device		 mce_chrdev_device

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
 arch/x86/kernel/cpu/mcheck/mce.c |   77 ++++++++++++++++++++------------------
 1 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 54360e8..9a73516 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -45,12 +45,12 @@
 
 #include "mce-internal.h"
 
-static DEFINE_MUTEX(mce_read_mutex);
+static DEFINE_MUTEX(mce_chrdev_read_mutex);
 
 #define rcu_dereference_check_mce(p) \
 	rcu_dereference_index_check((p), \
 			      rcu_read_lock_sched_held() || \
-			      lockdep_is_held(&mce_read_mutex))
+			      lockdep_is_held(&mce_chrdev_read_mutex))
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/mce.h>
@@ -90,7 +90,8 @@ static unsigned long		mce_need_notify;
 static char			mce_helper[128];
 static char			*mce_helper_argv[2] = { mce_helper, NULL };
 
-static DECLARE_WAIT_QUEUE_HEAD(mce_wait);
+static DECLARE_WAIT_QUEUE_HEAD(mce_chrdev_wait);
+
 static DEFINE_PER_CPU(struct mce, mces_seen);
 static int			cpu_missing;
 
@@ -1159,7 +1160,8 @@ int mce_notify_irq(void)
 	clear_thread_flag(TIF_MCE_NOTIFY);
 
 	if (test_and_clear_bit(0, &mce_need_notify)) {
-		wake_up_interruptible(&mce_wait);
+		/* wake processes polling /dev/mcelog */
+		wake_up_interruptible(&mce_chrdev_wait);
 
 		/*
 		 * There is no risk of missing notifications because
@@ -1423,40 +1425,41 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
 }
 
 /*
- * Character device to read and clear the MCE log.
+ * mce_chrdev: Character device /dev/mcelog to read and clear the MCE log.
  */
 
-static DEFINE_SPINLOCK(mce_state_lock);
-static int		open_count;		/* #times opened */
-static int		open_exclu;		/* already open exclusive? */
+static DEFINE_SPINLOCK(mce_chrdev_state_lock);
+static int mce_chrdev_open_count;	/* #times opened */
+static int mce_chrdev_open_exclu;	/* already open exclusive? */
 
-static int mce_open(struct inode *inode, struct file *file)
+static int mce_chrdev_open(struct inode *inode, struct file *file)
 {
-	spin_lock(&mce_state_lock);
+	spin_lock(&mce_chrdev_state_lock);
 
-	if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
-		spin_unlock(&mce_state_lock);
+	if (mce_chrdev_open_exclu ||
+	    (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
+		spin_unlock(&mce_chrdev_state_lock);
 
 		return -EBUSY;
 	}
 
 	if (file->f_flags & O_EXCL)
-		open_exclu = 1;
-	open_count++;
+		mce_chrdev_open_exclu = 1;
+	mce_chrdev_open_count++;
 
-	spin_unlock(&mce_state_lock);
+	spin_unlock(&mce_chrdev_state_lock);
 
 	return nonseekable_open(inode, file);
 }
 
-static int mce_release(struct inode *inode, struct file *file)
+static int mce_chrdev_release(struct inode *inode, struct file *file)
 {
-	spin_lock(&mce_state_lock);
+	spin_lock(&mce_chrdev_state_lock);
 
-	open_count--;
-	open_exclu = 0;
+	mce_chrdev_open_count--;
+	mce_chrdev_open_exclu = 0;
 
-	spin_unlock(&mce_state_lock);
+	spin_unlock(&mce_chrdev_state_lock);
 
 	return 0;
 }
@@ -1505,8 +1508,8 @@ static int __mce_read_apei(char __user **ubuf, size_t usize)
 	return 0;
 }
 
-static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
-			loff_t *off)
+static ssize_t mce_chrdev_read(struct file *filp, char __user *ubuf,
+				size_t usize, loff_t *off)
 {
 	char __user *buf = ubuf;
 	unsigned long *cpu_tsc;
@@ -1517,7 +1520,7 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
 	if (!cpu_tsc)
 		return -ENOMEM;
 
-	mutex_lock(&mce_read_mutex);
+	mutex_lock(&mce_chrdev_read_mutex);
 
 	if (!mce_apei_read_done) {
 		err = __mce_read_apei(&buf, usize);
@@ -1582,15 +1585,15 @@ timeout:
 		err = -EFAULT;
 
 out:
-	mutex_unlock(&mce_read_mutex);
+	mutex_unlock(&mce_chrdev_read_mutex);
 	kfree(cpu_tsc);
 
 	return err ? err : buf - ubuf;
 }
 
-static unsigned int mce_poll(struct file *file, poll_table *wait)
+static unsigned int mce_chrdev_poll(struct file *file, poll_table *wait)
 {
-	poll_wait(file, &mce_wait, wait);
+	poll_wait(file, &mce_chrdev_wait, wait);
 	if (rcu_access_index(mcelog.next))
 		return POLLIN | POLLRDNORM;
 	if (!mce_apei_read_done && apei_check_mce())
@@ -1598,7 +1601,8 @@ static unsigned int mce_poll(struct file *file, poll_table *wait)
 	return 0;
 }
 
-static long mce_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
+static long mce_chrdev_ioctl(struct file *f, unsigned int cmd,
+				unsigned long arg)
 {
 	int __user *p = (int __user *)arg;
 
@@ -1626,16 +1630,16 @@ static long mce_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 
 /* Modified in mce-inject.c, so not static or const */
 struct file_operations mce_chrdev_ops = {
-	.open			= mce_open,
-	.release		= mce_release,
-	.read			= mce_read,
-	.poll			= mce_poll,
-	.unlocked_ioctl		= mce_ioctl,
-	.llseek		= no_llseek,
+	.open			= mce_chrdev_open,
+	.release		= mce_chrdev_release,
+	.read			= mce_chrdev_read,
+	.poll			= mce_chrdev_poll,
+	.unlocked_ioctl		= mce_chrdev_ioctl,
+	.llseek			= no_llseek,
 };
 EXPORT_SYMBOL_GPL(mce_chrdev_ops);
 
-static struct miscdevice mce_log_device = {
+static struct miscdevice mce_chrdev_device = {
 	MISC_MCELOG_MINOR,
 	"mcelog",
 	&mce_chrdev_ops,
@@ -2107,11 +2111,12 @@ static __init int mcheck_init_device(void)
 
 	register_syscore_ops(&mce_syscore_ops);
 	register_hotcpu_notifier(&mce_cpu_notifier);
-	misc_register(&mce_log_device);
+
+	/* register character device /dev/mcelog */
+	misc_register(&mce_chrdev_device);
 
 	return err;
 }
-
 device_initcall(mcheck_init_device);
 
 /*
-- 
1.7.1



  parent reply	other threads:[~2011-06-08  2:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08  1:48 [PATCH 00/12] x86: minor cleanups/fixes for MCE codes (v2) Hidetoshi Seto
2011-06-08  1:51 ` [PATCH 01/12] mce-severity: fixes for mce severity table Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Fix two severities table signatures tip-bot for Tony Luck
2011-06-08  1:52 ` [PATCH 02/12] mce-severity: cleanup severity table, prep Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Make formatting a bit more readable tip-bot for Hidetoshi Seto
2011-06-08  1:53 ` [PATCH 03/12] mce-severity: cleanup severity table Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Cleanup " tip-bot for Hidetoshi Seto
2011-06-08  1:55 ` [PATCH 04/12] mce-severity: trivial cleanups Hidetoshi Seto
2011-06-16 11:17   ` [tip:ras/core] x86, mce, severity: Clean up trivial coding style problems tip-bot for Hidetoshi Seto
2011-06-08  1:56 ` [PATCH 05/12] x86, mce: replace MCE_SELF_VECTOR by irq_work Hidetoshi Seto
2011-06-16 11:17   ` [tip:ras/core] x86, mce: Replace " tip-bot for Hidetoshi Seto
2011-06-08  1:56 ` [PATCH 06/12] x86, mce: replace MCM_ to MCI_MISC_ Hidetoshi Seto
2011-06-16 11:18   ` [tip:ras/core] x86, mce: Replace MCM_ with MCI_MISC_ tip-bot for Hidetoshi Seto
2011-06-08  1:57 ` [PATCH 07/12] x86, mce: introduce mce_gather_info() Hidetoshi Seto
2011-06-16 11:18   ` [tip:ras/core] x86, mce: Introduce mce_gather_info() tip-bot for Hidetoshi Seto
2011-06-08  1:58 ` [PATCH 08/12] x86, mce: check the result of ancient_init() Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Check " tip-bot for Hidetoshi Seto
2011-06-08  1:59 ` [PATCH 09/12] x86, mce: cleanup mce_create/remove_device Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Cleanup mce_create()/remove_device() tip-bot for Hidetoshi Seto
2011-06-08  2:00 ` [PATCH 10/12] x86, mce: cleanup mce_read Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Cleanup mce_read() tip-bot for Hidetoshi Seto
2011-06-08  2:00 ` Hidetoshi Seto [this message]
2011-06-16 11:20   ` [tip:ras/core] x86, mce: Use mce_chrdev_ prefix to group functions tip-bot for Hidetoshi Seto
2011-06-08  2:02 ` [PATCH 12/12] x86, mce: use prefix mce_sysdev_ " Hidetoshi Seto
2011-06-16 11:20   ` [tip:ras/core] x86, mce: Use mce_sysdev_ prefix " tip-bot for Hidetoshi Seto
2011-06-08 10:19 ` [PATCH 00/12] x86: minor cleanups/fixes for MCE codes (v2) Borislav Petkov
2011-06-10  8:24   ` Hidetoshi Seto
  -- strict thread matches above, loose matches on Subject: below --
2011-05-27  4:00 [PATCH 00/12] minor cleanups/fixes for MCE codes Hidetoshi Seto
2011-05-27  4:12 ` [PATCH 11/12] x86, mce: use prefix mce_chrdev_ to group functions Hidetoshi Seto

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=4DEED7CD.3040500@jp.fujitsu.com \
    --to=seto.hidetoshi@jp.fujitsu.com \
    --cc=bp@amd64.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tony.luck@gmail.com \
    --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