aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/char/tape_char.c
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2009-12-07 06:52:04 -0500
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>2009-12-07 06:51:36 -0500
commit369a46325d07061e0f66e16a1f59ef4f526a6464 (patch)
tree1d8c398266e1794f7dd2c958b2c2eef6088d5dda /drivers/s390/char/tape_char.c
parent8fd138c366a8a302d9da8a428c6e927c8bff7d35 (diff)
[S390] tape: remove BKL from tape driver
Replace BLK with a per device mutex. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/char/tape_char.c')
-rw-r--r--drivers/s390/char/tape_char.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c
index d44e6981eeac..23d773a0d113 100644
--- a/drivers/s390/char/tape_char.c
+++ b/drivers/s390/char/tape_char.c
@@ -33,8 +33,7 @@ static ssize_t tapechar_read(struct file *, char __user *, size_t, loff_t *);
33static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *); 33static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *);
34static int tapechar_open(struct inode *,struct file *); 34static int tapechar_open(struct inode *,struct file *);
35static int tapechar_release(struct inode *,struct file *); 35static int tapechar_release(struct inode *,struct file *);
36static int tapechar_ioctl(struct inode *, struct file *, unsigned int, 36static long tapechar_ioctl(struct file *, unsigned int, unsigned long);
37 unsigned long);
38static long tapechar_compat_ioctl(struct file *, unsigned int, 37static long tapechar_compat_ioctl(struct file *, unsigned int,
39 unsigned long); 38 unsigned long);
40 39
@@ -43,7 +42,7 @@ static const struct file_operations tape_fops =
43 .owner = THIS_MODULE, 42 .owner = THIS_MODULE,
44 .read = tapechar_read, 43 .read = tapechar_read,
45 .write = tapechar_write, 44 .write = tapechar_write,
46 .ioctl = tapechar_ioctl, 45 .unlocked_ioctl = tapechar_ioctl,
47 .compat_ioctl = tapechar_compat_ioctl, 46 .compat_ioctl = tapechar_compat_ioctl,
48 .open = tapechar_open, 47 .open = tapechar_open,
49 .release = tapechar_release, 48 .release = tapechar_release,
@@ -284,26 +283,20 @@ tapechar_open (struct inode *inode, struct file *filp)
284 if (imajor(filp->f_path.dentry->d_inode) != tapechar_major) 283 if (imajor(filp->f_path.dentry->d_inode) != tapechar_major)
285 return -ENODEV; 284 return -ENODEV;
286 285
287 lock_kernel();
288 minor = iminor(filp->f_path.dentry->d_inode); 286 minor = iminor(filp->f_path.dentry->d_inode);
289 device = tape_find_device(minor / TAPE_MINORS_PER_DEV); 287 device = tape_find_device(minor / TAPE_MINORS_PER_DEV);
290 if (IS_ERR(device)) { 288 if (IS_ERR(device)) {
291 DBF_EVENT(3, "TCHAR:open: tape_find_device() failed\n"); 289 DBF_EVENT(3, "TCHAR:open: tape_find_device() failed\n");
292 rc = PTR_ERR(device); 290 return PTR_ERR(device);
293 goto out;
294 } 291 }
295 292
296
297 rc = tape_open(device); 293 rc = tape_open(device);
298 if (rc == 0) { 294 if (rc == 0) {
299 filp->private_data = device; 295 filp->private_data = device;
300 rc = nonseekable_open(inode, filp); 296 nonseekable_open(inode, filp);
301 } 297 } else
302 else
303 tape_put_device(device); 298 tape_put_device(device);
304 299
305out:
306 unlock_kernel();
307 return rc; 300 return rc;
308} 301}
309 302
@@ -350,16 +343,11 @@ tapechar_release(struct inode *inode, struct file *filp)
350 * Tape device io controls. 343 * Tape device io controls.
351 */ 344 */
352static int 345static int
353tapechar_ioctl(struct inode *inp, struct file *filp, 346__tapechar_ioctl(struct tape_device *device,
354 unsigned int no, unsigned long data) 347 unsigned int no, unsigned long data)
355{ 348{
356 struct tape_device *device;
357 int rc; 349 int rc;
358 350
359 DBF_EVENT(6, "TCHAR:ioct\n");
360
361 device = (struct tape_device *) filp->private_data;
362
363 if (no == MTIOCTOP) { 351 if (no == MTIOCTOP) {
364 struct mtop op; 352 struct mtop op;
365 353
@@ -452,15 +440,30 @@ tapechar_ioctl(struct inode *inp, struct file *filp,
452} 440}
453 441
454static long 442static long
443tapechar_ioctl(struct file *filp, unsigned int no, unsigned long data)
444{
445 struct tape_device *device;
446 long rc;
447
448 DBF_EVENT(6, "TCHAR:ioct\n");
449
450 device = (struct tape_device *) filp->private_data;
451 mutex_lock(&device->mutex);
452 rc = __tapechar_ioctl(device, no, data);
453 mutex_unlock(&device->mutex);
454 return rc;
455}
456
457static long
455tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data) 458tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
456{ 459{
457 struct tape_device *device = filp->private_data; 460 struct tape_device *device = filp->private_data;
458 int rval = -ENOIOCTLCMD; 461 int rval = -ENOIOCTLCMD;
459 462
460 if (device->discipline->ioctl_fn) { 463 if (device->discipline->ioctl_fn) {
461 lock_kernel(); 464 mutex_lock(&device->mutex);
462 rval = device->discipline->ioctl_fn(device, no, data); 465 rval = device->discipline->ioctl_fn(device, no, data);
463 unlock_kernel(); 466 mutex_unlock(&device->mutex);
464 if (rval == -EINVAL) 467 if (rval == -EINVAL)
465 rval = -ENOIOCTLCMD; 468 rval = -ENOIOCTLCMD;
466 } 469 }