aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/raw.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-03-23 06:00:21 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:10 -0500
commit8ed965d612d9e9bc08805c75123f063cf6966311 (patch)
tree7a863b9cb0d408295193f888b06d40d3364a404a /drivers/char/raw.c
parent9cdf18279d1f4a2d075ebe924d74e6e4547f6e1b (diff)
[PATCH] sem2mutex: drivers: raw, connector, dcdbas, ppp_generic
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/raw.c')
-rw-r--r--drivers/char/raw.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 30e4cbe16bb0..15a7b4086524 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -19,6 +19,7 @@
19#include <linux/uio.h> 19#include <linux/uio.h>
20#include <linux/cdev.h> 20#include <linux/cdev.h>
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/mutex.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
@@ -29,7 +30,7 @@ struct raw_device_data {
29 30
30static struct class *raw_class; 31static struct class *raw_class;
31static struct raw_device_data raw_devices[MAX_RAW_MINORS]; 32static struct raw_device_data raw_devices[MAX_RAW_MINORS];
32static DECLARE_MUTEX(raw_mutex); 33static DEFINE_MUTEX(raw_mutex);
33static struct file_operations raw_ctl_fops; /* forward declaration */ 34static struct file_operations raw_ctl_fops; /* forward declaration */
34 35
35/* 36/*
@@ -53,7 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp)
53 return 0; 54 return 0;
54 } 55 }
55 56
56 down(&raw_mutex); 57 mutex_lock(&raw_mutex);
57 58
58 /* 59 /*
59 * All we need to do on open is check that the device is bound. 60 * All we need to do on open is check that the device is bound.
@@ -78,7 +79,7 @@ static int raw_open(struct inode *inode, struct file *filp)
78 filp->f_dentry->d_inode->i_mapping = 79 filp->f_dentry->d_inode->i_mapping =
79 bdev->bd_inode->i_mapping; 80 bdev->bd_inode->i_mapping;
80 filp->private_data = bdev; 81 filp->private_data = bdev;
81 up(&raw_mutex); 82 mutex_unlock(&raw_mutex);
82 return 0; 83 return 0;
83 84
84out2: 85out2:
@@ -86,7 +87,7 @@ out2:
86out1: 87out1:
87 blkdev_put(bdev); 88 blkdev_put(bdev);
88out: 89out:
89 up(&raw_mutex); 90 mutex_unlock(&raw_mutex);
90 return err; 91 return err;
91} 92}
92 93
@@ -99,14 +100,14 @@ static int raw_release(struct inode *inode, struct file *filp)
99 const int minor= iminor(inode); 100 const int minor= iminor(inode);
100 struct block_device *bdev; 101 struct block_device *bdev;
101 102
102 down(&raw_mutex); 103 mutex_lock(&raw_mutex);
103 bdev = raw_devices[minor].binding; 104 bdev = raw_devices[minor].binding;
104 if (--raw_devices[minor].inuse == 0) { 105 if (--raw_devices[minor].inuse == 0) {
105 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ 106 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */
106 inode->i_mapping = &inode->i_data; 107 inode->i_mapping = &inode->i_data;
107 inode->i_mapping->backing_dev_info = &default_backing_dev_info; 108 inode->i_mapping->backing_dev_info = &default_backing_dev_info;
108 } 109 }
109 up(&raw_mutex); 110 mutex_unlock(&raw_mutex);
110 111
111 bd_release(bdev); 112 bd_release(bdev);
112 blkdev_put(bdev); 113 blkdev_put(bdev);
@@ -187,9 +188,9 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
187 goto out; 188 goto out;
188 } 189 }
189 190
190 down(&raw_mutex); 191 mutex_lock(&raw_mutex);
191 if (rawdev->inuse) { 192 if (rawdev->inuse) {
192 up(&raw_mutex); 193 mutex_unlock(&raw_mutex);
193 err = -EBUSY; 194 err = -EBUSY;
194 goto out; 195 goto out;
195 } 196 }
@@ -211,11 +212,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
211 bind_device(&rq); 212 bind_device(&rq);
212 } 213 }
213 } 214 }
214 up(&raw_mutex); 215 mutex_unlock(&raw_mutex);
215 } else { 216 } else {
216 struct block_device *bdev; 217 struct block_device *bdev;
217 218
218 down(&raw_mutex); 219 mutex_lock(&raw_mutex);
219 bdev = rawdev->binding; 220 bdev = rawdev->binding;
220 if (bdev) { 221 if (bdev) {
221 rq.block_major = MAJOR(bdev->bd_dev); 222 rq.block_major = MAJOR(bdev->bd_dev);
@@ -223,7 +224,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
223 } else { 224 } else {
224 rq.block_major = rq.block_minor = 0; 225 rq.block_major = rq.block_minor = 0;
225 } 226 }
226 up(&raw_mutex); 227 mutex_unlock(&raw_mutex);
227 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { 228 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
228 err = -EFAULT; 229 err = -EFAULT;
229 goto out; 230 goto out;