Lines Matching defs:cd
147 struct scsi_cd *cd = dev_get_drvdata(dev);
149 if (!cd) /* E.g.: runtime suspend following sr_remove() */
152 if (cd->media_present)
208 struct scsi_cd *cd = cdi->handle;
218 events = sr_get_events(cd->device);
219 cd->get_event_changed |= events & DISK_EVENT_MEDIA_CHANGE;
227 if (cd->ignore_get_event) {
237 if (cd->device->changed) {
239 cd->device->changed = 0;
240 cd->tur_changed = true;
247 last_present = cd->media_present;
248 ret = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
255 cd->media_present = scsi_status_is_good(ret) ||
258 if (last_present != cd->media_present)
259 cd->device->changed = 1;
261 if (cd->device->changed) {
263 cd->device->changed = 0;
264 cd->tur_changed = true;
267 if (cd->ignore_get_event)
271 if (!cd->tur_changed) {
272 if (cd->get_event_changed) {
273 if (cd->tur_mismatch++ > 8) {
274 sr_printk(KERN_WARNING, cd,
276 cd->ignore_get_event = true;
279 cd->tur_mismatch = 0;
282 cd->tur_changed = false;
283 cd->get_event_changed = false;
302 struct scsi_cd *cd = scsi_cd(rq->q->disk);
328 if (cd->device->sector_size == 2048)
342 if (error_sector < get_capacity(cd->disk) &&
343 cd->capacity - error_sector < 4 * 75)
344 set_capacity(cd->disk, error_sector);
362 struct scsi_cd *cd;
369 cd = scsi_cd(rq->q->disk);
374 if (!cd->device || !scsi_device_online(cd->device)) {
382 if (cd->device->changed) {
390 s_size = cd->device->sector_size;
398 if (!cd->writeable)
401 cd->cdi.media_written = 1;
462 SCpnt->transfersize = cd->device->sector_size;
476 static int sr_revalidate_disk(struct scsi_cd *cd)
481 if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
483 sr_cd_check(&cd->cdi);
484 return get_sectorsize(cd);
489 struct scsi_cd *cd = scsi_cd(disk);
490 struct scsi_device *sdev = cd->device;
493 if (scsi_device_get(cd->device))
498 ret = sr_revalidate_disk(cd);
503 mutex_lock(&cd->lock);
504 ret = cdrom_open(&cd->cdi, mode);
505 mutex_unlock(&cd->lock);
509 scsi_device_put(cd->device);
515 struct scsi_cd *cd = scsi_cd(disk);
517 mutex_lock(&cd->lock);
518 cdrom_release(&cd->cdi);
519 mutex_unlock(&cd->lock);
521 scsi_device_put(cd->device);
527 struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
528 struct scsi_device *sdev = cd->device;
535 mutex_lock(&cd->lock);
545 ret = cdrom_ioctl(&cd->cdi, bdev, cmd, arg);
554 mutex_unlock(&cd->lock);
561 struct scsi_cd *cd = disk->private_data;
563 if (atomic_read(&cd->device->disk_events_disable_depth))
565 return cdrom_check_events(&cd->cdi, clearing);
570 struct scsi_cd *cd = disk->private_data;
576 unregister_cdrom(&cd->cdi);
577 mutex_destroy(&cd->lock);
578 kfree(cd);
594 struct scsi_cd *cd = cdi->handle;
595 struct scsi_device *sdev = cd->device;
615 struct scsi_cd *cd;
624 cd = kzalloc(sizeof(*cd), GFP_KERNEL);
625 if (!cd)
632 mutex_init(&cd->lock);
656 cd->device = sdev;
657 cd->disk = disk;
658 cd->capacity = 0x1fffff;
659 cd->device->changed = 1; /* force recheck CD type */
660 cd->media_present = 1;
661 cd->use = 1;
662 cd->readcd_known = 0;
663 cd->readcd_cdda = 0;
665 cd->cdi.ops = &sr_dops;
666 cd->cdi.handle = cd;
667 cd->cdi.mask = 0;
668 cd->cdi.capacity = 1;
669 sprintf(cd->cdi.name, "sr%d", minor);
674 if (get_capabilities(cd))
676 sr_vendor_init(cd);
678 set_capacity(disk, cd->capacity);
679 disk->private_data = cd;
681 if (register_cdrom(disk, &cd->cdi))
690 dev_set_drvdata(dev, cd);
691 error = sr_revalidate_disk(cd);
700 "Attached scsi CD-ROM %s\n", cd->cdi.name);
701 scsi_autopm_put_device(cd->device);
706 unregister_cdrom(&cd->cdi);
713 mutex_destroy(&cd->lock);
715 kfree(cd);
722 static int get_sectorsize(struct scsi_cd *cd)
724 struct request_queue *q = cd->device->request_queue;
745 err = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, buffer,
749 cd->capacity = 0x1fffff;
754 cd->capacity = 1 + get_unaligned_be32(&buffer[0]);
762 if (!cdrom_get_last_written(&cd->cdi, &last_written))
763 cd->capacity = max_t(long, cd->capacity, last_written);
779 cd->capacity *= 4;
784 sr_printk(KERN_INFO, cd,
786 cd->capacity = 0;
789 cd->device->sector_size = sector_size;
795 set_capacity(cd->disk, cd->capacity);
803 static int get_capabilities(struct scsi_cd *cd)
827 sr_printk(KERN_ERR, cd, "out of memory.\n");
832 scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
835 rc = scsi_mode_sense(cd->device, 0, 0x2a, 0, buffer, ms_len,
841 cd->cdi.speed = 1;
842 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
847 sr_printk(KERN_INFO, cd, "scsi-1 drive");
852 cd->cdi.speed = get_unaligned_be16(&buffer[n + 8]) / 176;
853 cd->readcd_known = 1;
854 cd->readcd_cdda = buffer[n + 5] & 0x01;
856 sr_printk(KERN_INFO, cd,
859 cd->cdi.speed,
862 buffer[n + 2] & 0x02 ? "cd/rw " : "", /* can read rewriteable */
868 cd->cdi.mask |= CDC_CLOSE_TRAY;
871 cd->cdi.mask |= CDC_DVD;
874 cd->cdi.mask |= CDC_DVD_RAM;
877 cd->cdi.mask |= CDC_DVD_R;
880 cd->cdi.mask |= CDC_CD_RW;
883 cd->cdi.mask |= CDC_CD_R;
886 cd->cdi.mask |= CDC_OPEN_TRAY;
890 cd->cdi.capacity =
891 cdrom_number_of_slots(&cd->cdi);
892 if (cd->cdi.capacity <= 1)
894 cd->cdi.mask |= CDC_SELECT_DISC;
896 cd->cdi.mask |= CDC_CLOSE_TRAY; */
901 if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
903 cd->writeable = 1;
917 struct scsi_cd *cd = cdi->handle;
918 struct scsi_device *sdev = cd->device;
926 sr_do_ioctl(cd, cgc);
983 struct scsi_cd *cd = dev_get_drvdata(dev);
985 scsi_autopm_get_device(cd->device);
987 del_gendisk(cd->disk);
988 put_disk(cd->disk);