diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:27 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:27 -0500 |
commit | a11e77db4982d44bf610dc7257b0fca3f7202403 (patch) | |
tree | cd1289f1a2802113ee2cfb6e0be3216b7dbcb954 | |
parent | 37782fcefcca437f870e581e6cc316111f8b7660 (diff) |
ide-cd: prepare cdrom_rw_intr() and cdrom_newpc_intr() to be merged
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>
-rw-r--r-- | drivers/ide/ide-cd.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 0f17117c5aa0..2a520bd27a37 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1123,8 +1123,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1123 | * transfer data | 1123 | * transfer data |
1124 | */ | 1124 | */ |
1125 | while (thislen > 0) { | 1125 | while (thislen > 0) { |
1126 | int blen = blen = rq->data_len; | 1126 | u8 *ptr = rq->data; |
1127 | char *ptr = rq->data; | 1127 | int blen = rq->data_len; |
1128 | 1128 | ||
1129 | /* | 1129 | /* |
1130 | * bio backed? | 1130 | * bio backed? |
@@ -1207,7 +1207,7 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive) | |||
1207 | struct cdrom_info *info = drive->driver_data; | 1207 | struct cdrom_info *info = drive->driver_data; |
1208 | struct request *rq = HWGROUP(drive)->rq; | 1208 | struct request *rq = HWGROUP(drive)->rq; |
1209 | xfer_func_t *xferfunc; | 1209 | xfer_func_t *xferfunc; |
1210 | int stat, ireason, len, sectors_to_transfer, uptodate, nskip; | 1210 | int stat, ireason, len, thislen, uptodate, nskip; |
1211 | int dma_error = 0, dma = info->dma, write = rq_data_dir(rq) == WRITE; | 1211 | int dma_error = 0, dma = info->dma, write = rq_data_dir(rq) == WRITE; |
1212 | u8 lowcyl = 0, highcyl = 0; | 1212 | u8 lowcyl = 0, highcyl = 0; |
1213 | 1213 | ||
@@ -1262,7 +1262,7 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive) | |||
1262 | return ide_stopped; | 1262 | return ide_stopped; |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | sectors_to_transfer = len / SECTOR_SIZE; | 1265 | thislen = len; |
1266 | 1266 | ||
1267 | /* Check that the drive is expecting to do the same thing we are. */ | 1267 | /* Check that the drive is expecting to do the same thing we are. */ |
1268 | if (write) { | 1268 | if (write) { |
@@ -1285,12 +1285,12 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive) | |||
1285 | */ | 1285 | */ |
1286 | nskip = min_t(int, rq->current_nr_sectors | 1286 | nskip = min_t(int, rq->current_nr_sectors |
1287 | - bio_cur_sectors(rq->bio), | 1287 | - bio_cur_sectors(rq->bio), |
1288 | sectors_to_transfer); | 1288 | thislen >> 9); |
1289 | 1289 | ||
1290 | if (nskip > 0) { | 1290 | if (nskip > 0) { |
1291 | ide_cd_drain_data(drive, nskip); | 1291 | ide_cd_drain_data(drive, nskip); |
1292 | rq->current_nr_sectors -= nskip; | 1292 | rq->current_nr_sectors -= nskip; |
1293 | sectors_to_transfer -= nskip; | 1293 | thislen -= (nskip << 9); |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | xferfunc = HWIF(drive)->atapi_input_bytes; | 1296 | xferfunc = HWIF(drive)->atapi_input_bytes; |
@@ -1299,17 +1299,23 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive) | |||
1299 | /* | 1299 | /* |
1300 | * now loop and read/write the data | 1300 | * now loop and read/write the data |
1301 | */ | 1301 | */ |
1302 | while (sectors_to_transfer > 0) { | 1302 | while (thislen > 0) { |
1303 | int this_transfer; | 1303 | u8 *ptr = NULL; |
1304 | int blen; | ||
1305 | |||
1306 | if (rq->bio) { | ||
1307 | ptr = rq->buffer; | ||
1308 | blen = rq->current_nr_sectors << 9; | ||
1309 | } | ||
1304 | 1310 | ||
1305 | if (!rq->current_nr_sectors) { | 1311 | if (!ptr) { |
1306 | if (!write) | 1312 | if (!write) |
1307 | /* | 1313 | /* |
1308 | * If the buffers are full, cache the rest | 1314 | * If the buffers are full, cache the rest |
1309 | * of the data in our internal buffer. | 1315 | * of the data in our internal buffer. |
1310 | */ | 1316 | */ |
1311 | cdrom_buffer_sectors(drive, rq->sector, | 1317 | cdrom_buffer_sectors(drive, rq->sector, |
1312 | sectors_to_transfer); | 1318 | thislen >> 9); |
1313 | else | 1319 | else |
1314 | printk(KERN_ERR "%s: %s: confused, missing " | 1320 | printk(KERN_ERR "%s: %s: confused, missing " |
1315 | "data\n", | 1321 | "data\n", |
@@ -1320,17 +1326,16 @@ static ide_startstop_t cdrom_rw_intr(ide_drive_t *drive) | |||
1320 | /* | 1326 | /* |
1321 | * Figure out how many sectors we can transfer | 1327 | * Figure out how many sectors we can transfer |
1322 | */ | 1328 | */ |
1323 | this_transfer = min_t(int, sectors_to_transfer, rq->current_nr_sectors); | 1329 | if (blen > thislen) |
1324 | 1330 | blen = thislen; | |
1325 | while (this_transfer > 0) { | 1331 | |
1326 | xferfunc(drive, rq->buffer, SECTOR_SIZE); | 1332 | xferfunc(drive, ptr, blen); |
1327 | rq->buffer += SECTOR_SIZE; | 1333 | |
1328 | --rq->nr_sectors; | 1334 | thislen -= blen; |
1329 | --rq->current_nr_sectors; | 1335 | rq->buffer += blen; |
1330 | ++rq->sector; | 1336 | rq->nr_sectors -= (blen >> 9); |
1331 | --this_transfer; | 1337 | rq->current_nr_sectors -= (blen >> 9); |
1332 | --sectors_to_transfer; | 1338 | rq->sector += (blen >> 9); |
1333 | } | ||
1334 | 1339 | ||
1335 | /* | 1340 | /* |
1336 | * current buffer complete, move on | 1341 | * current buffer complete, move on |