diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2009-12-07 06:52:04 -0500 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2009-12-07 06:51:36 -0500 |
commit | 369a46325d07061e0f66e16a1f59ef4f526a6464 (patch) | |
tree | 1d8c398266e1794f7dd2c958b2c2eef6088d5dda /drivers/s390 | |
parent | 8fd138c366a8a302d9da8a428c6e927c8bff7d35 (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')
-rw-r--r-- | drivers/s390/char/tape.h | 3 | ||||
-rw-r--r-- | drivers/s390/char/tape_block.c | 2 | ||||
-rw-r--r-- | drivers/s390/char/tape_char.c | 45 | ||||
-rw-r--r-- | drivers/s390/char/tape_core.c | 1 |
4 files changed, 29 insertions, 22 deletions
diff --git a/drivers/s390/char/tape.h b/drivers/s390/char/tape.h index fbe41e0377b8..7a242f073632 100644 --- a/drivers/s390/char/tape.h +++ b/drivers/s390/char/tape.h | |||
@@ -212,6 +212,9 @@ struct tape_device { | |||
212 | struct tape_class_device * nt; | 212 | struct tape_class_device * nt; |
213 | struct tape_class_device * rt; | 213 | struct tape_class_device * rt; |
214 | 214 | ||
215 | /* Device mutex to serialize tape commands. */ | ||
216 | struct mutex mutex; | ||
217 | |||
215 | /* Device discipline information. */ | 218 | /* Device discipline information. */ |
216 | struct tape_discipline * discipline; | 219 | struct tape_discipline * discipline; |
217 | void * discdata; | 220 | void * discdata; |
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c index c97c6aac8ed5..4799cc2f73c3 100644 --- a/drivers/s390/char/tape_block.c +++ b/drivers/s390/char/tape_block.c | |||
@@ -54,7 +54,7 @@ static const struct block_device_operations tapeblock_fops = { | |||
54 | .owner = THIS_MODULE, | 54 | .owner = THIS_MODULE, |
55 | .open = tapeblock_open, | 55 | .open = tapeblock_open, |
56 | .release = tapeblock_release, | 56 | .release = tapeblock_release, |
57 | .locked_ioctl = tapeblock_ioctl, | 57 | .ioctl = tapeblock_ioctl, |
58 | .media_changed = tapeblock_medium_changed, | 58 | .media_changed = tapeblock_medium_changed, |
59 | .revalidate_disk = tapeblock_revalidate_disk, | 59 | .revalidate_disk = tapeblock_revalidate_disk, |
60 | }; | 60 | }; |
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 *); | |||
33 | static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *); | 33 | static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *); |
34 | static int tapechar_open(struct inode *,struct file *); | 34 | static int tapechar_open(struct inode *,struct file *); |
35 | static int tapechar_release(struct inode *,struct file *); | 35 | static int tapechar_release(struct inode *,struct file *); |
36 | static int tapechar_ioctl(struct inode *, struct file *, unsigned int, | 36 | static long tapechar_ioctl(struct file *, unsigned int, unsigned long); |
37 | unsigned long); | ||
38 | static long tapechar_compat_ioctl(struct file *, unsigned int, | 37 | static 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 | ||
305 | out: | ||
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 | */ |
352 | static int | 345 | static int |
353 | tapechar_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 | ||
454 | static long | 442 | static long |
443 | tapechar_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 | |||
457 | static long | ||
455 | tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data) | 458 | tapechar_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 | } |
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c index a7b7e72c691b..f5d6802dc5da 100644 --- a/drivers/s390/char/tape_core.c +++ b/drivers/s390/char/tape_core.c | |||
@@ -492,6 +492,7 @@ tape_alloc_device(void) | |||
492 | kfree(device); | 492 | kfree(device); |
493 | return ERR_PTR(-ENOMEM); | 493 | return ERR_PTR(-ENOMEM); |
494 | } | 494 | } |
495 | mutex_init(&device->mutex); | ||
495 | INIT_LIST_HEAD(&device->req_queue); | 496 | INIT_LIST_HEAD(&device->req_queue); |
496 | INIT_LIST_HEAD(&device->node); | 497 | INIT_LIST_HEAD(&device->node); |
497 | init_waitqueue_head(&device->state_change_wq); | 498 | init_waitqueue_head(&device->state_change_wq); |