aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:46 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:46 -0400
commitb788ee9c6561fd9219a503216284d61036a0dc0b (patch)
treed83198a6c1a38661e60ac7454d1d82889c0472b3
parent2298169418f43ba5e0919762a4bab95a1227872a (diff)
ide: use do_rw_taskfile() for ATA_CMD_PACKET commands
* Pass command to ide_issue_pc() and update ->do_request methods in ide-{cd,floppy,tape}.c accordingly. * Convert ide_pktcmd_tf_load() to ide_init_packet_cmd() which just initializes command structure and use do_rw_taskfile() to load ATA_CMD_PACKET commands. While at it: * Rename ide{floppy,tape}_issue_pc() to ide_{floppy,tape}_issue_pc(). There should be no functional changes caused by this patch. Acked-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-atapi.c37
-rw-r--r--drivers/ide/ide-cd.c11
-rw-r--r--drivers/ide/ide-floppy.c24
-rw-r--r--drivers/ide/ide-tape.c19
-rw-r--r--drivers/ide/ide-taskfile.c3
-rw-r--r--include/linux/ide.h2
6 files changed, 53 insertions, 43 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index b56af49f876b..75df05add1b9 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -487,23 +487,15 @@ next_irq:
487 return ide_started; 487 return ide_started;
488} 488}
489 489
490static void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount) 490static void ide_init_packet_cmd(struct ide_cmd *cmd, u32 tf_flags,
491 u16 bcount, u8 dma)
491{ 492{
492 ide_hwif_t *hwif = drive->hwif; 493 cmd->protocol = dma ? ATAPI_PROT_DMA : ATAPI_PROT_PIO;
493 struct ide_cmd cmd; 494 cmd->tf_flags |= IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM |
494 u8 dma = drive->dma; 495 IDE_TFLAG_OUT_FEATURE | tf_flags;
495 496 cmd->tf.feature = dma; /* Use PIO/DMA */
496 memset(&cmd, 0, sizeof(cmd)); 497 cmd->tf.lbam = bcount & 0xff;
497 cmd.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM | 498 cmd->tf.lbah = (bcount >> 8) & 0xff;
498 IDE_TFLAG_OUT_FEATURE | tf_flags;
499 cmd.tf.feature = dma; /* Use PIO/DMA */
500 cmd.tf.lbam = bcount & 0xff;
501 cmd.tf.lbah = (bcount >> 8) & 0xff;
502
503 ide_tf_dump(drive->name, &cmd.tf);
504 hwif->tp_ops->set_irq(hwif, 1);
505 SELECT_MASK(drive, 0);
506 hwif->tp_ops->tf_load(drive, &cmd);
507} 499}
508 500
509static u8 ide_read_ireason(ide_drive_t *drive) 501static u8 ide_read_ireason(ide_drive_t *drive)
@@ -634,24 +626,17 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
634 return ide_started; 626 return ide_started;
635} 627}
636 628
637ide_startstop_t ide_issue_pc(ide_drive_t *drive) 629ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
638{ 630{
639 struct ide_atapi_pc *pc; 631 struct ide_atapi_pc *pc;
640 ide_hwif_t *hwif = drive->hwif; 632 ide_hwif_t *hwif = drive->hwif;
641 const struct ide_dma_ops *dma_ops = hwif->dma_ops; 633 const struct ide_dma_ops *dma_ops = hwif->dma_ops;
642 struct ide_cmd *cmd = &hwif->cmd;
643 ide_expiry_t *expiry = NULL; 634 ide_expiry_t *expiry = NULL;
644 struct request *rq = hwif->rq; 635 struct request *rq = hwif->rq;
645 unsigned int timeout; 636 unsigned int timeout;
646 u32 tf_flags; 637 u32 tf_flags;
647 u16 bcount; 638 u16 bcount;
648 639
649 if (drive->media != ide_floppy) {
650 if (rq_data_dir(rq))
651 cmd->tf_flags |= IDE_TFLAG_WRITE;
652 cmd->rq = rq;
653 }
654
655 if (dev_is_idecd(drive)) { 640 if (dev_is_idecd(drive)) {
656 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; 641 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
657 bcount = ide_cd_get_xferlen(rq); 642 bcount = ide_cd_get_xferlen(rq);
@@ -696,7 +681,9 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
696 : WAIT_TAPE_CMD; 681 : WAIT_TAPE_CMD;
697 } 682 }
698 683
699 ide_pktcmd_tf_load(drive, tf_flags, bcount); 684 ide_init_packet_cmd(cmd, tf_flags, bcount, drive->dma);
685
686 (void)do_rw_taskfile(drive, cmd);
700 687
701 /* Issue the packet command */ 688 /* Issue the packet command */
702 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 689 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 2f698c6e913f..a6c847d31b9d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1066,6 +1066,8 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1066static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, 1066static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1067 sector_t block) 1067 sector_t block)
1068{ 1068{
1069 struct ide_cmd cmd;
1070
1069 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu", 1071 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu",
1070 rq->cmd[0], (unsigned long long)block); 1072 rq->cmd[0], (unsigned long long)block);
1071 1073
@@ -1094,7 +1096,14 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1094 return ide_stopped; 1096 return ide_stopped;
1095 } 1097 }
1096 1098
1097 return ide_issue_pc(drive); 1099 memset(&cmd, 0, sizeof(cmd));
1100
1101 if (rq_data_dir(rq))
1102 cmd.tf_flags |= IDE_TFLAG_WRITE;
1103
1104 cmd.rq = rq;
1105
1106 return ide_issue_pc(drive, &cmd);
1098} 1107}
1099 1108
1100/* 1109/*
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index ee3e77a7a727..f3ed5de3141b 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -130,8 +130,9 @@ static void ide_floppy_report_error(struct ide_disk_obj *floppy,
130 130
131} 131}
132 132
133static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, 133static ide_startstop_t ide_floppy_issue_pc(ide_drive_t *drive,
134 struct ide_atapi_pc *pc) 134 struct ide_cmd *cmd,
135 struct ide_atapi_pc *pc)
135{ 136{
136 struct ide_disk_obj *floppy = drive->driver_data; 137 struct ide_disk_obj *floppy = drive->driver_data;
137 138
@@ -157,7 +158,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
157 158
158 pc->retries++; 159 pc->retries++;
159 160
160 return ide_issue_pc(drive); 161 return ide_issue_pc(drive, cmd);
161} 162}
162 163
163void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) 164void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc)
@@ -244,7 +245,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
244{ 245{
245 struct ide_disk_obj *floppy = drive->driver_data; 246 struct ide_disk_obj *floppy = drive->driver_data;
246 ide_hwif_t *hwif = drive->hwif; 247 ide_hwif_t *hwif = drive->hwif;
247 struct ide_cmd *cmd = &hwif->cmd; 248 struct ide_cmd cmd;
248 struct ide_atapi_pc *pc; 249 struct ide_atapi_pc *pc;
249 250
250 if (drive->debug_mask & IDE_DBG_RQ) 251 if (drive->debug_mask & IDE_DBG_RQ)
@@ -285,21 +286,24 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
285 goto out_end; 286 goto out_end;
286 } 287 }
287 288
289 memset(&cmd, 0, sizeof(cmd));
290
288 if (rq_data_dir(rq)) 291 if (rq_data_dir(rq))
289 cmd->tf_flags |= IDE_TFLAG_WRITE; 292 cmd.tf_flags |= IDE_TFLAG_WRITE;
290 cmd->rq = rq; 293
294 cmd.rq = rq;
291 295
292 if (blk_fs_request(rq) || pc->req_xfer) { 296 if (blk_fs_request(rq) || pc->req_xfer) {
293 ide_init_sg_cmd(cmd, rq->nr_sectors); 297 ide_init_sg_cmd(&cmd, rq->nr_sectors);
294 ide_map_sg(drive, cmd); 298 ide_map_sg(drive, &cmd);
295 } 299 }
296 300
297 pc->sg = hwif->sg_table; 301 pc->sg = hwif->sg_table;
298 pc->sg_cnt = cmd->sg_nents; 302 pc->sg_cnt = cmd.sg_nents;
299 303
300 pc->rq = rq; 304 pc->rq = rq;
301 305
302 return idefloppy_issue_pc(drive, pc); 306 return ide_floppy_issue_pc(drive, &cmd, pc);
303out_end: 307out_end:
304 drive->failed_pc = NULL; 308 drive->failed_pc = NULL;
305 if (blk_fs_request(rq) == 0 && rq->errors == 0) 309 if (blk_fs_request(rq) == 0 && rq->errors == 0)
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 853d047aa78f..64dfa7458f8d 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -580,7 +580,7 @@ static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
580 * 580 *
581 * The handling will be done in three stages: 581 * The handling will be done in three stages:
582 * 582 *
583 * 1. idetape_issue_pc will send the packet command to the drive, and will set 583 * 1. ide_tape_issue_pc will send the packet command to the drive, and will set
584 * the interrupt handler to ide_pc_intr. 584 * the interrupt handler to ide_pc_intr.
585 * 585 *
586 * 2. On each interrupt, ide_pc_intr will be called. This step will be 586 * 2. On each interrupt, ide_pc_intr will be called. This step will be
@@ -608,8 +608,9 @@ static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
608 * request. 608 * request.
609 */ 609 */
610 610
611static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, 611static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
612 struct ide_atapi_pc *pc) 612 struct ide_cmd *cmd,
613 struct ide_atapi_pc *pc)
613{ 614{
614 idetape_tape_t *tape = drive->driver_data; 615 idetape_tape_t *tape = drive->driver_data;
615 616
@@ -654,7 +655,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
654 655
655 pc->retries++; 656 pc->retries++;
656 657
657 return ide_issue_pc(drive); 658 return ide_issue_pc(drive, cmd);
658} 659}
659 660
660/* A mode sense command is used to "sense" tape parameters. */ 661/* A mode sense command is used to "sense" tape parameters. */
@@ -749,6 +750,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
749 idetape_tape_t *tape = drive->driver_data; 750 idetape_tape_t *tape = drive->driver_data;
750 struct ide_atapi_pc *pc = NULL; 751 struct ide_atapi_pc *pc = NULL;
751 struct request *postponed_rq = tape->postponed_rq; 752 struct request *postponed_rq = tape->postponed_rq;
753 struct ide_cmd cmd;
752 u8 stat; 754 u8 stat;
753 755
754 debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu," 756 debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu,"
@@ -844,7 +846,14 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
844 BUG(); 846 BUG();
845 847
846out: 848out:
847 return idetape_issue_pc(drive, pc); 849 memset(&cmd, 0, sizeof(cmd));
850
851 if (rq_data_dir(rq))
852 cmd.tf_flags |= IDE_TFLAG_WRITE;
853
854 cmd.rq = rq;
855
856 return ide_tape_issue_pc(drive, &cmd, pc);
848} 857}
849 858
850/* 859/*
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 3b23bd11945e..63ab233ba942 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -100,13 +100,14 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
100 ide_execute_command(drive, tf->command, handler, 100 ide_execute_command(drive, tf->command, handler,
101 WAIT_WORSTCASE, NULL); 101 WAIT_WORSTCASE, NULL);
102 return ide_started; 102 return ide_started;
103 default: 103 case ATA_PROT_DMA:
104 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 || 104 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
105 ide_build_sglist(drive, cmd) == 0 || 105 ide_build_sglist(drive, cmd) == 0 ||
106 dma_ops->dma_setup(drive, cmd)) 106 dma_ops->dma_setup(drive, cmd))
107 return ide_stopped; 107 return ide_stopped;
108 dma_ops->dma_exec_cmd(drive, tf->command); 108 dma_ops->dma_exec_cmd(drive, tf->command);
109 dma_ops->dma_start(drive); 109 dma_ops->dma_start(drive);
110 default:
110 return ide_started; 111 return ide_started;
111 } 112 }
112} 113}
diff --git a/include/linux/ide.h b/include/linux/ide.h
index b30e79c6ff57..e339d6646552 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1226,7 +1226,7 @@ int ide_cd_expiry(ide_drive_t *);
1226 1226
1227int ide_cd_get_xferlen(struct request *); 1227int ide_cd_get_xferlen(struct request *);
1228 1228
1229ide_startstop_t ide_issue_pc(ide_drive_t *); 1229ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_cmd *);
1230 1230
1231ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *); 1231ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *);
1232 1232