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 | |
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>
-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 | ||||
-rw-r--r-- | drivers/scsi/ide-scsi.c | 30 | ||||
-rw-r--r-- | include/linux/ide.h | 2 |
5 files changed, 57 insertions, 89 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. */ |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index b7c5e8391575..32415466fbfe 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -502,38 +502,12 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, | |||
502 | struct ide_atapi_pc *pc) | 502 | struct ide_atapi_pc *pc) |
503 | { | 503 | { |
504 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); | 504 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); |
505 | ide_hwif_t *hwif = drive->hwif; | ||
506 | u16 bcount; | ||
507 | u8 dma = 0; | ||
508 | 505 | ||
509 | /* Set the current packet command */ | 506 | /* Set the current packet command */ |
510 | scsi->pc = pc; | 507 | scsi->pc = pc; |
511 | /* We haven't transferred any data yet */ | ||
512 | pc->xferred = 0; | ||
513 | pc->cur_pos = pc->buf; | ||
514 | /* Request to transfer the entire buffer at once */ | ||
515 | bcount = min(pc->req_xfer, 63 * 1024); | ||
516 | |||
517 | if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) { | ||
518 | hwif->sg_mapped = 1; | ||
519 | dma = !hwif->dma_ops->dma_setup(drive); | ||
520 | hwif->sg_mapped = 0; | ||
521 | } | ||
522 | |||
523 | if (!dma) | ||
524 | pc->flags &= ~PC_FLAG_DMA_OK; | ||
525 | 508 | ||
526 | ide_pktcmd_tf_load(drive, 0, bcount, dma); | 509 | return ide_issue_pc(drive, pc, idescsi_transfer_pc, |
527 | 510 | get_timeout(pc), idescsi_expiry); | |
528 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | ||
529 | ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc, | ||
530 | get_timeout(pc), idescsi_expiry); | ||
531 | return ide_started; | ||
532 | } else { | ||
533 | /* Issue the packet command */ | ||
534 | ide_execute_pkt_cmd(drive); | ||
535 | return idescsi_transfer_pc(drive); | ||
536 | } | ||
537 | } | 511 | } |
538 | 512 | ||
539 | /* | 513 | /* |
diff --git a/include/linux/ide.h b/include/linux/ide.h index c2274ad44b2e..fee07a7edb19 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -970,6 +970,8 @@ void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); | |||
970 | 970 | ||
971 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, | 971 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, |
972 | ide_handler_t *, unsigned int, ide_expiry_t *); | 972 | ide_handler_t *, unsigned int, ide_expiry_t *); |
973 | ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *, | ||
974 | ide_handler_t *, unsigned int, ide_expiry_t *); | ||
973 | 975 | ||
974 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); | 976 | ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); |
975 | 977 | ||