===== drivers/ide/ide-disk.c 1.16 vs edited ===== --- 1.16/drivers/ide/ide-disk.c Sat Sep 21 02:32:22 2002 +++ edited/drivers/ide/ide-disk.c Mon Sep 23 17:18:48 2002 @@ -139,8 +139,8 @@ */ static ide_startstop_t read_intr (ide_drive_t *drive) { - ide_hwif_t *hwif = HWIF(drive); - int i = 0, nsect = 0, msect = drive->mult_count; + ide_hwif_t *hwif = HWIF(drive); + int nsect = 0, msect = drive->mult_count; struct request *rq; unsigned long flags; u8 stat; @@ -174,25 +174,24 @@ (unsigned long) rq->buffer+(nsect<<9), rq->nr_sectors-nsect); #endif ide_unmap_buffer(rq, to, &flags); - rq->sector += nsect; - rq->errors = 0; - i = (rq->nr_sectors -= nsect); - if (((long)(rq->current_nr_sectors -= nsect)) <= 0) - ide_end_request(drive, 1, rq->hard_cur_sectors); + + /* + * all done + */ + if (!ide_end_request(drive, 1, nsect)) + return ide_stopped; + /* * Another BH Page walker and DATA INTERGRITY Questioned on ERROR. * If passed back up on multimode read, BAD DATA could be ACKED * to FILE SYSTEMS above ... */ - if (i > 0) { - if (msect) - goto read_next; - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, &read_intr, WAIT_CMD, NULL); - return ide_started; - } - return ide_stopped; + if (msect) + goto read_next; + if (HWGROUP(drive)->handler != NULL) + BUG(); + ide_set_handler(drive, &read_intr, WAIT_CMD, NULL); + return ide_started; } /* @@ -203,7 +202,6 @@ ide_hwgroup_t *hwgroup = HWGROUP(drive); ide_hwif_t *hwif = HWIF(drive); struct request *rq = hwgroup->rq; - int i = 0; u8 stat; if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), @@ -217,23 +215,19 @@ rq->nr_sectors-1); #endif if ((rq->nr_sectors == 1) ^ ((stat & DRQ_STAT) != 0)) { - rq->sector++; - rq->errors = 0; - i = --rq->nr_sectors; - --rq->current_nr_sectors; - if (((long)rq->current_nr_sectors) <= 0) - ide_end_request(drive, 1, rq->hard_cur_sectors); - if (i > 0) { - unsigned long flags; - char *to = ide_map_buffer(rq, &flags); - taskfile_output_data(drive, to, SECTOR_WORDS); - ide_unmap_buffer(rq, to, &flags); - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, &write_intr, WAIT_CMD, NULL); - return ide_started; - } - return ide_stopped; + unsigned long flags; + char *to; + + if (!ide_end_request(drive, 1, 1)) + return ide_stopped; + + to = ide_map_buffer(rq, &flags); + taskfile_output_data(drive, to, SECTOR_WORDS); + ide_unmap_buffer(rq, to, &flags); + if (HWGROUP(drive)->handler != NULL) + BUG(); + ide_set_handler(drive, &write_intr, WAIT_CMD, NULL); + return ide_started; } /* the original code did this here (?) */ return ide_stopped; ===== drivers/ide/ide-taskfile.c 1.4 vs edited ===== --- 1.4/drivers/ide/ide-taskfile.c Fri Sep 20 00:13:51 2002 +++ edited/drivers/ide/ide-taskfile.c Mon Sep 23 17:04:47 2002 @@ -611,9 +611,8 @@ * BH walking or segment can only be updated after we have a good * hwif->INB(IDE_STATUS_REG); return. */ - if (--rq->current_nr_sectors <= 0) - if (!DRIVER(drive)->end_request(drive, 1, 0)) - return ide_stopped; + if (!DRIVER(drive)->end_request(drive, 1, 1)) + return ide_stopped; /* * ERM, it is techincally legal to leave/exit here but it makes * a mess of the code ... @@ -669,7 +668,6 @@ taskfile_input_data(drive, pBuf, nsect * SECTOR_WORDS); task_unmap_rq(rq, pBuf, &flags); rq->errors = 0; - rq->current_nr_sectors -= nsect; msect -= nsect; /* * FIXME :: We really can not legally get a new page/bh @@ -677,10 +675,8 @@ * BH walking or segment can only be updated after we have a * good hwif->INB(IDE_STATUS_REG); return. */ - if (!rq->current_nr_sectors) { - if (!DRIVER(drive)->end_request(drive, 1, 0)) - return ide_stopped; - } + if (!DRIVER(drive)->end_request(drive, 1, 1)) + return ide_stopped; } while (msect); if (HWGROUP(drive)->handler == NULL) ide_set_handler(drive, &task_mulin_intr, WAIT_WORSTCASE, NULL); @@ -740,9 +736,9 @@ * Safe to update request for partial completions. * We have a good STATUS CHECK!!! */ - if (!rq->current_nr_sectors) - if (!DRIVER(drive)->end_request(drive, 1, 0)) - return ide_stopped; + if (!DRIVER(drive)->end_request(drive, 1, 1)) + return ide_stopped; + if ((rq->current_nr_sectors==1) ^ (stat & DRQ_STAT)) { rq = HWGROUP(drive)->rq; pBuf = task_map_rq(rq, &flags); @@ -802,13 +798,10 @@ msect -= nsect; taskfile_output_data(drive, pBuf, nsect * SECTOR_WORDS); task_unmap_rq(rq, pBuf, &flags); - rq->current_nr_sectors -= nsect; - if (!rq->current_nr_sectors) { - if (!DRIVER(drive)->end_request(drive, 1, 0)) - if (!rq->bio) { - stat = hwif->INB(IDE_STATUS_REG); - return ide_stopped; - } + if (!DRIVER(drive)->end_request(drive, 1, 1)) { + /* stat for...? */ + stat = hwif->INB(IDE_STATUS_REG); + return ide_stopped; } } while (msect); rq->errors = 0; @@ -922,18 +915,14 @@ msect -= nsect; taskfile_output_data(drive, pBuf, nsect * SECTOR_WORDS); task_unmap_rq(rq, pBuf, &flags); - rq->current_nr_sectors -= nsect; /* * FIXME :: We really can not legally get a new page/bh * regardless, if this is the end of our segment. * BH walking or segment can only be updated after we * have a good hwif->INB(IDE_STATUS_REG); return. */ - if (!rq->current_nr_sectors) { - if (!DRIVER(drive)->end_request(drive, 1, 0)) - if (!rq->bio) - return ide_stopped; - } + if (!DRIVER(drive)->end_request(drive, 1, 1)) + return ide_stopped; } while (msect); rq->errors = 0; if (HWGROUP(drive)->handler == NULL)