Lines Matching refs:cd

148 	struct scsi_cd *cd = dev_get_drvdata(dev);
150 if (!cd) /* E.g.: runtime suspend following sr_remove() */
153 if (cd->media_present)
209 struct scsi_cd *cd = cdi->handle;
219 events = sr_get_events(cd->device);
220 cd->get_event_changed |= events & DISK_EVENT_MEDIA_CHANGE;
228 if (cd->ignore_get_event) {
238 if (cd->device->changed) {
240 cd->device->changed = 0;
241 cd->tur_changed = true;
248 last_present = cd->media_present;
249 ret = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
256 cd->media_present = scsi_status_is_good(ret) ||
259 if (last_present != cd->media_present)
260 cd->device->changed = 1;
262 if (cd->device->changed) {
264 cd->device->changed = 0;
265 cd->tur_changed = true;
268 if (cd->ignore_get_event)
272 if (!cd->tur_changed) {
273 if (cd->get_event_changed) {
274 if (cd->tur_mismatch++ > 8) {
275 sr_printk(KERN_WARNING, cd,
277 cd->ignore_get_event = true;
280 cd->tur_mismatch = 0;
283 cd->tur_changed = false;
284 cd->get_event_changed = false;
303 struct scsi_cd *cd = scsi_cd(rq->q->disk);
329 if (cd->device->sector_size == 2048)
343 if (error_sector < get_capacity(cd->disk) &&
344 cd->capacity - error_sector < 4 * 75)
345 set_capacity(cd->disk, error_sector);
363 struct scsi_cd *cd;
370 cd = scsi_cd(rq->q->disk);
375 if (!cd->device || !scsi_device_online(cd->device)) {
383 if (cd->device->changed) {
391 s_size = cd->device->sector_size;
399 if (!cd->writeable)
402 cd->cdi.media_written = 1;
463 SCpnt->transfersize = cd->device->sector_size;
477 static void sr_revalidate_disk(struct scsi_cd *cd)
482 if (scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
484 sr_cd_check(&cd->cdi);
485 get_sectorsize(cd);
490 struct scsi_cd *cd = scsi_cd(disk);
491 struct scsi_device *sdev = cd->device;
494 if (scsi_device_get(cd->device))
499 sr_revalidate_disk(cd);
501 mutex_lock(&cd->lock);
502 ret = cdrom_open(&cd->cdi, mode);
503 mutex_unlock(&cd->lock);
507 scsi_device_put(cd->device);
513 struct scsi_cd *cd = scsi_cd(disk);
515 mutex_lock(&cd->lock);
516 cdrom_release(&cd->cdi);
517 mutex_unlock(&cd->lock);
519 scsi_device_put(cd->device);
525 struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
526 struct scsi_device *sdev = cd->device;
533 mutex_lock(&cd->lock);
543 ret = cdrom_ioctl(&cd->cdi, bdev, cmd, arg);
552 mutex_unlock(&cd->lock);
559 struct scsi_cd *cd = disk->private_data;
561 if (atomic_read(&cd->device->disk_events_disable_depth))
563 return cdrom_check_events(&cd->cdi, clearing);
568 struct scsi_cd *cd = disk->private_data;
574 unregister_cdrom(&cd->cdi);
575 mutex_destroy(&cd->lock);
576 kfree(cd);
592 struct scsi_cd *cd = cdi->handle;
593 struct scsi_device *sdev = cd->device;
613 struct scsi_cd *cd;
622 cd = kzalloc(sizeof(*cd), GFP_KERNEL);
623 if (!cd)
630 mutex_init(&cd->lock);
654 cd->device = sdev;
655 cd->disk = disk;
656 cd->capacity = 0x1fffff;
657 cd->device->changed = 1; /* force recheck CD type */
658 cd->media_present = 1;
659 cd->use = 1;
660 cd->readcd_known = 0;
661 cd->readcd_cdda = 0;
663 cd->cdi.ops = &sr_dops;
664 cd->cdi.handle = cd;
665 cd->cdi.mask = 0;
666 cd->cdi.capacity = 1;
667 sprintf(cd->cdi.name, "sr%d", minor);
672 if (get_capabilities(cd))
674 sr_vendor_init(cd);
676 set_capacity(disk, cd->capacity);
677 disk->private_data = cd;
679 if (register_cdrom(disk, &cd->cdi))
688 dev_set_drvdata(dev, cd);
689 sr_revalidate_disk(cd);
696 "Attached scsi CD-ROM %s\n", cd->cdi.name);
697 scsi_autopm_put_device(cd->device);
702 unregister_cdrom(&cd->cdi);
709 mutex_destroy(&cd->lock);
711 kfree(cd);
718 static void get_sectorsize(struct scsi_cd *cd)
740 the_result = scsi_execute_cmd(cd->device, cmd, REQ_OP_DRV_IN, buffer,
744 cd->capacity = 0x1fffff;
749 cd->capacity = 1 + get_unaligned_be32(&buffer[0]);
757 if (!cdrom_get_last_written(&cd->cdi, &last_written))
758 cd->capacity = max_t(long, cd->capacity, last_written);
774 cd->capacity *= 4;
779 sr_printk(KERN_INFO, cd,
781 cd->capacity = 0;
784 cd->device->sector_size = sector_size;
790 set_capacity(cd->disk, cd->capacity);
793 queue = cd->device->request_queue;
799 static int get_capabilities(struct scsi_cd *cd)
823 sr_printk(KERN_ERR, cd, "out of memory.\n");
828 scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
831 rc = scsi_mode_sense(cd->device, 0, 0x2a, 0, buffer, ms_len,
837 cd->cdi.speed = 1;
838 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
843 sr_printk(KERN_INFO, cd, "scsi-1 drive");
848 cd->cdi.speed = get_unaligned_be16(&buffer[n + 8]) / 176;
849 cd->readcd_known = 1;
850 cd->readcd_cdda = buffer[n + 5] & 0x01;
852 sr_printk(KERN_INFO, cd,
855 cd->cdi.speed,
858 buffer[n + 2] & 0x02 ? "cd/rw " : "", /* can read rewriteable */
864 cd->cdi.mask |= CDC_CLOSE_TRAY;
867 cd->cdi.mask |= CDC_DVD;
870 cd->cdi.mask |= CDC_DVD_RAM;
873 cd->cdi.mask |= CDC_DVD_R;
876 cd->cdi.mask |= CDC_CD_RW;
879 cd->cdi.mask |= CDC_CD_R;
882 cd->cdi.mask |= CDC_OPEN_TRAY;
886 cd->cdi.capacity =
887 cdrom_number_of_slots(&cd->cdi);
888 if (cd->cdi.capacity <= 1)
890 cd->cdi.mask |= CDC_SELECT_DISC;
892 cd->cdi.mask |= CDC_CLOSE_TRAY; */
897 if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
899 cd->writeable = 1;
913 struct scsi_cd *cd = cdi->handle;
914 struct scsi_device *sdev = cd->device;
922 sr_do_ioctl(cd, cgc);
979 struct scsi_cd *cd = dev_get_drvdata(dev);
981 scsi_autopm_get_device(cd->device);
983 del_gendisk(cd->disk);
984 put_disk(cd->disk);