aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-cd.c49
1 files changed, 11 insertions, 38 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 34981f578e26..1a7410f88249 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -511,6 +511,9 @@ end_request:
511 return 1; 511 return 1;
512} 512}
513 513
514static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *);
515static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
516
514/* 517/*
515 * Set up the device registers for transferring a packet command on DEV, 518 * Set up the device registers for transferring a packet command on DEV,
516 * expecting to later transfer XFERLEN bytes. HANDLER is the routine 519 * expecting to later transfer XFERLEN bytes. HANDLER is the routine
@@ -519,8 +522,7 @@ end_request:
519 * called when the interrupt from the drive arrives. Otherwise, HANDLER 522 * called when the interrupt from the drive arrives. Otherwise, HANDLER
520 * will be called immediately after the drive is prepared for the transfer. 523 * will be called immediately after the drive is prepared for the transfer.
521 */ 524 */
522static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, 525static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive)
523 ide_handler_t *handler)
524{ 526{
525 ide_hwif_t *hwif = drive->hwif; 527 ide_hwif_t *hwif = drive->hwif;
526 struct request *rq = hwif->hwgroup->rq; 528 struct request *rq = hwif->hwgroup->rq;
@@ -544,13 +546,14 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
544 drive->waiting_for_dma = 0; 546 drive->waiting_for_dma = 0;
545 547
546 /* packet command */ 548 /* packet command */
547 ide_execute_command(drive, ATA_CMD_PACKET, handler, 549 ide_execute_command(drive, ATA_CMD_PACKET,
550 cdrom_transfer_packet_command,
548 ATAPI_WAIT_PC, ide_cd_expiry); 551 ATAPI_WAIT_PC, ide_cd_expiry);
549 return ide_started; 552 return ide_started;
550 } else { 553 } else {
551 ide_execute_pkt_cmd(drive); 554 ide_execute_pkt_cmd(drive);
552 555
553 return (*handler) (drive); 556 return cdrom_transfer_packet_command(drive);
554 } 557 }
555} 558}
556 559
@@ -561,11 +564,10 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
561 * there's data ready. 564 * there's data ready.
562 */ 565 */
563#define ATAPI_MIN_CDB_BYTES 12 566#define ATAPI_MIN_CDB_BYTES 12
564static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, 567static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive)
565 struct request *rq,
566 ide_handler_t *handler)
567{ 568{
568 ide_hwif_t *hwif = drive->hwif; 569 ide_hwif_t *hwif = drive->hwif;
570 struct request *rq = hwif->hwgroup->rq;
569 int cmd_len; 571 int cmd_len;
570 ide_startstop_t startstop; 572 ide_startstop_t startstop;
571 573
@@ -592,7 +594,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
592 } 594 }
593 595
594 /* arm the interrupt handler */ 596 /* arm the interrupt handler */
595 ide_set_handler(drive, handler, rq->timeout, ide_cd_expiry); 597 ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, ide_cd_expiry);
596 598
597 /* ATAPI commands get padded out to 12 bytes minimum */ 599 /* ATAPI commands get padded out to 12 bytes minimum */
598 cmd_len = COMMAND_SIZE(rq->cmd[0]); 600 cmd_len = COMMAND_SIZE(rq->cmd[0]);
@@ -680,8 +682,6 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
680 return 1; 682 return 1;
681} 683}
682 684
683static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
684
685static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, 685static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
686 struct request *rq) 686 struct request *rq)
687{ 687{
@@ -724,20 +724,6 @@ static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
724} 724}
725 725
726/* 726/*
727 * Routine to send a read/write packet command to the drive. This is usually
728 * called directly from cdrom_start_{read,write}(). However, for drq_interrupt
729 * devices, it is called from an interrupt when the drive is ready to accept
730 * the command.
731 */
732static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
733{
734 struct request *rq = drive->hwif->hwgroup->rq;
735
736 /* send the command to the drive and return */
737 return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
738}
739
740/*
741 * Fix up a possibly partially-processed request so that we can start it over 727 * Fix up a possibly partially-processed request so that we can start it over
742 * entirely, or even put it back on the request queue. 728 * entirely, or even put it back on the request queue.
743 */ 729 */
@@ -1126,13 +1112,6 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
1126 return ide_started; 1112 return ide_started;
1127} 1113}
1128 1114
1129static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive)
1130{
1131 struct request *rq = HWGROUP(drive)->rq;
1132
1133 return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
1134}
1135
1136static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) 1115static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1137{ 1116{
1138 1117
@@ -1177,16 +1156,12 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1177static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, 1156static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1178 sector_t block) 1157 sector_t block)
1179{ 1158{
1180 ide_handler_t *fn;
1181
1182 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, " 1159 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, "
1183 "rq->cmd_type: 0x%x, block: %llu\n", 1160 "rq->cmd_type: 0x%x, block: %llu\n",
1184 __func__, rq->cmd[0], rq->cmd_type, 1161 __func__, rq->cmd[0], rq->cmd_type,
1185 (unsigned long long)block); 1162 (unsigned long long)block);
1186 1163
1187 if (blk_fs_request(rq)) { 1164 if (blk_fs_request(rq)) {
1188 fn = cdrom_start_rw_cont;
1189
1190 if (cdrom_start_rw(drive, rq) == ide_stopped) 1165 if (cdrom_start_rw(drive, rq) == ide_stopped)
1191 return ide_stopped; 1166 return ide_stopped;
1192 1167
@@ -1194,8 +1169,6 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1194 return ide_stopped; 1169 return ide_stopped;
1195 } else if (blk_sense_request(rq) || blk_pc_request(rq) || 1170 } else if (blk_sense_request(rq) || blk_pc_request(rq) ||
1196 rq->cmd_type == REQ_TYPE_ATA_PC) { 1171 rq->cmd_type == REQ_TYPE_ATA_PC) {
1197 fn = cdrom_do_newpc_cont;
1198
1199 if (!rq->timeout) 1172 if (!rq->timeout)
1200 rq->timeout = ATAPI_WAIT_PC; 1173 rq->timeout = ATAPI_WAIT_PC;
1201 1174
@@ -1210,7 +1183,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1210 return ide_stopped; 1183 return ide_stopped;
1211 } 1184 }
1212 1185
1213 return cdrom_start_packet_command(drive, fn); 1186 return cdrom_start_packet_command(drive);
1214} 1187}
1215 1188
1216/* 1189/*