diff options
author | Borislav Petkov <petkovbb@gmail.com> | 2009-05-01 14:35:21 -0400 |
---|---|---|
committer | Borislav Petkov <petkovbb@gmail.com> | 2009-05-15 00:43:59 -0400 |
commit | dfb7e621fa12c0579e88560ab176c5768f9e0bfb (patch) | |
tree | 9a0fc84735ee3290c366b4244763013ba07bcdd7 /drivers/ide | |
parent | 10c0b3437c4dc0d14ac254bbe71e54ea5f238d97 (diff) |
ide-atapi: switch to blk_rq_bytes() on do_request() path
After the recent struct request cleanups, blk_rq_bytes() is guaranteed
to be valid and is the current total length of the rq's bio. Use that
instead of pc->req_xfer in the do_request() path after the command has
been queued
The remaining usage of pc->req_xfer now is only until we map the rq to a
bio.
While at it:
- remove local caching of rq completion length in ide_tape_issue_pc()
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-atapi.c | 12 | ||||
-rw-r--r-- | drivers/ide/ide-floppy.c | 8 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 14 |
3 files changed, 18 insertions, 16 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 8a894fa37b53..7129495b3e40 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -370,7 +370,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
370 | ? "write" : "read"); | 370 | ? "write" : "read"); |
371 | pc->flags |= PC_FLAG_DMA_ERROR; | 371 | pc->flags |= PC_FLAG_DMA_ERROR; |
372 | } else | 372 | } else |
373 | pc->xferred = pc->req_xfer; | 373 | pc->xferred = blk_rq_bytes(rq); |
374 | debug_log("%s: DMA finished\n", drive->name); | 374 | debug_log("%s: DMA finished\n", drive->name); |
375 | } | 375 | } |
376 | 376 | ||
@@ -627,7 +627,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd) | |||
627 | ide_hwif_t *hwif = drive->hwif; | 627 | ide_hwif_t *hwif = drive->hwif; |
628 | ide_expiry_t *expiry = NULL; | 628 | ide_expiry_t *expiry = NULL; |
629 | struct request *rq = hwif->rq; | 629 | struct request *rq = hwif->rq; |
630 | unsigned int timeout; | 630 | unsigned int timeout, bytes; |
631 | u16 bcount; | 631 | u16 bcount; |
632 | u8 valid_tf; | 632 | u8 valid_tf; |
633 | u8 drq_int = !!(drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT); | 633 | u8 drq_int = !!(drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT); |
@@ -647,9 +647,11 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd) | |||
647 | pc->xferred = 0; | 647 | pc->xferred = 0; |
648 | 648 | ||
649 | valid_tf = IDE_VALID_DEVICE; | 649 | valid_tf = IDE_VALID_DEVICE; |
650 | bcount = ((drive->media == ide_tape) ? | 650 | bytes = blk_rq_bytes(rq); |
651 | pc->req_xfer : | 651 | |
652 | min(pc->req_xfer, 63 * 1024)); | 652 | bcount = ((drive->media == ide_tape) ? bytes |
653 | : min_t(unsigned int, | ||
654 | bytes, 63 * 1024)); | ||
653 | 655 | ||
654 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 656 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
655 | pc->flags &= ~PC_FLAG_DMA_ERROR; | 657 | pc->flags &= ~PC_FLAG_DMA_ERROR; |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 650981758f15..a1c55985d4ae 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -210,7 +210,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive, | |||
210 | if (rq->cmd_flags & REQ_RW) | 210 | if (rq->cmd_flags & REQ_RW) |
211 | pc->flags |= PC_FLAG_WRITING; | 211 | pc->flags |= PC_FLAG_WRITING; |
212 | pc->buf = NULL; | 212 | pc->buf = NULL; |
213 | pc->req_xfer = pc->buf_size = blocks * floppy->block_size; | 213 | pc->buf_size = blk_rq_bytes(rq); |
214 | pc->flags |= PC_FLAG_DMA_OK; | 214 | pc->flags |= PC_FLAG_DMA_OK; |
215 | } | 215 | } |
216 | 216 | ||
@@ -227,7 +227,7 @@ static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy, | |||
227 | } | 227 | } |
228 | /* pio will be performed by ide_pio_bytes() which handles sg fine */ | 228 | /* pio will be performed by ide_pio_bytes() which handles sg fine */ |
229 | pc->buf = NULL; | 229 | pc->buf = NULL; |
230 | pc->req_xfer = pc->buf_size = blk_rq_bytes(rq); | 230 | pc->buf_size = blk_rq_bytes(rq); |
231 | } | 231 | } |
232 | 232 | ||
233 | static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | 233 | static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, |
@@ -286,8 +286,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
286 | 286 | ||
287 | cmd.rq = rq; | 287 | cmd.rq = rq; |
288 | 288 | ||
289 | if (blk_fs_request(rq) || pc->req_xfer) { | 289 | if (blk_fs_request(rq) || blk_rq_bytes(rq)) { |
290 | ide_init_sg_cmd(&cmd, pc->req_xfer); | 290 | ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); |
291 | ide_map_sg(drive, &cmd); | 291 | ide_map_sg(drive, &cmd); |
292 | } | 292 | } |
293 | 293 | ||
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index fc79cf4812f3..aaeef12f80ad 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -292,6 +292,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
292 | { | 292 | { |
293 | idetape_tape_t *tape = drive->driver_data; | 293 | idetape_tape_t *tape = drive->driver_data; |
294 | struct ide_atapi_pc *pc = drive->failed_pc; | 294 | struct ide_atapi_pc *pc = drive->failed_pc; |
295 | struct request *rq = drive->hwif->rq; | ||
295 | 296 | ||
296 | tape->sense_key = sense[2] & 0xF; | 297 | tape->sense_key = sense[2] & 0xF; |
297 | tape->asc = sense[12]; | 298 | tape->asc = sense[12]; |
@@ -302,7 +303,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
302 | 303 | ||
303 | /* Correct pc->xferred by asking the tape. */ | 304 | /* Correct pc->xferred by asking the tape. */ |
304 | if (pc->flags & PC_FLAG_DMA_ERROR) | 305 | if (pc->flags & PC_FLAG_DMA_ERROR) |
305 | pc->xferred = pc->req_xfer - | 306 | pc->xferred = blk_rq_bytes(rq) - |
306 | tape->blk_size * | 307 | tape->blk_size * |
307 | get_unaligned_be32(&sense[3]); | 308 | get_unaligned_be32(&sense[3]); |
308 | 309 | ||
@@ -484,6 +485,7 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
484 | struct ide_atapi_pc *pc) | 485 | struct ide_atapi_pc *pc) |
485 | { | 486 | { |
486 | idetape_tape_t *tape = drive->driver_data; | 487 | idetape_tape_t *tape = drive->driver_data; |
488 | struct request *rq = drive->hwif->rq; | ||
487 | 489 | ||
488 | if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) | 490 | if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) |
489 | drive->failed_pc = pc; | 491 | drive->failed_pc = pc; |
@@ -493,7 +495,6 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
493 | 495 | ||
494 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || | 496 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || |
495 | (pc->flags & PC_FLAG_ABORT)) { | 497 | (pc->flags & PC_FLAG_ABORT)) { |
496 | unsigned int done = blk_rq_bytes(drive->hwif->rq); | ||
497 | 498 | ||
498 | /* | 499 | /* |
499 | * We will "abort" retrying a packet command in case legitimate | 500 | * We will "abort" retrying a packet command in case legitimate |
@@ -517,7 +518,7 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
517 | 518 | ||
518 | drive->failed_pc = NULL; | 519 | drive->failed_pc = NULL; |
519 | drive->pc_callback(drive, 0); | 520 | drive->pc_callback(drive, 0); |
520 | ide_complete_rq(drive, -EIO, done); | 521 | ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); |
521 | return ide_stopped; | 522 | return ide_stopped; |
522 | } | 523 | } |
523 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 524 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
@@ -592,9 +593,8 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | |||
592 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 593 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
593 | pc->c[1] = 1; | 594 | pc->c[1] = 1; |
594 | pc->buf = NULL; | 595 | pc->buf = NULL; |
595 | pc->buf_size = length * tape->blk_size; | 596 | pc->buf_size = blk_rq_bytes(rq); |
596 | pc->req_xfer = pc->buf_size; | 597 | if (pc->buf_size == tape->buffer_size) |
597 | if (pc->req_xfer == tape->buffer_size) | ||
598 | pc->flags |= PC_FLAG_DMA_OK; | 598 | pc->flags |= PC_FLAG_DMA_OK; |
599 | 599 | ||
600 | if (opcode == READ_6) | 600 | if (opcode == READ_6) |
@@ -718,7 +718,7 @@ out: | |||
718 | 718 | ||
719 | cmd.rq = rq; | 719 | cmd.rq = rq; |
720 | 720 | ||
721 | ide_init_sg_cmd(&cmd, pc->req_xfer); | 721 | ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); |
722 | ide_map_sg(drive, &cmd); | 722 | ide_map_sg(drive, &cmd); |
723 | 723 | ||
724 | return ide_tape_issue_pc(drive, &cmd, pc); | 724 | return ide_tape_issue_pc(drive, &cmd, pc); |