Hi Bart,
here's my first stab at using scatterlists in ide-floppy. I've adapted your
ide-scsi version to fit in here. The change here is that i use pc->b_count as
a sort-of completion counter to know when i'm at the end of the sg element and
be able to switch to the next/finish transfer. I've tested the patch with the
Iomega ZIP drive i have here - it works. We should do some more testing first
though, before sending it upstream.
---
From: Borislav Petkov <petkovbb@gmail.com>
Date: Tue, 5 Aug 2008 06:57:44 +0200
Subject: [PATCH] ide-floppy: use scatterlists for pio transfers
Use hwif->sg_table for pio transfers instead of fumbling
with block layer internals in the driver. Also, make debug
statements more informative in .._do_request() while at it.
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
drivers/ide/ide-floppy.c | 58 +++++++++++++++++++++++++++------------------
1 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index de8d42b..5820d3a 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -224,29 +224,37 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
unsigned int bcount, int direction)
{
ide_hwif_t *hwif = drive->hwif;
- struct request *rq = pc->rq;
- struct req_iterator iter;
- struct bio_vec *bvec;
- unsigned long flags;
+ const struct ide_tp_ops *tp_ops = hwif->tp_ops;
+ xfer_func_t *xf = direction ? tp_ops->output_data : tp_ops->input_data;
+ struct scatterlist *sg = hwif->sg_table;
+ char *buf;
int count, done = 0;
- char *data;
- rq_for_each_segment(bvec, rq, iter) {
- if (!bcount)
- break;
+ while (bcount) {
- count = min(bvec->bv_len, bcount);
-
- data = bvec_kmap_irq(bvec, &flags);
- if (direction)
- hwif->tp_ops->output_data(drive, NULL, data, count);
- else
- hwif->tp_ops->input_data(drive, NULL, data, count);
- bvec_kunmap_irq(data, &flags);
+ count = min(sg->length - ...