aboutsummaryrefslogtreecommitdiffstats
path: root/fs/configfs/file.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-06-22 05:20:00 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2007-07-10 20:10:58 -0400
commit6d748924b753d63a57dad130fdf11f64c27ff54b (patch)
tree93af23c4329ffb16de923ab84f63669b2423ea29 /fs/configfs/file.c
parente6bd07aee739566803425acdbf5cdb29919164e1 (diff)
[PATCH] configsfs buffer: use mutex
Seems copied from sysfs, but I don't see a reason here nor there to use a semaphore instead of a mutex. Convert. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/configfs/file.c')
-rw-r--r--fs/configfs/file.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 0f4b65e85245..a3658f9a082c 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -27,8 +27,8 @@
27#include <linux/fs.h> 27#include <linux/fs.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mutex.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/semaphore.h>
32 32
33#include <linux/configfs.h> 33#include <linux/configfs.h>
34#include "configfs_internal.h" 34#include "configfs_internal.h"
@@ -46,7 +46,7 @@ struct configfs_buffer {
46 loff_t pos; 46 loff_t pos;
47 char * page; 47 char * page;
48 struct configfs_item_operations * ops; 48 struct configfs_item_operations * ops;
49 struct semaphore sem; 49 struct mutex mutex;
50 int needs_read_fill; 50 int needs_read_fill;
51}; 51};
52 52
@@ -109,7 +109,7 @@ configfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *pp
109 struct configfs_buffer * buffer = file->private_data; 109 struct configfs_buffer * buffer = file->private_data;
110 ssize_t retval = 0; 110 ssize_t retval = 0;
111 111
112 down(&buffer->sem); 112 mutex_lock(&buffer->mutex);
113 if (buffer->needs_read_fill) { 113 if (buffer->needs_read_fill) {
114 if ((retval = fill_read_buffer(file->f_path.dentry,buffer))) 114 if ((retval = fill_read_buffer(file->f_path.dentry,buffer)))
115 goto out; 115 goto out;
@@ -119,7 +119,7 @@ configfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *pp
119 retval = simple_read_from_buffer(buf, count, ppos, buffer->page, 119 retval = simple_read_from_buffer(buf, count, ppos, buffer->page,
120 buffer->count); 120 buffer->count);
121out: 121out:
122 up(&buffer->sem); 122 mutex_unlock(&buffer->mutex);
123 return retval; 123 return retval;
124} 124}
125 125
@@ -200,13 +200,13 @@ configfs_write_file(struct file *file, const char __user *buf, size_t count, lof
200 struct configfs_buffer * buffer = file->private_data; 200 struct configfs_buffer * buffer = file->private_data;
201 ssize_t len; 201 ssize_t len;
202 202
203 down(&buffer->sem); 203 mutex_lock(&buffer->mutex);
204 len = fill_write_buffer(buffer, buf, count); 204 len = fill_write_buffer(buffer, buf, count);
205 if (len > 0) 205 if (len > 0)
206 len = flush_write_buffer(file->f_path.dentry, buffer, count); 206 len = flush_write_buffer(file->f_path.dentry, buffer, count);
207 if (len > 0) 207 if (len > 0)
208 *ppos += len; 208 *ppos += len;
209 up(&buffer->sem); 209 mutex_unlock(&buffer->mutex);
210 return len; 210 return len;
211} 211}
212 212
@@ -260,7 +260,7 @@ static int check_perm(struct inode * inode, struct file * file)
260 error = -ENOMEM; 260 error = -ENOMEM;
261 goto Enomem; 261 goto Enomem;
262 } 262 }
263 init_MUTEX(&buffer->sem); 263 mutex_init(&buffer->mutex);
264 buffer->needs_read_fill = 1; 264 buffer->needs_read_fill = 1;
265 buffer->ops = ops; 265 buffer->ops = ops;
266 file->private_data = buffer; 266 file->private_data = buffer;
@@ -299,6 +299,7 @@ static int configfs_release(struct inode * inode, struct file * filp)
299 if (buffer) { 299 if (buffer) {
300 if (buffer->page) 300 if (buffer->page)
301 free_page((unsigned long)buffer->page); 301 free_page((unsigned long)buffer->page);
302 mutex_destroy(&buffer->mutex);
302 kfree(buffer); 303 kfree(buffer);
303 } 304 }
304 return 0; 305 return 0;