diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:36 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:36 -0400 |
commit | acaa0f5f675ccf6b8a3a11a933419068b1ea1f46 (patch) | |
tree | 8afee71c69bf765a5edd0de82c98c6470905ec20 /drivers/ide/ide-floppy.c | |
parent | c860f955681ebd83df4a03089f1910fc4b54651f (diff) |
ide: add ide_io_buffers() helper
* Make ->io_buffers method return number of bytes transferred.
* Use ide_end_request() instead of idefloppy_end_request()
in ide_floppy_io_buffers() and then move the call out to
ide_pc_intr().
* Add ide_io_buffers() helper and convert ide-{floppy,scsi}.c
to use it instead of ide*_io_buffers().
There should be no functional changes caused by this patch.
Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r-- | drivers/ide/ide-floppy.c | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index a0a8ad3a3038..38dca45ffd11 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -208,51 +208,6 @@ static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) | |||
208 | return 0; | 208 | return 0; |
209 | } | 209 | } |
210 | 210 | ||
211 | static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
212 | unsigned int bcount, int direction) | ||
213 | { | ||
214 | ide_hwif_t *hwif = drive->hwif; | ||
215 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
216 | xfer_func_t *xf = direction ? tp_ops->output_data : tp_ops->input_data; | ||
217 | struct scatterlist *sg = pc->sg; | ||
218 | char *buf; | ||
219 | int count, done = 0; | ||
220 | |||
221 | while (bcount) { | ||
222 | count = min(sg->length - pc->b_count, bcount); | ||
223 | if (PageHighMem(sg_page(sg))) { | ||
224 | unsigned long flags; | ||
225 | |||
226 | local_irq_save(flags); | ||
227 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; | ||
228 | xf(drive, NULL, buf + pc->b_count, count); | ||
229 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | ||
230 | local_irq_restore(flags); | ||
231 | } else { | ||
232 | buf = sg_virt(sg); | ||
233 | xf(drive, NULL, buf + pc->b_count, count); | ||
234 | } | ||
235 | bcount -= count; | ||
236 | pc->b_count += count; | ||
237 | done += count; | ||
238 | |||
239 | if (pc->b_count == sg->length) { | ||
240 | if (!--pc->sg_cnt) | ||
241 | break; | ||
242 | pc->sg = sg = sg_next(sg); | ||
243 | pc->b_count = 0; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | idefloppy_end_request(drive, 1, done >> 9); | ||
248 | |||
249 | if (bcount) { | ||
250 | printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n", | ||
251 | drive->name, __func__, bcount); | ||
252 | ide_pad_transfer(drive, direction, bcount); | ||
253 | } | ||
254 | } | ||
255 | |||
256 | static void idefloppy_update_buffers(ide_drive_t *drive, | 211 | static void idefloppy_update_buffers(ide_drive_t *drive, |
257 | struct ide_atapi_pc *pc) | 212 | struct ide_atapi_pc *pc) |
258 | { | 213 | { |
@@ -356,7 +311,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) | |||
356 | 311 | ||
357 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, | 312 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, |
358 | IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers, | 313 | IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers, |
359 | idefloppy_retry_pc, NULL, ide_floppy_io_buffers); | 314 | idefloppy_retry_pc, NULL, ide_io_buffers); |
360 | } | 315 | } |
361 | 316 | ||
362 | /* | 317 | /* |