From: Borislav Petkov <petkovbb@googlemail.com>
To: bzolnier@gmail.com
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 03/15] ide-atapi: switch to rq->resid_len
Date: Fri, 15 May 2009 07:11:21 +0200 [thread overview]
Message-ID: <1242364293-29223-4-git-send-email-petkovbb@gmail.com> (raw)
In-Reply-To: <1242364293-29223-1-git-send-email-petkovbb@gmail.com>
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>
---
drivers/ide/ide-atapi.c | 19 ++++++++-----------
drivers/ide/ide-tape.c | 12 +++++-------
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 7129495..1022e42 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)
unsigned int cmd_len, sense_len;
int err;
- debug_log("%s: enter\n", __func__);
-
switch (drive->media) {
case ide_floppy:
cmd_len = 255;
@@ -370,7 +368,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
? "write" : "read");
pc->flags |= PC_FLAG_DMA_ERROR;
} else
- pc->xferred = blk_rq_bytes(rq);
+ rq->resid_len = 0;
debug_log("%s: DMA finished\n", drive->name);
}
@@ -379,7 +377,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
int uptodate, error;
debug_log("Packet command completed, %d bytes transferred\n",
- pc->xferred);
+ blk_rq_bytes(rq));
pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
@@ -467,15 +465,15 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
ide_pio_bytes(drive, cmd, write, done);
/* Update transferred byte count */
- pc->xferred += done;
+ rq->resid_len -= done;
bcount -= done;
if (bcount)
ide_pad_transfer(drive, write, bcount);
- debug_log("[cmd %x] transferred %d bytes, padded %d bytes\n",
- rq->cmd[0], done, bcount);
+ debug_log("[cmd %x] transferred %d bytes, padded %d bytes, resid: %u\n",
+ rq->cmd[0], done, bcount, rq->resid_len);
/* And set the interrupt handler again */
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)
} else {
pc = drive->pc;
- /* We haven't transferred any data yet */
- pc->xferred = 0;
-
valid_tf = IDE_VALID_DEVICE;
bytes = blk_rq_bytes(rq);
-
bcount = ((drive->media == ide_tape) ? bytes
: min_t(unsigned int,
bytes, 63 * 1024));
+ /* We haven't transferred any data yet */
+ rq->resid_len = bcount;
+
if (pc->flags & PC_FLAG_DMA_ERROR) {
pc->flags &= ~PC_FLAG_DMA_ERROR;
ide_dma_off(drive);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index aaeef12..c933709 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)
debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n",
pc->c[0], tape->sense_key, tape->asc, tape->ascq);
- /* Correct pc->xferred by asking the tape. */
+ /* correct remaining bytes to transfer */
if (pc->flags & PC_FLAG_DMA_ERROR)
- pc->xferred = blk_rq_bytes(rq) -
- tape->blk_size *
- get_unaligned_be32(&sense[3]);
+ rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]);
/*
* 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)
pc->flags |= PC_FLAG_ABORT;
}
if (!(pc->flags & PC_FLAG_ABORT) &&
- pc->xferred)
+ (blk_rq_bytes(rq) - rq->resid_len))
pc->retries = IDETAPE_MAX_PC_RETRIES + 1;
}
}
@@ -369,7 +367,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
"itself - Aborting request!\n");
} else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
- int blocks = pc->xferred / tape->blk_size;
+ unsigned int blocks =
+ (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size;
tape->avg_size += blocks * tape->blk_size;
@@ -381,7 +380,6 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
}
tape->first_frame += blocks;
- rq->resid_len = blk_rq_bytes(rq) - blocks * tape->blk_size;
if (pc->error) {
uptodate = 0;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 34c128f..745a393 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -357,8 +357,6 @@ struct ide_atapi_pc {
/* bytes to transfer */
int req_xfer;
- /* bytes actually transferred */
- int xferred;
/* data buffer */
u8 *buf;
--
1.6.3
next prev parent reply other threads:[~2009-05-15 5:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-15 5:11 [PATCH 0/15 v2] ide-atapi: remove pc->buf and misc cleanups Borislav Petkov
2009-05-15 5:11 ` [PATCH 01/15] ide-tape: fix potential fs requests bug Borislav Petkov
2009-05-15 5:11 ` [PATCH 02/15] ide-atapi: switch to blk_rq_bytes() on do_request() path Borislav Petkov
2009-05-15 5:11 ` Borislav Petkov [this message]
2009-05-15 5:11 ` [PATCH 04/15] ide-atapi: add a len-parameter to ide_queue_pc_tail Borislav Petkov
2009-05-15 5:11 ` [PATCH 05/15] ide-atapi: add a buffer-arg " Borislav Petkov
2009-05-15 5:11 ` [PATCH 06/15] ide-floppy/ide_floppy_get_flexible_disk_page: use local buffer Borislav Petkov
2009-05-15 5:11 ` [PATCH 07/15] ide-floppy/ide_floppy_get_sfrp_bit: " Borislav Petkov
2009-05-15 5:11 ` [PATCH 08/15] ide-floppy/ide_floppy_format_unit: " Borislav Petkov
2009-05-15 5:11 ` [PATCH 09/15] ide-atapi: use local sense buffer Borislav Petkov
2009-05-15 5:11 ` [PATCH 10/15] ide-floppy/ide_floppy_get_format_progress: " Borislav Petkov
2009-05-15 5:11 ` [PATCH 11/15] ide-tape/ide_tape_get_bsize_from_bdesc: use local buffer Borislav Petkov
2009-05-15 5:11 ` [PATCH 12/15] ide-tape: fix READ POSITION cmd handling Borislav Petkov
2009-05-15 5:11 ` [PATCH 13/15] ide-atapi: remove pc->buf Borislav Petkov
2009-05-15 5:11 ` [PATCH 14/15] ide-cd: use whole request_sense buffer in EH Borislav Petkov
2009-05-15 5:11 ` [PATCH 15/15] ide: unify interrupt reason checking Borislav Petkov
2009-05-16 19:07 ` [PATCH 0/15 v2] ide-atapi: remove pc->buf and misc cleanups Bartlomiej Zolnierkiewicz
2009-05-16 19:23 ` Borislav Petkov
2009-05-16 19:35 ` Bartlomiej Zolnierkiewicz
2009-05-17 10:33 ` Borislav Petkov
2009-05-17 13:12 ` Bartlomiej Zolnierkiewicz
2009-05-16 22:08 ` Tejun Heo
2009-05-17 10:26 ` Borislav Petkov
2009-05-17 10:36 ` Bartlomiej Zolnierkiewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1242364293-29223-4-git-send-email-petkovbb@gmail.com \
--to=petkovbb@googlemail.com \
--cc=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).