Commit 52e8c209 authored by Dave Young's avatar Dave Young Committed by Greg Kroah-Hartman

sysfs/file.c - use mutex instead of semaphore

Use mutex instead of semaphore in sysfs/file.c : sys_buffer.
Signed-off-by: default avatarDave Young <hidave.darkstar@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2ebefc50
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h>
#include "sysfs.h" #include "sysfs.h"
...@@ -55,7 +55,7 @@ struct sysfs_buffer { ...@@ -55,7 +55,7 @@ struct sysfs_buffer {
loff_t pos; loff_t pos;
char * page; char * page;
struct sysfs_ops * ops; struct sysfs_ops * ops;
struct semaphore sem; struct mutex mutex;
int needs_read_fill; int needs_read_fill;
int event; int event;
}; };
...@@ -128,7 +128,7 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -128,7 +128,7 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)
struct sysfs_buffer * buffer = file->private_data; struct sysfs_buffer * buffer = file->private_data;
ssize_t retval = 0; ssize_t retval = 0;
down(&buffer->sem); mutex_lock(&buffer->mutex);
if (buffer->needs_read_fill) { if (buffer->needs_read_fill) {
retval = fill_read_buffer(file->f_path.dentry,buffer); retval = fill_read_buffer(file->f_path.dentry,buffer);
if (retval) if (retval)
...@@ -139,7 +139,7 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -139,7 +139,7 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)
retval = simple_read_from_buffer(buf, count, ppos, buffer->page, retval = simple_read_from_buffer(buf, count, ppos, buffer->page,
buffer->count); buffer->count);
out: out:
up(&buffer->sem); mutex_unlock(&buffer->mutex);
return retval; return retval;
} }
...@@ -228,13 +228,13 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t ...@@ -228,13 +228,13 @@ sysfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t
struct sysfs_buffer * buffer = file->private_data; struct sysfs_buffer * buffer = file->private_data;
ssize_t len; ssize_t len;
down(&buffer->sem); mutex_lock(&buffer->mutex);
len = fill_write_buffer(buffer, buf, count); len = fill_write_buffer(buffer, buf, count);
if (len > 0) if (len > 0)
len = flush_write_buffer(file->f_path.dentry, buffer, len); len = flush_write_buffer(file->f_path.dentry, buffer, len);
if (len > 0) if (len > 0)
*ppos += len; *ppos += len;
up(&buffer->sem); mutex_unlock(&buffer->mutex);
return len; return len;
} }
...@@ -294,7 +294,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file) ...@@ -294,7 +294,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
if (!buffer) if (!buffer)
goto err_out; goto err_out;
init_MUTEX(&buffer->sem); mutex_init(&buffer->mutex);
buffer->needs_read_fill = 1; buffer->needs_read_fill = 1;
buffer->ops = ops; buffer->ops = ops;
file->private_data = buffer; file->private_data = buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment