提交 7c3e28bc 编写于 作者: A Alan Stern 提交者: Greg Kroah-Hartman

USB: use standard SG iterator in the scatter-gather library

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: NAlan Stern <stern@rowland.harvard.edu>
Acked-by: NJens Axboe <jens.axboe@oracle.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 625f6949
...@@ -400,7 +400,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, ...@@ -400,7 +400,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
if (usb_pipein(pipe)) if (usb_pipein(pipe))
urb_flags |= URB_SHORT_NOT_OK; urb_flags |= URB_SHORT_NOT_OK;
for (i = 0; i < io->entries; i++) { for_each_sg(sg, sg, io->entries, i) {
unsigned len; unsigned len;
io->urbs[i] = usb_alloc_urb(0, mem_flags); 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, ...@@ -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. * to prevent stale pointers and to help spot bugs.
*/ */
if (dma) { if (dma) {
io->urbs[i]->transfer_dma = sg_dma_address(sg + i); io->urbs[i]->transfer_dma = sg_dma_address(sg);
len = sg_dma_len(sg + i); len = sg_dma_len(sg);
#if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU)
io->urbs[i]->transfer_buffer = NULL; io->urbs[i]->transfer_buffer = NULL;
#else #else
io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); io->urbs[i]->transfer_buffer = sg_virt(sg);
#endif #endif
} else { } else {
/* hc may use _only_ transfer_buffer */ /* hc may use _only_ transfer_buffer */
io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); io->urbs[i]->transfer_buffer = sg_virt(sg);
len = sg[i].length; len = sg->length;
} }
if (length) { if (length) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册