Commit 910f8d0c authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Greg Kroah-Hartman

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: default avatarMatthew Wilcox <willy@linux.intel.com>
Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Tested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1e429018
...@@ -1278,7 +1278,7 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) ...@@ -1278,7 +1278,7 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
if (urb->transfer_flags & URB_DMA_MAP_SG) if (urb->transfer_flags & URB_DMA_MAP_SG)
dma_unmap_sg(hcd->self.controller, dma_unmap_sg(hcd->self.controller,
urb->sg->sg, urb->sg,
urb->num_sgs, urb->num_sgs,
dir); dir);
else if (urb->transfer_flags & URB_DMA_MAP_PAGE) 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,7 +1346,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
if (urb->num_sgs) { if (urb->num_sgs) {
int n = dma_map_sg( int n = dma_map_sg(
hcd->self.controller, hcd->self.controller,
urb->sg->sg, urb->sg,
urb->num_sgs, urb->num_sgs,
dir); dir);
if (n <= 0) if (n <= 0)
...@@ -1359,9 +1359,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, ...@@ -1359,9 +1359,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
URB_DMA_SG_COMBINED; URB_DMA_SG_COMBINED;
} }
} else if (urb->sg) { } else if (urb->sg) {
struct scatterlist *sg; struct scatterlist *sg = urb->sg;
sg = (struct scatterlist *) urb->sg;
urb->transfer_dma = dma_map_page( urb->transfer_dma = dma_map_page(
hcd->self.controller, hcd->self.controller,
sg_page(sg), sg_page(sg),
......
...@@ -413,7 +413,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, ...@@ -413,7 +413,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
sg->length; sg->length;
} }
} }
io->urbs[0]->sg = io; io->urbs[0]->sg = sg;
io->urbs[0]->num_sgs = io->entries; io->urbs[0]->num_sgs = io->entries;
io->entries = 1; io->entries = 1;
} else { } else {
...@@ -454,7 +454,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, ...@@ -454,7 +454,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
} }
io->urbs[i]->transfer_buffer_length = len; io->urbs[i]->transfer_buffer_length = len;
io->urbs[i]->sg = (struct usb_sg_request *) sg; io->urbs[i]->sg = sg;
} }
io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT;
} }
......
...@@ -663,7 +663,7 @@ qh_urb_transaction ( ...@@ -663,7 +663,7 @@ qh_urb_transaction (
*/ */
i = urb->num_sgs; i = urb->num_sgs;
if (len > 0 && i > 0) { if (len > 0 && i > 0) {
sg = urb->sg->sg; sg = urb->sg;
buf = sg_dma_address(sg); buf = sg_dma_address(sg);
/* urb->transfer_buffer_length may be smaller than the /* urb->transfer_buffer_length may be smaller than the
......
...@@ -443,7 +443,7 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u ...@@ -443,7 +443,7 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u
remaining = urb->transfer_buffer_length; remaining = urb->transfer_buffer_length;
for_each_sg(urb->sg->sg, sg, urb->num_sgs, i) { for_each_sg(urb->sg, sg, urb->num_sgs, i) {
dma_addr_t dma_addr; dma_addr_t dma_addr;
size_t dma_remaining; size_t dma_remaining;
dma_addr_t sp, ep; dma_addr_t sp, ep;
...@@ -561,7 +561,7 @@ static int qset_add_urb_sg_linearize(struct whc *whc, struct whc_qset *qset, ...@@ -561,7 +561,7 @@ static int qset_add_urb_sg_linearize(struct whc *whc, struct whc_qset *qset,
remaining = urb->transfer_buffer_length; remaining = urb->transfer_buffer_length;
for_each_sg(urb->sg->sg, sg, urb->sg->nents, i) { for_each_sg(urb->sg, sg, urb->num_sgs, i) {
size_t len; size_t len;
size_t sg_remaining; size_t sg_remaining;
void *orig; void *orig;
......
...@@ -1788,7 +1788,7 @@ static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb) ...@@ -1788,7 +1788,7 @@ static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb)
xhci_dbg(xhci, "count sg list trbs: \n"); xhci_dbg(xhci, "count sg list trbs: \n");
num_trbs = 0; num_trbs = 0;
for_each_sg(urb->sg->sg, sg, num_sgs, i) { for_each_sg(urb->sg, sg, num_sgs, i) {
unsigned int previous_total_trbs = num_trbs; unsigned int previous_total_trbs = num_trbs;
unsigned int len = sg_dma_len(sg); unsigned int len = sg_dma_len(sg);
...@@ -1951,7 +1951,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, ...@@ -1951,7 +1951,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
* the amount of memory allocated for this scatter-gather list. * the amount of memory allocated for this scatter-gather list.
* 3. TRBs buffers can't cross 64KB boundaries. * 3. TRBs buffers can't cross 64KB boundaries.
*/ */
sg = urb->sg->sg; sg = urb->sg;
addr = (u64) sg_dma_address(sg); addr = (u64) sg_dma_address(sg);
this_sg_len = sg_dma_len(sg); this_sg_len = sg_dma_len(sg);
trb_buff_len = TRB_MAX_BUFF_SIZE - trb_buff_len = TRB_MAX_BUFF_SIZE -
......
...@@ -422,7 +422,7 @@ static unsigned int mon_bin_get_data(const struct mon_reader_bin *rp, ...@@ -422,7 +422,7 @@ static unsigned int mon_bin_get_data(const struct mon_reader_bin *rp,
} }
/* Copy up to the first non-addressable segment */ /* Copy up to the first non-addressable segment */
for_each_sg(urb->sg->sg, sg, urb->num_sgs, i) { for_each_sg(urb->sg, sg, urb->num_sgs, i) {
if (length == 0 || PageHighMem(sg_page(sg))) if (length == 0 || PageHighMem(sg_page(sg)))
break; break;
this_len = min_t(unsigned int, sg->length, length); this_len = min_t(unsigned int, sg->length, length);
......
...@@ -159,7 +159,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, ...@@ -159,7 +159,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
if (src == NULL) if (src == NULL)
return 'Z'; /* '0' would be not as pretty. */ return 'Z'; /* '0' would be not as pretty. */
} else { } else {
struct scatterlist *sg = urb->sg->sg; struct scatterlist *sg = urb->sg;
if (PageHighMem(sg_page(sg))) if (PageHighMem(sg_page(sg)))
return 'D'; return 'D';
......
...@@ -1195,7 +1195,7 @@ struct urb { ...@@ -1195,7 +1195,7 @@ struct urb {
unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
void *transfer_buffer; /* (in) associated data buffer */ void *transfer_buffer; /* (in) associated data buffer */
dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */ dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
struct usb_sg_request *sg; /* (in) scatter gather buffer list */ struct scatterlist *sg; /* (in) scatter gather buffer list */
int num_sgs; /* (in) number of entries in the sg list */ int num_sgs; /* (in) number of entries in the sg list */
u32 transfer_buffer_length; /* (in) data buffer length */ u32 transfer_buffer_length; /* (in) data buffer length */
u32 actual_length; /* (return) actual transfer length */ u32 actual_length; /* (return) actual transfer length */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment