diff options
author | James Bottomley <JBottomley@Parallels.com> | 2014-01-22 09:57:27 -0800 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2014-01-22 09:57:27 -0800 |
commit | 4b1a9a5e40210cb4a0687806d3b631f7db4b9b0e (patch) | |
tree | 4f33f3af2e1ff163c6f4a1022d1d6b6be7b11547 /drivers/scsi/sr.c | |
parent | dcaf9aed995c2b2a49fb86bbbcfa2f92c797ab5d (diff) | |
parent | 3ce438df106826edde7ad724f3819716a3f0cf56 (diff) |
Merge branch 'misc' into for-linus
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r-- | drivers/scsi/sr.c | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 119d67f9c47..40d85929aef 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -161,14 +161,10 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk) goto out; cd = scsi_cd(disk); kref_get(&cd->kref); - if (scsi_device_get(cd->device)) - goto out_put; - if (!scsi_autopm_get_device(cd->device)) - goto out; - - out_put: - kref_put(&cd->kref, sr_kref_release); - cd = NULL; + if (scsi_device_get(cd->device)) { + kref_put(&cd->kref, sr_kref_release); + cd = NULL; + } out: mutex_unlock(&sr_ref_mutex); return cd; @@ -180,7 +176,6 @@ static void scsi_cd_put(struct scsi_cd *cd) mutex_lock(&sr_ref_mutex); kref_put(&cd->kref, sr_kref_release); - scsi_autopm_put_device(sdev); scsi_device_put(sdev); mutex_unlock(&sr_ref_mutex); } @@ -558,8 +553,6 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, void __user *argp = (void __user *)arg; int ret; - scsi_autopm_get_device(cd->device); - mutex_lock(&sr_mutex); /* @@ -591,7 +584,6 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, out: mutex_unlock(&sr_mutex); - scsi_autopm_put_device(cd->device); return ret; } @@ -599,17 +591,11 @@ static unsigned int sr_block_check_events(struct gendisk *disk, unsigned int clearing) { struct scsi_cd *cd = scsi_cd(disk); - unsigned int ret; - if (atomic_read(&cd->device->disk_events_disable_depth) == 0) { - scsi_autopm_get_device(cd->device); - ret = cdrom_check_events(&cd->cdi, clearing); - scsi_autopm_put_device(cd->device); - } else { - ret = 0; - } + if (atomic_read(&cd->device->disk_events_disable_depth)) + return 0; - return ret; + return cdrom_check_events(&cd->cdi, clearing); } static int sr_block_revalidate_disk(struct gendisk *disk) @@ -617,8 +603,6 @@ static int sr_block_revalidate_disk(struct gendisk *disk) struct scsi_cd *cd = scsi_cd(disk); struct scsi_sense_hdr sshdr; - scsi_autopm_get_device(cd->device); - /* if the unit is not ready, nothing more to do */ if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr)) goto out; @@ -626,7 +610,6 @@ static int sr_block_revalidate_disk(struct gendisk *disk) sr_cd_check(&cd->cdi); get_sectorsize(cd); out: - scsi_autopm_put_device(cd->device); return 0; } @@ -747,6 +730,12 @@ static int sr_probe(struct device *dev) if (register_cdrom(&cd->cdi)) goto fail_put; + /* + * Initialize block layer runtime PM stuffs before the + * periodic event checking request gets started in add_disk. + */ + blk_pm_runtime_init(sdev->request_queue, dev); + dev_set_drvdata(dev, cd); disk->flags |= GENHD_FL_REMOVABLE; add_disk(disk); |