aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-03-23 06:00:36 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:12 -0500
commit7cf34c761db8827818a27e23c50756f8b821a9b0 (patch)
treec8cb1a4973aae6203e50164a479a77d244378c8d /fs
parent7a7d1cf95408863a657035701606b13644c9f55e (diff)
[PATCH] sem2mutex: fs/libfs.c
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/libfs.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/libfs.c b/fs/libfs.c
index 71fd08fa4103..4fdeaceb892c 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -7,6 +7,8 @@
7#include <linux/pagemap.h> 7#include <linux/pagemap.h>
8#include <linux/mount.h> 8#include <linux/mount.h>
9#include <linux/vfs.h> 9#include <linux/vfs.h>
10#include <linux/mutex.h>
11
10#include <asm/uaccess.h> 12#include <asm/uaccess.h>
11 13
12int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, 14int simple_getattr(struct vfsmount *mnt, struct dentry *dentry,
@@ -530,7 +532,7 @@ struct simple_attr {
530 char set_buf[24]; 532 char set_buf[24];
531 void *data; 533 void *data;
532 const char *fmt; /* format for read operation */ 534 const char *fmt; /* format for read operation */
533 struct semaphore sem; /* protects access to these buffers */ 535 struct mutex mutex; /* protects access to these buffers */
534}; 536};
535 537
536/* simple_attr_open is called by an actual attribute open file operation 538/* simple_attr_open is called by an actual attribute open file operation
@@ -549,7 +551,7 @@ int simple_attr_open(struct inode *inode, struct file *file,
549 attr->set = set; 551 attr->set = set;
550 attr->data = inode->u.generic_ip; 552 attr->data = inode->u.generic_ip;
551 attr->fmt = fmt; 553 attr->fmt = fmt;
552 init_MUTEX(&attr->sem); 554 mutex_init(&attr->mutex);
553 555
554 file->private_data = attr; 556 file->private_data = attr;
555 557
@@ -575,7 +577,7 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
575 if (!attr->get) 577 if (!attr->get)
576 return -EACCES; 578 return -EACCES;
577 579
578 down(&attr->sem); 580 mutex_lock(&attr->mutex);
579 if (*ppos) /* continued read */ 581 if (*ppos) /* continued read */
580 size = strlen(attr->get_buf); 582 size = strlen(attr->get_buf);
581 else /* first read */ 583 else /* first read */
@@ -584,7 +586,7 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
584 (unsigned long long)attr->get(attr->data)); 586 (unsigned long long)attr->get(attr->data));
585 587
586 ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size); 588 ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
587 up(&attr->sem); 589 mutex_unlock(&attr->mutex);
588 return ret; 590 return ret;
589} 591}
590 592
@@ -602,7 +604,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
602 if (!attr->set) 604 if (!attr->set)
603 return -EACCES; 605 return -EACCES;
604 606
605 down(&attr->sem); 607 mutex_lock(&attr->mutex);
606 ret = -EFAULT; 608 ret = -EFAULT;
607 size = min(sizeof(attr->set_buf) - 1, len); 609 size = min(sizeof(attr->set_buf) - 1, len);
608 if (copy_from_user(attr->set_buf, buf, size)) 610 if (copy_from_user(attr->set_buf, buf, size))
@@ -613,7 +615,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
613 val = simple_strtol(attr->set_buf, NULL, 0); 615 val = simple_strtol(attr->set_buf, NULL, 0);
614 attr->set(attr->data, val); 616 attr->set(attr->data, val);
615out: 617out:
616 up(&attr->sem); 618 mutex_unlock(&attr->mutex);
617 return ret; 619 return ret;
618} 620}
619 621