diff options
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 118 |
1 files changed, 8 insertions, 110 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 1a7410f88249..cae69372cf45 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -239,7 +239,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
239 | 239 | ||
240 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) | 240 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) |
241 | { | 241 | { |
242 | struct request *rq = HWGROUP(drive)->rq; | 242 | struct request *rq = drive->hwif->rq; |
243 | int nsectors = rq->hard_cur_sectors; | 243 | int nsectors = rq->hard_cur_sectors; |
244 | 244 | ||
245 | ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, " | 245 | ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, " |
@@ -306,8 +306,7 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) | |||
306 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | 306 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) |
307 | { | 307 | { |
308 | ide_hwif_t *hwif = drive->hwif; | 308 | ide_hwif_t *hwif = drive->hwif; |
309 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 309 | struct request *rq = hwif->rq; |
310 | struct request *rq = hwgroup->rq; | ||
311 | int stat, err, sense_key; | 310 | int stat, err, sense_key; |
312 | 311 | ||
313 | /* check for errors */ | 312 | /* check for errors */ |
@@ -502,7 +501,7 @@ end_request: | |||
502 | blkdev_dequeue_request(rq); | 501 | blkdev_dequeue_request(rq); |
503 | spin_unlock_irqrestore(q->queue_lock, flags); | 502 | spin_unlock_irqrestore(q->queue_lock, flags); |
504 | 503 | ||
505 | hwgroup->rq = NULL; | 504 | hwif->rq = NULL; |
506 | 505 | ||
507 | cdrom_queue_request_sense(drive, rq->sense, rq); | 506 | cdrom_queue_request_sense(drive, rq->sense, rq); |
508 | } else | 507 | } else |
@@ -511,106 +510,6 @@ end_request: | |||
511 | return 1; | 510 | return 1; |
512 | } | 511 | } |
513 | 512 | ||
514 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *); | ||
515 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | ||
516 | |||
517 | /* | ||
518 | * Set up the device registers for transferring a packet command on DEV, | ||
519 | * expecting to later transfer XFERLEN bytes. HANDLER is the routine | ||
520 | * which actually transfers the command to the drive. If this is a | ||
521 | * drq_interrupt device, this routine will arrange for HANDLER to be | ||
522 | * called when the interrupt from the drive arrives. Otherwise, HANDLER | ||
523 | * will be called immediately after the drive is prepared for the transfer. | ||
524 | */ | ||
525 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive) | ||
526 | { | ||
527 | ide_hwif_t *hwif = drive->hwif; | ||
528 | struct request *rq = hwif->hwgroup->rq; | ||
529 | int xferlen; | ||
530 | |||
531 | xferlen = ide_cd_get_xferlen(rq); | ||
532 | |||
533 | ide_debug_log(IDE_DBG_PC, "Call %s, xferlen: %d\n", __func__, xferlen); | ||
534 | |||
535 | /* FIXME: for Virtual DMA we must check harder */ | ||
536 | if (drive->dma) | ||
537 | drive->dma = !hwif->dma_ops->dma_setup(drive); | ||
538 | |||
539 | /* set up the controller registers */ | ||
540 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL, | ||
541 | xferlen, drive->dma); | ||
542 | |||
543 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { | ||
544 | /* waiting for CDB interrupt, not DMA yet. */ | ||
545 | if (drive->dma) | ||
546 | drive->waiting_for_dma = 0; | ||
547 | |||
548 | /* packet command */ | ||
549 | ide_execute_command(drive, ATA_CMD_PACKET, | ||
550 | cdrom_transfer_packet_command, | ||
551 | ATAPI_WAIT_PC, ide_cd_expiry); | ||
552 | return ide_started; | ||
553 | } else { | ||
554 | ide_execute_pkt_cmd(drive); | ||
555 | |||
556 | return cdrom_transfer_packet_command(drive); | ||
557 | } | ||
558 | } | ||
559 | |||
560 | /* | ||
561 | * Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. The device | ||
562 | * registers must have already been prepared by cdrom_start_packet_command. | ||
563 | * HANDLER is the interrupt handler to call when the command completes or | ||
564 | * there's data ready. | ||
565 | */ | ||
566 | #define ATAPI_MIN_CDB_BYTES 12 | ||
567 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive) | ||
568 | { | ||
569 | ide_hwif_t *hwif = drive->hwif; | ||
570 | struct request *rq = hwif->hwgroup->rq; | ||
571 | int cmd_len; | ||
572 | ide_startstop_t startstop; | ||
573 | |||
574 | ide_debug_log(IDE_DBG_PC, "Call %s\n", __func__); | ||
575 | |||
576 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { | ||
577 | /* | ||
578 | * Here we should have been called after receiving an interrupt | ||
579 | * from the device. DRQ should how be set. | ||
580 | */ | ||
581 | |||
582 | /* check for errors */ | ||
583 | if (cdrom_decode_status(drive, ATA_DRQ, NULL)) | ||
584 | return ide_stopped; | ||
585 | |||
586 | /* ok, next interrupt will be DMA interrupt */ | ||
587 | if (drive->dma) | ||
588 | drive->waiting_for_dma = 1; | ||
589 | } else { | ||
590 | /* otherwise, we must wait for DRQ to get set */ | ||
591 | if (ide_wait_stat(&startstop, drive, ATA_DRQ, | ||
592 | ATA_BUSY, WAIT_READY)) | ||
593 | return startstop; | ||
594 | } | ||
595 | |||
596 | /* arm the interrupt handler */ | ||
597 | ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, ide_cd_expiry); | ||
598 | |||
599 | /* ATAPI commands get padded out to 12 bytes minimum */ | ||
600 | cmd_len = COMMAND_SIZE(rq->cmd[0]); | ||
601 | if (cmd_len < ATAPI_MIN_CDB_BYTES) | ||
602 | cmd_len = ATAPI_MIN_CDB_BYTES; | ||
603 | |||
604 | /* send the command to the device */ | ||
605 | hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len); | ||
606 | |||
607 | /* start the DMA if need be */ | ||
608 | if (drive->dma) | ||
609 | hwif->dma_ops->dma_start(drive); | ||
610 | |||
611 | return ide_started; | ||
612 | } | ||
613 | |||
614 | /* | 513 | /* |
615 | * Check the contents of the interrupt reason register from the cdrom | 514 | * Check the contents of the interrupt reason register from the cdrom |
616 | * and attempt to recover if there are problems. Returns 0 if everything's | 515 | * and attempt to recover if there are problems. Returns 0 if everything's |
@@ -854,8 +753,7 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq) | |||
854 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | 753 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) |
855 | { | 754 | { |
856 | ide_hwif_t *hwif = drive->hwif; | 755 | ide_hwif_t *hwif = drive->hwif; |
857 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 756 | struct request *rq = hwif->rq; |
858 | struct request *rq = hwgroup->rq; | ||
859 | xfer_func_t *xferfunc; | 757 | xfer_func_t *xferfunc; |
860 | ide_expiry_t *expiry = NULL; | 758 | ide_expiry_t *expiry = NULL; |
861 | int dma_error = 0, dma, stat, thislen, uptodate = 0; | 759 | int dma_error = 0, dma, stat, thislen, uptodate = 0; |
@@ -1061,7 +959,7 @@ end_request: | |||
1061 | if (blk_end_request(rq, 0, dlen)) | 959 | if (blk_end_request(rq, 0, dlen)) |
1062 | BUG(); | 960 | BUG(); |
1063 | 961 | ||
1064 | hwgroup->rq = NULL; | 962 | hwif->rq = NULL; |
1065 | } else { | 963 | } else { |
1066 | if (!uptodate) | 964 | if (!uptodate) |
1067 | rq->cmd_flags |= REQ_FAILED; | 965 | rq->cmd_flags |= REQ_FAILED; |
@@ -1183,7 +1081,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
1183 | return ide_stopped; | 1081 | return ide_stopped; |
1184 | } | 1082 | } |
1185 | 1083 | ||
1186 | return cdrom_start_packet_command(drive); | 1084 | return ide_issue_pc(drive); |
1187 | } | 1085 | } |
1188 | 1086 | ||
1189 | /* | 1087 | /* |
@@ -1916,7 +1814,7 @@ static void ide_cd_release(struct kref *kref) | |||
1916 | 1814 | ||
1917 | static int ide_cd_probe(ide_drive_t *); | 1815 | static int ide_cd_probe(ide_drive_t *); |
1918 | 1816 | ||
1919 | static ide_driver_t ide_cdrom_driver = { | 1817 | static struct ide_driver ide_cdrom_driver = { |
1920 | .gen_driver = { | 1818 | .gen_driver = { |
1921 | .owner = THIS_MODULE, | 1819 | .owner = THIS_MODULE, |
1922 | .name = "ide-cdrom", | 1820 | .name = "ide-cdrom", |
@@ -1927,7 +1825,6 @@ static ide_driver_t ide_cdrom_driver = { | |||
1927 | .version = IDECD_VERSION, | 1825 | .version = IDECD_VERSION, |
1928 | .do_request = ide_cd_do_request, | 1826 | .do_request = ide_cd_do_request, |
1929 | .end_request = ide_end_request, | 1827 | .end_request = ide_end_request, |
1930 | .error = __ide_error, | ||
1931 | #ifdef CONFIG_IDE_PROC_FS | 1828 | #ifdef CONFIG_IDE_PROC_FS |
1932 | .proc_entries = ide_cd_proc_entries, | 1829 | .proc_entries = ide_cd_proc_entries, |
1933 | .proc_devsets = ide_cd_proc_devsets, | 1830 | .proc_devsets = ide_cd_proc_devsets, |
@@ -2082,6 +1979,7 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2082 | } | 1979 | } |
2083 | 1980 | ||
2084 | drive->debug_mask = debug_mask; | 1981 | drive->debug_mask = debug_mask; |
1982 | drive->irq_handler = cdrom_newpc_intr; | ||
2085 | 1983 | ||
2086 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); | 1984 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); |
2087 | if (info == NULL) { | 1985 | if (info == NULL) { |