aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2010-05-01 14:20:01 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:41 -0400
commit910f8d0cede74beff1eee93cf9cf2a28d7600e66 (patch)
tree663cd91c3d4ca2a71937b0dcaad51b02cae3c9c6
parent1e429018b646bdf903554e92ead1cda96cc552dc (diff)
USB: Change the scatterlist type in struct urb
Change the type of the URB's 'sg' pointer from a usb_sg_request to a scatterlist. This allows drivers to submit scatter-gather lists without using the usb_sg_wait() interface. It has the added benefit of removing the typecasts that were added as part of patch as1368 (and slightly decreasing the number of pointer dereferences). Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Tested-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/core/hcd.c8
-rw-r--r--drivers/usb/core/message.c4
-rw-r--r--drivers/usb/host/ehci-q.c2
-rw-r--r--drivers/usb/host/whci/qset.c4
-rw-r--r--drivers/usb/host/xhci-ring.c4
-rw-r--r--drivers/usb/mon/mon_bin.c2
-rw-r--r--drivers/usb/mon/mon_text.c2
-rw-r--r--include/linux/usb.h2
8 files changed, 13 insertions, 15 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 0abc5c537f39..297c92e4bf8d 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1278,7 +1278,7 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
1278 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 1278 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
1279 if (urb->transfer_flags & URB_DMA_MAP_SG) 1279 if (urb->transfer_flags & URB_DMA_MAP_SG)
1280 dma_unmap_sg(hcd->self.controller, 1280 dma_unmap_sg(hcd->self.controller,
1281 urb->sg->sg, 1281 urb->sg,
1282 urb->num_sgs, 1282 urb->num_sgs,
1283 dir); 1283 dir);
1284 else if (urb->transfer_flags & URB_DMA_MAP_PAGE) 1284 else if (urb->transfer_flags & URB_DMA_MAP_PAGE)
@@ -1346,7 +1346,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
1346 if (urb->num_sgs) { 1346 if (urb->num_sgs) {
1347 int n = dma_map_sg( 1347 int n = dma_map_sg(
1348 hcd->self.controller, 1348 hcd->self.controller,
1349 urb->sg->sg, 1349 urb->sg,
1350 urb->num_sgs, 1350 urb->num_sgs,
1351 dir); 1351 dir);
1352 if (n <= 0) 1352 if (n <= 0)
@@ -1359,9 +1359,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
1359 URB_DMA_SG_COMBINED; 1359 URB_DMA_SG_COMBINED;
1360 } 1360 }
1361 } else if (urb->sg) { 1361 } else if (urb->sg) {
1362 struct scatterlist *sg; 1362 struct scatterlist *sg = urb->sg;
1363
1364 sg = (struct scatterlist *) urb->sg;
1365 urb->transfer_dma = dma_map_page( 1363 urb->transfer_dma = dma_map_page(
1366 hcd->self.controller, 1364 hcd->self.controller,
1367 sg_page(sg), 1365 sg_page(sg),
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index d8329eb47d4f..63919b8abee1 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -413,7 +413,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
413 sg->length; 413 sg->length;
414 } 414 }
415 } 415 }
416 io->urbs[0]->sg = io; 416 io->urbs[0]->sg = sg;
417 io->urbs[0]->num_sgs = io->entries; 417 io->urbs[0]->num_sgs = io->entries;
418 io->entries = 1; 418 io->entries = 1;
419 } else { 419 } else {
@@ -454,7 +454,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
454 } 454 }
455 io->urbs[i]->transfer_buffer_length = len; 455 io->urbs[i]->transfer_buffer_length = len;
456 456
457 io->urbs[i]->sg = (struct usb_sg_request *) sg; 457 io->urbs[i]->sg = sg;
458 } 458 }
459 io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; 459 io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT;
460 } 460 }
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 89521775c567..11a79c4f4a9d 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -663,7 +663,7 @@ qh_urb_transaction (
663 */ 663 */
664 i = urb->num_sgs; 664 i = urb->num_sgs;
665 if (len > 0 && i > 0) { 665 if (len > 0 && i > 0) {
666 sg = urb->sg->sg; 666 sg = urb->sg;
667 buf = sg_dma_address(sg); 667 buf = sg_dma_address(sg);
668 668
669 /* urb->transfer_buffer_length may be smaller than the 669 /* urb->transfer_buffer_length may be smaller than the
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c
index b388dd1fb4c4..ab5a14fbfeeb 100644
--- a/drivers/usb/host/whci/qset.c
+++ b/drivers/usb/host/whci/qset.c
@@ -443,7 +443,7 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u
443 443
444 remaining = urb->transfer_buffer_length; 444 remaining = urb->transfer_buffer_length;
445 445
446 for_each_sg(urb->sg->sg, sg, urb->num_sgs, i) { 446 for_each_sg(urb->sg, sg, urb->num_sgs, i) {
447 dma_addr_t dma_addr; 447 dma_addr_t dma_addr;
448 size_t dma_remaining; 448 size_t dma_remaining;
449 dma_addr_t sp, ep; 449 dma_addr_t sp, ep;
@@ -561,7 +561,7 @@ static int qset_add_urb_sg_linearize(struct whc *whc, struct whc_qset *qset,
561 561
562 remaining = urb->transfer_buffer_length; 562 remaining = urb->transfer_buffer_length;
563 563
564 for_each_sg(urb->sg->sg, sg, urb->sg->nents, i) { 564 for_each_sg(urb->sg, sg, urb->num_sgs, i) {
565 size_t len; 565 size_t len;
566 size_t sg_remaining; 566 size_t sg_remaining;
567 void *orig; 567 void *orig;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 9e27eb0c7004..a67caef265b1 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1788,7 +1788,7 @@ static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb)
1788 1788
1789 xhci_dbg(xhci, "count sg list trbs: \n"); 1789 xhci_dbg(xhci, "count sg list trbs: \n");
1790 num_trbs = 0; 1790 num_trbs = 0;
1791 for_each_sg(urb->sg->sg, sg, num_sgs, i) { 1791 for_each_sg(urb->sg, sg, num_sgs, i) {
1792 unsigned int previous_total_trbs = num_trbs; 1792 unsigned int previous_total_trbs = num_trbs;
1793 unsigned int len = sg_dma_len(sg); 1793 unsigned int len = sg_dma_len(sg);
1794 1794
@@ -1951,7 +1951,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
1951 * the amount of memory allocated for this scatter-gather list. 1951 * the amount of memory allocated for this scatter-gather list.
1952 * 3. TRBs buffers can't cross 64KB boundaries. 1952 * 3. TRBs buffers can't cross 64KB boundaries.
1953 */ 1953 */
1954 sg = urb->sg->sg; 1954 sg = urb->sg;
1955 addr = (u64) sg_dma_address(sg); 1955 addr = (u64) sg_dma_address(sg);
1956 this_sg_len = sg_dma_len(sg); 1956 this_sg_len = sg_dma_len(sg);
1957 trb_buff_len = TRB_MAX_BUFF_SIZE - 1957 trb_buff_len = TRB_MAX_BUFF_SIZE -
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 8a7968df278f..e7fa3644ba6a 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -422,7 +422,7 @@ static unsigned int mon_bin_get_data(const struct mon_reader_bin *rp,
422 } 422 }
423 423
424 /* Copy up to the first non-addressable segment */ 424 /* Copy up to the first non-addressable segment */
425 for_each_sg(urb->sg->sg, sg, urb->num_sgs, i) { 425 for_each_sg(urb->sg, sg, urb->num_sgs, i) {
426 if (length == 0 || PageHighMem(sg_page(sg))) 426 if (length == 0 || PageHighMem(sg_page(sg)))
427 break; 427 break;
428 this_len = min_t(unsigned int, sg->length, length); 428 this_len = min_t(unsigned int, sg->length, length);
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index d56260280f54..a545d65f6e57 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -159,7 +159,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
159 if (src == NULL) 159 if (src == NULL)
160 return 'Z'; /* '0' would be not as pretty. */ 160 return 'Z'; /* '0' would be not as pretty. */
161 } else { 161 } else {
162 struct scatterlist *sg = urb->sg->sg; 162 struct scatterlist *sg = urb->sg;
163 163
164 if (PageHighMem(sg_page(sg))) 164 if (PageHighMem(sg_page(sg)))
165 return 'D'; 165 return 'D';
diff --git a/include/linux/usb.h b/include/linux/usb.h
index cf3b289a87a2..eec9e74f332f 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1195,7 +1195,7 @@ struct urb {
1195 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ 1195 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
1196 void *transfer_buffer; /* (in) associated data buffer */ 1196 void *transfer_buffer; /* (in) associated data buffer */
1197 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ 1197 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
1198 struct usb_sg_request *sg; /* (in) scatter gather buffer list */ 1198 struct scatterlist *sg; /* (in) scatter gather buffer list */
1199 int num_sgs; /* (in) number of entries in the sg list */ 1199 int num_sgs; /* (in) number of entries in the sg list */
1200 u32 transfer_buffer_length; /* (in) data buffer length */ 1200 u32 transfer_buffer_length; /* (in) data buffer length */
1201 u32 actual_length; /* (return) actual transfer length */ 1201 u32 actual_length; /* (return) actual transfer length */