vserver 1.9.3
[linux-2.6.git] / drivers / scsi / sr.c
index b80aa28..b6c76b5 100644 (file)
@@ -140,15 +140,13 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk)
        if (disk->private_data == NULL)
                goto out;
        cd = scsi_cd(disk);
-       if (!kref_get(&cd->kref))
-               goto out_null;
+       kref_get(&cd->kref);
        if (scsi_device_get(cd->device))
                goto out_put;
        goto out;
 
  out_put:
-       kref_put(&cd->kref);
- out_null:
+       kref_put(&cd->kref, sr_kref_release);
        cd = NULL;
  out:
        up(&sr_ref_sem);
@@ -159,7 +157,7 @@ static inline void scsi_cd_put(struct scsi_cd *cd)
 {
        down(&sr_ref_sem);
        scsi_device_put(cd->device);
-       kref_put(&cd->kref);
+       kref_put(&cd->kref, sr_kref_release);
        up(&sr_ref_sem);
 }
 
@@ -183,7 +181,7 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot)
                return -EINVAL;
        }
 
-       retval = scsi_ioctl(cd->device, SCSI_IOCTL_TEST_UNIT_READY, NULL);
+       retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES);
        if (retval) {
                /* Unable to test, unit probably not ready.  This usually
                 * means there is no disc in the drive.  Mark as changed,
@@ -576,7 +574,7 @@ static int sr_probe(struct device *dev)
                goto fail;
        memset(cd, 0, sizeof(*cd));
 
-       kref_init(&cd->kref, sr_kref_release);
+       kref_init(&cd->kref);
 
        disk = alloc_disk(1);
        if (!disk)
@@ -937,7 +935,7 @@ static int sr_remove(struct device *dev)
        del_gendisk(cd->disk);
 
        down(&sr_ref_sem);
-       kref_put(&cd->kref);
+       kref_put(&cd->kref, sr_kref_release);
        up(&sr_ref_sem);
 
        return 0;