]> err.no Git - linux-2.6/commitdiff
USB: use standard SG iterator in the scatter-gather library
authorAlan Stern <stern@rowland.harvard.edu>
Mon, 16 Jun 2008 16:11:39 +0000 (12:11 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Jul 2008 22:16:32 +0000 (15:16 -0700)
This patch (as1103) changes the iteration in the USB scatter-gather to
use a standard SG iterator.  Otherwise the iteration will fail if it
encounters a chained SG list.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/message.c

index 315363b744a3781ab86e5e3476e35061e89cd30c..08af1083ebfc69227e1b012bc9f914be30538431 100644 (file)
@@ -400,7 +400,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
        if (usb_pipein(pipe))
                urb_flags |= URB_SHORT_NOT_OK;
 
-       for (i = 0; i < io->entries; i++) {
+       for_each_sg(sg, sg, io->entries, i) {
                unsigned len;
 
                io->urbs[i] = usb_alloc_urb(0, mem_flags);
@@ -434,17 +434,17 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
                 * to prevent stale pointers and to help spot bugs.
                 */
                if (dma) {
-                       io->urbs[i]->transfer_dma = sg_dma_address(sg + i);
-                       len = sg_dma_len(sg + i);
+                       io->urbs[i]->transfer_dma = sg_dma_address(sg);
+                       len = sg_dma_len(sg);
 #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU)
                        io->urbs[i]->transfer_buffer = NULL;
 #else
-                       io->urbs[i]->transfer_buffer = sg_virt(&sg[i]);
+                       io->urbs[i]->transfer_buffer = sg_virt(sg);
 #endif
                } else {
                        /* hc may use _only_ transfer_buffer */
-                       io->urbs[i]->transfer_buffer = sg_virt(&sg[i]);
-                       len = sg[i].length;
+                       io->urbs[i]->transfer_buffer = sg_virt(sg);
+                       len = sg->length;
                }
 
                if (length) {