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);
{
down(&sr_ref_sem);
scsi_device_put(cd->device);
- kref_put(&cd->kref);
+ kref_put(&cd->kref, sr_kref_release);
up(&sr_ref_sem);
}
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,
goto fail;
memset(cd, 0, sizeof(*cd));
- kref_init(&cd->kref, sr_kref_release);
+ kref_init(&cd->kref);
disk = alloc_disk(1);
if (!disk)
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;