X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Foprofile%2Fevent_buffer.c;h=e7fbac5299354e485c4a4d98774ba4fc0ae7424c;hb=2f69ae01c83a94af5dc3c20e8135b974687ed004;hp=b80318f0342022fe53827cae6e242a66479d761b;hpb=c59ede7b78db329949d9cdcd7064e22d357560ef;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c index b80318f..e7fbac5 100644 --- a/drivers/oprofile/event_buffer.c +++ b/drivers/oprofile/event_buffer.c @@ -24,7 +24,7 @@ #include "event_buffer.h" #include "oprofile_stats.h" -DECLARE_MUTEX(buffer_sem); +DEFINE_MUTEX(buffer_mutex); static unsigned long buffer_opened; static DECLARE_WAIT_QUEUE_HEAD(buffer_wait); @@ -32,7 +32,7 @@ static unsigned long * event_buffer; static unsigned long buffer_size; static unsigned long buffer_watershed; static size_t buffer_pos; -/* atomic_t because wait_event checks it outside of buffer_sem */ +/* atomic_t because wait_event checks it outside of buffer_mutex */ static atomic_t buffer_ready = ATOMIC_INIT(0); /* Add an entry to the event buffer. When we @@ -60,21 +60,22 @@ void add_event_entry(unsigned long value) */ void wake_up_buffer_waiter(void) { - down(&buffer_sem); + mutex_lock(&buffer_mutex); atomic_set(&buffer_ready, 1); wake_up(&buffer_wait); - up(&buffer_sem); + mutex_unlock(&buffer_mutex); } int alloc_event_buffer(void) { int err = -ENOMEM; + unsigned long flags; - spin_lock(&oprofilefs_lock); + spin_lock_irqsave(&oprofilefs_lock, flags); buffer_size = fs_buffer_size; buffer_watershed = fs_buffer_watershed; - spin_unlock(&oprofilefs_lock); + spin_unlock_irqrestore(&oprofilefs_lock, flags); if (buffer_watershed >= buffer_size) return -EINVAL; @@ -162,7 +163,7 @@ static ssize_t event_buffer_read(struct file * file, char __user * buf, if (!atomic_read(&buffer_ready)) return -EAGAIN; - down(&buffer_sem); + mutex_lock(&buffer_mutex); atomic_set(&buffer_ready, 0); @@ -177,11 +178,11 @@ static ssize_t event_buffer_read(struct file * file, char __user * buf, buffer_pos = 0; out: - up(&buffer_sem); + mutex_unlock(&buffer_mutex); return retval; } -struct file_operations event_buffer_fops = { +const struct file_operations event_buffer_fops = { .open = event_buffer_open, .release = event_buffer_release, .read = event_buffer_read,