aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r--drivers/scsi/sr.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 0f17009c99d..62b6633e3a9 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -471,38 +471,31 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
471 return scsi_prep_return(q, rq, ret); 471 return scsi_prep_return(q, rq, ret);
472} 472}
473 473
474static int sr_block_open(struct inode *inode, struct file *file) 474static int sr_block_open(struct block_device *bdev, fmode_t mode)
475{ 475{
476 struct gendisk *disk = inode->i_bdev->bd_disk; 476 struct scsi_cd *cd = scsi_cd_get(bdev->bd_disk);
477 struct scsi_cd *cd; 477 int ret = -ENXIO;
478 int ret = 0;
479
480 if(!(cd = scsi_cd_get(disk)))
481 return -ENXIO;
482
483 if((ret = cdrom_open(&cd->cdi, inode, file)) != 0)
484 scsi_cd_put(cd);
485 478
479 if (cd) {
480 ret = cdrom_open(&cd->cdi, bdev, mode);
481 if (ret)
482 scsi_cd_put(cd);
483 }
486 return ret; 484 return ret;
487} 485}
488 486
489static int sr_block_release(struct inode *inode, struct file *file) 487static int sr_block_release(struct gendisk *disk, fmode_t mode)
490{ 488{
491 int ret; 489 struct scsi_cd *cd = scsi_cd(disk);
492 struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); 490 cdrom_release(&cd->cdi, mode);
493 ret = cdrom_release(&cd->cdi, file);
494 if(ret)
495 return ret;
496
497 scsi_cd_put(cd); 491 scsi_cd_put(cd);
498
499 return 0; 492 return 0;
500} 493}
501 494
502static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, 495static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
503 unsigned long arg) 496 unsigned long arg)
504{ 497{
505 struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); 498 struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
506 struct scsi_device *sdev = cd->device; 499 struct scsi_device *sdev = cd->device;
507 void __user *argp = (void __user *)arg; 500 void __user *argp = (void __user *)arg;
508 int ret; 501 int ret;
@@ -517,7 +510,7 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
517 return scsi_ioctl(sdev, cmd, argp); 510 return scsi_ioctl(sdev, cmd, argp);
518 } 511 }
519 512
520 ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); 513 ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg);
521 if (ret != -ENOSYS) 514 if (ret != -ENOSYS)
522 return ret; 515 return ret;
523 516
@@ -527,7 +520,8 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
527 * case fall through to scsi_ioctl, which will return ENDOEV again 520 * case fall through to scsi_ioctl, which will return ENDOEV again
528 * if it doesn't recognise the ioctl 521 * if it doesn't recognise the ioctl
529 */ 522 */
530 ret = scsi_nonblockable_ioctl(sdev, cmd, argp, NULL); 523 ret = scsi_nonblockable_ioctl(sdev, cmd, argp,
524 (mode & FMODE_NDELAY_NOW) != 0);
531 if (ret != -ENODEV) 525 if (ret != -ENODEV)
532 return ret; 526 return ret;
533 return scsi_ioctl(sdev, cmd, argp); 527 return scsi_ioctl(sdev, cmd, argp);
@@ -544,7 +538,7 @@ static struct block_device_operations sr_bdops =
544 .owner = THIS_MODULE, 538 .owner = THIS_MODULE,
545 .open = sr_block_open, 539 .open = sr_block_open,
546 .release = sr_block_release, 540 .release = sr_block_release,
547 .ioctl = sr_block_ioctl, 541 .locked_ioctl = sr_block_ioctl,
548 .media_changed = sr_block_media_changed, 542 .media_changed = sr_block_media_changed,
549 /* 543 /*
550 * No compat_ioctl for now because sr_block_ioctl never 544 * No compat_ioctl for now because sr_block_ioctl never