From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 58/63] ide-cd: prepare cdrom_rw_intr() and cdrom_newpc_intr() to be merged
Date: Thu, 20 Dec 2007 02:36:41 +0100 [thread overview]
Message-ID: <200712200236.41270.bzolnier@gmail.com> (raw)
In cdrom_newpc_intr():
* cleanup variables in the 'transfer data' loop
In cdrom_rw_intr():
* rename 'sectors_to_transfer' to 'thislen'
* rename 'this_transfer' to 'blen'
* keep number of bytes (instead of sectors) in 'thislen' and 'blen'
* call 'xferfunc' only once for 'blen'
* cache 'rq->buffer' in 'ptr' variable
* check for 'rq->bio' before setting 'ptr' and 'blen'
* check for 'ptr' instead of 'rq->current_nr_sectors'
There should be no functionality changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
+54 bytes
drivers/ide/ide-cd.c | 45 +++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
Index: b/drivers/ide/ide-cd.c
===================================================================
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1115,8 +1115,8 @@ static ide_startstop_t cdrom_newpc_intr(
* transfer data
*/
while (thislen > 0) {
- int blen = blen = rq->data_len;
- char *ptr = rq->data;
+ u8 *ptr = rq->data;
+ int blen = rq->data_len;
/*
* bio backed?
@@ -1192,7 +1192,7 @@ static ide_startstop_t cdrom_rw_intr(ide
struct cdrom_info *info = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
xfer_func_t *xferfunc;
- int stat, ireason, len, sectors_to_transfer, uptodate, nskip;
+ int stat, ireason, len, thislen, uptodate, nskip;
int dma_error = 0, dma = info->dma, write = rq_data_dir(rq) == WRITE;
u8 lowcyl = 0, highcyl = 0;
@@ -1247,7 +1247,7 @@ static ide_startstop_t cdrom_rw_intr(ide
return ide_stopped;
}
- sectors_to_transfer = len / SECTOR_SIZE;
+ thislen = len;
/* Check that the drive is expecting to do the same thing we are. */
if (write) {
@@ -1270,12 +1270,12 @@ static ide_startstop_t cdrom_rw_intr(ide
*/
nskip = min_t(int, rq->current_nr_sectors
- bio_cur_sectors(rq->bio),
- sectors_to_transfer);
+ thislen >> 9);
if (nskip > 0) {
ide_cd_drain_data(drive, nskip);
rq->current_nr_sectors -= nskip;
- sectors_to_transfer -= nskip;
+ thislen -= (nskip << 9);
}
xferfunc = HWIF(drive)->atapi_input_bytes;
@@ -1284,17 +1284,23 @@ static ide_startstop_t cdrom_rw_intr(ide
/*
* now loop and read/write the data
*/
- while (sectors_to_transfer > 0) {
- int this_transfer;
+ while (thislen > 0) {
+ u8 *ptr = NULL;
+ int blen;
+
+ if (rq->bio) {
+ ptr = rq->buffer;
+ blen = rq->current_nr_sectors << 9;
+ }
- if (!rq->current_nr_sectors) {
+ if (!ptr) {
if (!write)
/*
* If the buffers are full, cache the rest
* of the data in our internal buffer.
*/
cdrom_buffer_sectors(drive, rq->sector,
- sectors_to_transfer);
+ thislen >> 9);
else
printk(KERN_ERR "%s: %s: confused, missing "
"data\n",
@@ -1305,17 +1311,16 @@ static ide_startstop_t cdrom_rw_intr(ide
/*
* Figure out how many sectors we can transfer
*/
- this_transfer = min_t(int, sectors_to_transfer, rq->current_nr_sectors);
+ if (blen > thislen)
+ blen = thislen;
- while (this_transfer > 0) {
- xferfunc(drive, rq->buffer, SECTOR_SIZE);
- rq->buffer += SECTOR_SIZE;
- --rq->nr_sectors;
- --rq->current_nr_sectors;
- ++rq->sector;
- --this_transfer;
- --sectors_to_transfer;
- }
+ xferfunc(drive, ptr, blen);
+
+ thislen -= blen;
+ rq->buffer += blen;
+ rq->nr_sectors -= (blen >> 9);
+ rq->current_nr_sectors -= (blen >> 9);
+ rq->sector += (blen >> 9);
/*
* current buffer complete, move on
reply other threads:[~2007-12-20 1:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200712200236.41270.bzolnier@gmail.com \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.