Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62391
b: refs/heads/master
c: f528e7b
h: refs/heads/master
i:
  62389: 37ebdb9
  62387: 55d5e50
  62383: 66461cf
v: v3
  • Loading branch information
Tim Hockin authored and Linus Torvalds committed Jul 22, 2007
1 parent 4f816e5 commit 5a54440
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a5ba7971045a90a36cef8f7d5a3075600b475b74
refs/heads/master: f528e7ba28492e363a64c80c414ded4cadf48f89
36 changes: 36 additions & 0 deletions trunk/arch/x86_64/kernel/mce.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,40 @@ void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
* Character device 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 int mce_open(struct inode *inode, struct file *file)
{
spin_lock(&mce_state_lock);

if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
spin_unlock(&mce_state_lock);
return -EBUSY;
}

if (file->f_flags & O_EXCL)
open_exclu = 1;
open_count++;

spin_unlock(&mce_state_lock);

return 0;
}

static int mce_release(struct inode *inode, struct file *file)
{
spin_lock(&mce_state_lock);

open_count--;
open_exclu = 0;

spin_unlock(&mce_state_lock);

return 0;
}

static void collect_tscs(void *data)
{
unsigned long *cpu_tsc = (unsigned long *)data;
Expand Down Expand Up @@ -555,6 +589,8 @@ static int mce_ioctl(struct inode *i, struct file *f,unsigned int cmd, unsigned
}

static const struct file_operations mce_chrdev_ops = {
.open = mce_open,
.release = mce_release,
.read = mce_read,
.ioctl = mce_ioctl,
};
Expand Down

0 comments on commit 5a54440

Please sign in to comment.