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 void 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 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 sr_revalidate_disk(cd);
500 mutex_lock(&cd->lock);
501 ret = cdrom_open(&cd->cdi, mode);
502 mutex_unlock(&cd->lock);
506 scsi_device_put(cd->device);
512 struct scsi_cd *cd = scsi_cd(disk);
514 mutex_lock(&cd->lock);
515 cdrom_release(&cd->cdi);
516 mutex_unlock(&cd->lock);
518 scsi_device_put(cd->device);
524 struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
525 struct scsi_device *sdev = cd->device;
532 mutex_lock(&cd->lock);
542 ret = cdrom_ioctl(&cd->cdi, bdev, cmd, arg);
551 mutex_unlock(&cd->lock);
558 struct scsi_cd *cd = disk->private_data;
560 if (atomic_read(&cd->device->disk_events_disable_depth))
562 return cdrom_check_events(&cd->cdi, clearing);
567 struct scsi_cd *cd = disk->private_data;
573 unregister_cdrom(&cd->cdi);
574 mutex_destroy(&cd->lock);
575 kfree(cd);
591 struct scsi_cd *cd = cdi->handle;
592 struct scsi_device *sdev = cd->device;
612 struct scsi_cd *cd;
621 cd = kzalloc(sizeof(*cd), GFP_KERNEL);
622 if (!cd)
629 mutex_init(&cd->lock);
653 cd->device = sdev;
654 cd->disk = disk;
655 cd->capacity = 0x1fffff;
656 cd->device->changed = 1; /* force recheck CD type */
657 cd->media_present = 1;
658 cd->use = 1;
659 cd->readcd_known = 0;
660 cd->readcd_cdda = 0;
662 cd->cdi.ops = &sr_dops;
663 cd->cdi.handle = cd;
664 cd->cdi.mask = 0;
665 cd->cdi.capacity = 1;
666 sprintf(cd->cdi.name, "sr%d", minor);
671 if (get_capabilities(cd))
673 sr_vendor_init(cd);
675 set_capacity(disk, cd->capacity);
676 disk->private_data = cd;
678 if (register_cdrom(disk, &cd->cdi))
687 dev_set_drvdata(dev, cd);
688 sr_revalidate_disk(cd);
695 "Attached scsi CD-ROM %s\n", cd->cdi.name);
696 scsi_autopm_put_device(cd->device);
701 unregister_cdrom(&cd->cdi);
708 mutex_destroy(&cd->lock);
710 kfree(cd);
717 static void get_sectorsize(struct scsi_cd *cd)
739 the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, buffer,
743 cd->capacity = 0x1fffff;
748 cd->capacity = 1 + get_unaligned_be32(&buffer[0]);
756 if (!cdrom_get_last_written(&cd->cdi, &last_written))
757 cd->capacity = max_t(long, cd->capacity, last_written);
773 cd->capacity *= 4;
778 sr_printk(KERN_INFO, cd,
780 cd->capacity = 0;
783 cd->device->sector_size = sector_size;
789 set_capacity(cd->disk, cd->capacity);
792 queue = cd->device->request_queue;
798 static int get_capabilities(struct scsi_cd *cd)
822 sr_printk(KERN_ERR, cd, "out of memory.\n");
827 scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
830 rc = scsi_mode_sense(cd->device, 0, 0x2a, 0, buffer, ms_len,
836 cd->cdi.speed = 1;
837 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
842 sr_printk(KERN_INFO, cd, "scsi-1 drive");
847 cd->cdi.speed = get_unaligned_be16(&buffer[n + 8]) / 176;
848 cd->readcd_known = 1;
849 cd->readcd_cdda = buffer[n + 5] & 0x01;
851 sr_printk(KERN_INFO, cd,
854 cd->cdi.speed,
857 buffer[n + 2] & 0x02 ? "cd/rw " : "", /* can read rewriteable */
863 cd->cdi.mask |= CDC_CLOSE_TRAY;
866 cd->cdi.mask |= CDC_DVD;
869 cd->cdi.mask |= CDC_DVD_RAM;
872 cd->cdi.mask |= CDC_DVD_R;
875 cd->cdi.mask |= CDC_CD_RW;
878 cd->cdi.mask |= CDC_CD_R;
881 cd->cdi.mask |= CDC_OPEN_TRAY;
885 cd->cdi.capacity =
886 cdrom_number_of_slots(&cd->cdi);
887 if (cd->cdi.capacity <= 1)
889 cd->cdi.mask |= CDC_SELECT_DISC;
891 cd->cdi.mask |= CDC_CLOSE_TRAY; */
896 if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
898 cd->writeable = 1;
912 struct scsi_cd *cd = cdi->handle;
913 struct scsi_device *sdev = cd->device;
921 sr_do_ioctl(cd, cgc);
978 struct scsi_cd *cd = dev_get_drvdata(dev);
980 scsi_autopm_get_device(cd->device);
982 del_gendisk(cd->disk);
983 put_disk(cd->disk);