diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-15 15:22:00 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-15 15:22:00 -0400 |
commit | 6bf1641ca1c7554f0da54aaf89788731b541bacc (patch) | |
tree | ce7c371971e68b650d87e67935e460c948f4cb20 /drivers/ide | |
parent | 28c7214bd8c2bbd4873b8f1e7f58d86d3731124f (diff) |
ide: add ide_issue_pc() helper
Add generic ide_issue_pc() helper to ide-atapi.c and then
convert ide-{floppy,tape,scsi} device drivers to use it.
There should be no functional changes caused by this patch.
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-atapi.c | 49 | ||||
-rw-r--r-- | drivers/ide/ide-floppy.c | 35 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 30 |
3 files changed, 53 insertions, 61 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 25939bc60402..932a83abaf06 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -68,3 +68,52 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
68 | return ide_started; | 68 | return ide_started; |
69 | } | 69 | } |
70 | EXPORT_SYMBOL_GPL(ide_transfer_pc); | 70 | EXPORT_SYMBOL_GPL(ide_transfer_pc); |
71 | |||
72 | ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
73 | ide_handler_t *handler, unsigned int timeout, | ||
74 | ide_expiry_t *expiry) | ||
75 | { | ||
76 | ide_hwif_t *hwif = drive->hwif; | ||
77 | u16 bcount; | ||
78 | u8 dma = 0; | ||
79 | |||
80 | /* We haven't transferred any data yet */ | ||
81 | pc->xferred = 0; | ||
82 | pc->cur_pos = pc->buf; | ||
83 | |||
84 | /* Request to transfer the entire buffer at once */ | ||
85 | if (drive->media == ide_tape && !drive->scsi) | ||
86 | bcount = pc->req_xfer; | ||
87 | else | ||
88 | bcount = min(pc->req_xfer, 63 * 1024); | ||
89 | |||
90 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
91 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
92 | ide_dma_off(drive); | ||
93 | } | ||
94 | |||
95 | if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) { | ||
96 | if (drive->scsi) | ||
97 | hwif->sg_mapped = 1; | ||
98 | dma = !hwif->dma_ops->dma_setup(drive); | ||
99 | if (drive->scsi) | ||
100 | hwif->sg_mapped = 0; | ||
101 | } | ||
102 | |||
103 | if (!dma) | ||
104 | pc->flags &= ~PC_FLAG_DMA_OK; | ||
105 | |||
106 | ide_pktcmd_tf_load(drive, drive->scsi ? 0 : IDE_TFLAG_OUT_DEVICE, | ||
107 | bcount, dma); | ||
108 | |||
109 | /* Issue the packet command */ | ||
110 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | ||
111 | ide_execute_command(drive, WIN_PACKETCMD, handler, | ||
112 | timeout, NULL); | ||
113 | return ide_started; | ||
114 | } else { | ||
115 | ide_execute_pkt_cmd(drive); | ||
116 | return (*handler)(drive); | ||
117 | } | ||
118 | } | ||
119 | EXPORT_SYMBOL_GPL(ide_issue_pc); | ||
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 13f650fa2125..e658aafc51da 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -576,9 +576,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
576 | struct ide_atapi_pc *pc) | 576 | struct ide_atapi_pc *pc) |
577 | { | 577 | { |
578 | idefloppy_floppy_t *floppy = drive->driver_data; | 578 | idefloppy_floppy_t *floppy = drive->driver_data; |
579 | ide_hwif_t *hwif = drive->hwif; | ||
580 | u16 bcount; | ||
581 | u8 dma; | ||
582 | 579 | ||
583 | if (floppy->failed_pc == NULL && | 580 | if (floppy->failed_pc == NULL && |
584 | pc->c[0] != GPCMD_REQUEST_SENSE) | 581 | pc->c[0] != GPCMD_REQUEST_SENSE) |
@@ -600,37 +597,9 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
600 | debug_log("Retry number - %d\n", pc->retries); | 597 | debug_log("Retry number - %d\n", pc->retries); |
601 | 598 | ||
602 | pc->retries++; | 599 | pc->retries++; |
603 | /* We haven't transferred any data yet */ | ||
604 | pc->xferred = 0; | ||
605 | pc->cur_pos = pc->buf; | ||
606 | bcount = min(pc->req_xfer, 63 * 1024); | ||
607 | |||
608 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
609 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
610 | ide_dma_off(drive); | ||
611 | } | ||
612 | dma = 0; | ||
613 | 600 | ||
614 | if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) | 601 | return ide_issue_pc(drive, pc, idefloppy_transfer_pc1, |
615 | dma = !hwif->dma_ops->dma_setup(drive); | 602 | IDEFLOPPY_WAIT_CMD, NULL); |
616 | |||
617 | if (!dma) | ||
618 | pc->flags &= ~PC_FLAG_DMA_OK; | ||
619 | |||
620 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_DEVICE, bcount, dma); | ||
621 | |||
622 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | ||
623 | /* Issue the packet command */ | ||
624 | ide_execute_command(drive, WIN_PACKETCMD, | ||
625 | &idefloppy_transfer_pc1, | ||
626 | IDEFLOPPY_WAIT_CMD, | ||
627 | NULL); | ||
628 | return ide_started; | ||
629 | } else { | ||
630 | /* Issue the packet command */ | ||
631 | ide_execute_pkt_cmd(drive); | ||
632 | return idefloppy_transfer_pc1(drive); | ||
633 | } | ||
634 | } | 603 | } |
635 | 604 | ||
636 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) | 605 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index cba18a675506..7907a1e41918 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -958,10 +958,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
958 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | 958 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, |
959 | struct ide_atapi_pc *pc) | 959 | struct ide_atapi_pc *pc) |
960 | { | 960 | { |
961 | ide_hwif_t *hwif = drive->hwif; | ||
962 | idetape_tape_t *tape = drive->driver_data; | 961 | idetape_tape_t *tape = drive->driver_data; |
963 | int dma_ok = 0; | ||
964 | u16 bcount; | ||
965 | 962 | ||
966 | if (tape->pc->c[0] == REQUEST_SENSE && | 963 | if (tape->pc->c[0] == REQUEST_SENSE && |
967 | pc->c[0] == REQUEST_SENSE) { | 964 | pc->c[0] == REQUEST_SENSE) { |
@@ -1002,32 +999,9 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
1002 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 999 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
1003 | 1000 | ||
1004 | pc->retries++; | 1001 | pc->retries++; |
1005 | /* We haven't transferred any data yet */ | ||
1006 | pc->xferred = 0; | ||
1007 | pc->cur_pos = pc->buf; | ||
1008 | /* Request to transfer the entire buffer at once */ | ||
1009 | bcount = pc->req_xfer; | ||
1010 | |||
1011 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
1012 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
1013 | ide_dma_off(drive); | ||
1014 | } | ||
1015 | if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) | ||
1016 | dma_ok = !hwif->dma_ops->dma_setup(drive); | ||
1017 | |||
1018 | if (!dma_ok) | ||
1019 | pc->flags &= ~PC_FLAG_DMA_OK; | ||
1020 | |||
1021 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); | ||
1022 | 1002 | ||
1023 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | 1003 | return ide_issue_pc(drive, pc, idetape_transfer_pc, |
1024 | ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc, | 1004 | IDETAPE_WAIT_CMD, NULL); |
1025 | IDETAPE_WAIT_CMD, NULL); | ||
1026 | return ide_started; | ||
1027 | } else { | ||
1028 | ide_execute_pkt_cmd(drive); | ||
1029 | return idetape_transfer_pc(drive); | ||
1030 | } | ||
1031 | } | 1005 | } |
1032 | 1006 | ||
1033 | /* A mode sense command is used to "sense" tape parameters. */ | 1007 | /* A mode sense command is used to "sense" tape parameters. */ |