diff options
author | Borislav Petkov <petkovbb@gmail.com> | 2009-05-01 15:21:02 -0400 |
---|---|---|
committer | Borislav Petkov <petkovbb@gmail.com> | 2009-05-15 00:44:02 -0400 |
commit | 077e6dba20e74a455a0452379d2a965c7e1b01ad (patch) | |
tree | 66b4a755d6e5941578d5a14b778b0734273343c5 | |
parent | dfb7e621fa12c0579e88560ab176c5768f9e0bfb (diff) |
ide-atapi: switch to rq->resid_len
Now that we have rq->resid_len, use it to account partial completion
amount during the lifetime of an rq, decrementing it on each successful
transfer. As a result, get rid of now unused pc->xferred.
While at it, remove noisy debug call in ide_prep_sense.
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
-rw-r--r-- | drivers/ide/ide-atapi.c | 19 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 12 | ||||
-rw-r--r-- | include/linux/ide.h | 2 |
3 files changed, 13 insertions, 20 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 7129495b3e40..1022e421abd8 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -172,8 +172,6 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) | |||
172 | unsigned int cmd_len, sense_len; | 172 | unsigned int cmd_len, sense_len; |
173 | int err; | 173 | int err; |
174 | 174 | ||
175 | debug_log("%s: enter\n", __func__); | ||
176 | |||
177 | switch (drive->media) { | 175 | switch (drive->media) { |
178 | case ide_floppy: | 176 | case ide_floppy: |
179 | cmd_len = 255; | 177 | cmd_len = 255; |
@@ -370,7 +368,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
370 | ? "write" : "read"); | 368 | ? "write" : "read"); |
371 | pc->flags |= PC_FLAG_DMA_ERROR; | 369 | pc->flags |= PC_FLAG_DMA_ERROR; |
372 | } else | 370 | } else |
373 | pc->xferred = blk_rq_bytes(rq); | 371 | rq->resid_len = 0; |
374 | debug_log("%s: DMA finished\n", drive->name); | 372 | debug_log("%s: DMA finished\n", drive->name); |
375 | } | 373 | } |
376 | 374 | ||
@@ -379,7 +377,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
379 | int uptodate, error; | 377 | int uptodate, error; |
380 | 378 | ||
381 | debug_log("Packet command completed, %d bytes transferred\n", | 379 | debug_log("Packet command completed, %d bytes transferred\n", |
382 | pc->xferred); | 380 | blk_rq_bytes(rq)); |
383 | 381 | ||
384 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | 382 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; |
385 | 383 | ||
@@ -467,15 +465,15 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
467 | ide_pio_bytes(drive, cmd, write, done); | 465 | ide_pio_bytes(drive, cmd, write, done); |
468 | 466 | ||
469 | /* Update transferred byte count */ | 467 | /* Update transferred byte count */ |
470 | pc->xferred += done; | 468 | rq->resid_len -= done; |
471 | 469 | ||
472 | bcount -= done; | 470 | bcount -= done; |
473 | 471 | ||
474 | if (bcount) | 472 | if (bcount) |
475 | ide_pad_transfer(drive, write, bcount); | 473 | ide_pad_transfer(drive, write, bcount); |
476 | 474 | ||
477 | debug_log("[cmd %x] transferred %d bytes, padded %d bytes\n", | 475 | debug_log("[cmd %x] transferred %d bytes, padded %d bytes, resid: %u\n", |
478 | rq->cmd[0], done, bcount); | 476 | rq->cmd[0], done, bcount, rq->resid_len); |
479 | 477 | ||
480 | /* And set the interrupt handler again */ | 478 | /* And set the interrupt handler again */ |
481 | ide_set_handler(drive, ide_pc_intr, timeout); | 479 | ide_set_handler(drive, ide_pc_intr, timeout); |
@@ -643,16 +641,15 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd) | |||
643 | } else { | 641 | } else { |
644 | pc = drive->pc; | 642 | pc = drive->pc; |
645 | 643 | ||
646 | /* We haven't transferred any data yet */ | ||
647 | pc->xferred = 0; | ||
648 | |||
649 | valid_tf = IDE_VALID_DEVICE; | 644 | valid_tf = IDE_VALID_DEVICE; |
650 | bytes = blk_rq_bytes(rq); | 645 | bytes = blk_rq_bytes(rq); |
651 | |||
652 | bcount = ((drive->media == ide_tape) ? bytes | 646 | bcount = ((drive->media == ide_tape) ? bytes |
653 | : min_t(unsigned int, | 647 | : min_t(unsigned int, |
654 | bytes, 63 * 1024)); | 648 | bytes, 63 * 1024)); |
655 | 649 | ||
650 | /* We haven't transferred any data yet */ | ||
651 | rq->resid_len = bcount; | ||
652 | |||
656 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 653 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
657 | pc->flags &= ~PC_FLAG_DMA_ERROR; | 654 | pc->flags &= ~PC_FLAG_DMA_ERROR; |
658 | ide_dma_off(drive); | 655 | ide_dma_off(drive); |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index aaeef12f80ad..c93370997972 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -301,11 +301,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
301 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", | 301 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", |
302 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); | 302 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); |
303 | 303 | ||
304 | /* Correct pc->xferred by asking the tape. */ | 304 | /* correct remaining bytes to transfer */ |
305 | if (pc->flags & PC_FLAG_DMA_ERROR) | 305 | if (pc->flags & PC_FLAG_DMA_ERROR) |
306 | pc->xferred = blk_rq_bytes(rq) - | 306 | rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); |
307 | tape->blk_size * | ||
308 | get_unaligned_be32(&sense[3]); | ||
309 | 307 | ||
310 | /* | 308 | /* |
311 | * If error was the result of a zero-length read or write command, | 309 | * If error was the result of a zero-length read or write command, |
@@ -339,7 +337,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
339 | pc->flags |= PC_FLAG_ABORT; | 337 | pc->flags |= PC_FLAG_ABORT; |
340 | } | 338 | } |
341 | if (!(pc->flags & PC_FLAG_ABORT) && | 339 | if (!(pc->flags & PC_FLAG_ABORT) && |
342 | pc->xferred) | 340 | (blk_rq_bytes(rq) - rq->resid_len)) |
343 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; | 341 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; |
344 | } | 342 | } |
345 | } | 343 | } |
@@ -369,7 +367,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
369 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " | 367 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " |
370 | "itself - Aborting request!\n"); | 368 | "itself - Aborting request!\n"); |
371 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | 369 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
372 | int blocks = pc->xferred / tape->blk_size; | 370 | unsigned int blocks = |
371 | (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size; | ||
373 | 372 | ||
374 | tape->avg_size += blocks * tape->blk_size; | 373 | tape->avg_size += blocks * tape->blk_size; |
375 | 374 | ||
@@ -381,7 +380,6 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
381 | } | 380 | } |
382 | 381 | ||
383 | tape->first_frame += blocks; | 382 | tape->first_frame += blocks; |
384 | rq->resid_len = blk_rq_bytes(rq) - blocks * tape->blk_size; | ||
385 | 383 | ||
386 | if (pc->error) { | 384 | if (pc->error) { |
387 | uptodate = 0; | 385 | uptodate = 0; |
diff --git a/include/linux/ide.h b/include/linux/ide.h index 34c128f0a33c..745a393af278 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -357,8 +357,6 @@ struct ide_atapi_pc { | |||
357 | 357 | ||
358 | /* bytes to transfer */ | 358 | /* bytes to transfer */ |
359 | int req_xfer; | 359 | int req_xfer; |
360 | /* bytes actually transferred */ | ||
361 | int xferred; | ||
362 | 360 | ||
363 | /* data buffer */ | 361 | /* data buffer */ |
364 | u8 *buf; | 362 | u8 *buf; |