From: Bartlomiej Zolnierkiewicz - split __task_sectors() out of task_sectors() - add bio and buffer versions of task[_multi]_sectors() - use task_bio_sectors() instead of task_sectors() in pdc4030.c - move task[_buffer]_sectors() to ide-taskfile.c - uninline task[_multi]_sectors() Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton --- 25-akpm/drivers/ide/ide-taskfile.c | 43 +++++++++++++++++++++++++++++++++-- 25-akpm/drivers/ide/legacy/pdc4030.c | 4 +-- 25-akpm/include/linux/ide.h | 36 ++++++++++------------------- 3 files changed, 56 insertions(+), 27 deletions(-) diff -puN drivers/ide/ide-taskfile.c~ide-split-task_sectors-and-task_multi_sectors drivers/ide/ide-taskfile.c --- 25/drivers/ide/ide-taskfile.c~ide-split-task_sectors-and-task_multi_sectors 2004-06-20 13:57:29.645635952 -0700 +++ 25-akpm/drivers/ide/ide-taskfile.c 2004-06-20 13:57:29.666632760 -0700 @@ -288,6 +288,27 @@ ide_startstop_t task_no_data_intr (ide_d EXPORT_SYMBOL(task_no_data_intr); +static inline void task_buffer_sectors(ide_drive_t *drive, struct request *rq, + unsigned nsect, unsigned rw) +{ + char *buf = rq->buffer + blk_rq_offset(rq); + + process_that_request_first(rq, nsect); + __task_sectors(drive, buf, nsect, rw); +} + +static inline void task_buffer_multi_sectors(ide_drive_t *drive, + struct request *rq, unsigned rw) +{ + unsigned int msect = drive->mult_count, nsect; + + nsect = rq->current_nr_sectors; + if (nsect > msect) + nsect = msect; + + task_buffer_sectors(drive, rq, nsect, rw); +} + /* * old taskfile PIO handlers, to be killed as soon as possible. */ @@ -512,8 +533,17 @@ EXPORT_SYMBOL(task_mulout_intr); #else /* !CONFIG_IDE_TASKFILE_IO */ -static inline void task_multi_sectors(ide_drive_t *drive, - struct request *rq, int rw) +static void task_sectors(ide_drive_t *drive, struct request *rq, + unsigned nsect, unsigned rw) +{ + if (rq->cbio) /* fs request */ + task_bio_sectors(drive, rq, nsect, rw); + else /* task request */ + task_buffer_sectors(drive, rq, nsect, rw); +} + +static inline void task_bio_multi_sectors(ide_drive_t *drive, + struct request *rq, unsigned rw) { unsigned int nsect, msect = drive->mult_count; @@ -532,6 +562,15 @@ static inline void task_multi_sectors(id } while (msect); } +static void task_multi_sectors(ide_drive_t *drive, + struct request *rq, unsigned rw) +{ + if (rq->cbio) /* fs request */ + task_bio_multi_sectors(drive, rq, rw); + else /* task request */ + task_buffer_multi_sectors(drive, rq, rw); +} + static u8 wait_drive_not_busy(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); diff -puN drivers/ide/legacy/pdc4030.c~ide-split-task_sectors-and-task_multi_sectors drivers/ide/legacy/pdc4030.c --- 25/drivers/ide/legacy/pdc4030.c~ide-split-task_sectors-and-task_multi_sectors 2004-06-20 13:57:29.653634736 -0700 +++ 25-akpm/drivers/ide/legacy/pdc4030.c 2004-06-20 13:57:29.669632304 -0700 @@ -355,7 +355,7 @@ read_next: #endif /* DEBUG_READ */ #ifdef CONFIG_IDE_TASKFILE_IO - task_sectors(drive, rq, nsect, IDE_PIO_IN); + task_bio_sectors(drive, rq, nsect, IDE_PIO_IN); /* FIXME: can we check status after transfer on pdc4030? */ /* Complete previously submitted bios. */ @@ -478,7 +478,7 @@ static void promise_multwrite (ide_drive if (nsect > msect) nsect = msect; - task_sectors(drive, rq, nsect, IDE_PIO_OUT); + task_bio_sectors(drive, rq, nsect, IDE_PIO_OUT); if (!rq->nr_sectors) msect = 0; diff -puN include/linux/ide.h~ide-split-task_sectors-and-task_multi_sectors include/linux/ide.h --- 25/include/linux/ide.h~ide-split-task_sectors-and-task_multi_sectors 2004-06-20 13:57:29.662633368 -0700 +++ 25-akpm/include/linux/ide.h 2004-06-20 13:57:29.671632000 -0700 @@ -1421,42 +1421,32 @@ extern void atapi_output_bytes(ide_drive extern void taskfile_input_data(ide_drive_t *, void *, u32); extern void taskfile_output_data(ide_drive_t *, void *, u32); -#ifdef CONFIG_IDE_TASKFILE_IO - #define IDE_PIO_IN 0 #define IDE_PIO_OUT 1 -static inline void task_sectors(ide_drive_t *drive, struct request *rq, - unsigned nsect, int rw) +static inline void __task_sectors(ide_drive_t *drive, char *buf, + unsigned nsect, unsigned rw) { - unsigned long flags; - unsigned int bio_rq; - char *buf; - - /* - * bio_rq flag is needed because we can call - * rq_unmap_buffer() with rq->cbio == NULL - */ - bio_rq = rq->cbio ? 1 : 0; - - if (bio_rq) - buf = rq_map_buffer(rq, &flags); /* fs request */ - else - buf = rq->buffer + blk_rq_offset(rq); /* task request */ - /* * IRQ can happen instantly after reading/writing * last sector of the datablock. */ - process_that_request_first(rq, nsect); - if (rw == IDE_PIO_OUT) taskfile_output_data(drive, buf, nsect * SECTOR_WORDS); else taskfile_input_data(drive, buf, nsect * SECTOR_WORDS); +} + +#ifdef CONFIG_IDE_TASKFILE_IO +static inline void task_bio_sectors(ide_drive_t *drive, struct request *rq, + unsigned nsect, unsigned rw) +{ + unsigned long flags; + char *buf = rq_map_buffer(rq, &flags); - if (bio_rq) - rq_unmap_buffer(buf, &flags); + process_that_request_first(rq, nsect); + __task_sectors(drive, buf, nsect, rw); + rq_unmap_buffer(buf, &flags); } #endif /* CONFIG_IDE_TASKFILE_IO */ _