Skip to content

Commit 910f8d0

Browse files
Matthew Wilcoxgregkh
authored andcommitted
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 <[email protected]> Reviewed-by: Alan Stern <[email protected]> Tested-by: Alan Stern <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1e42901 commit 910f8d0

File tree

8 files changed

+13
-15
lines changed

8 files changed

+13
-15
lines changed

drivers/usb/core/hcd.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
12781278
dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
12791279
if (urb->transfer_flags & URB_DMA_MAP_SG)
12801280
dma_unmap_sg(hcd->self.controller,
1281-
urb->sg->sg,
1281+
urb->sg,
12821282
urb->num_sgs,
12831283
dir);
12841284
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,
13461346
if (urb->num_sgs) {
13471347
int n = dma_map_sg(
13481348
hcd->self.controller,
1349-
urb->sg->sg,
1349+
urb->sg,
13501350
urb->num_sgs,
13511351
dir);
13521352
if (n <= 0)
@@ -1359,9 +1359,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
13591359
URB_DMA_SG_COMBINED;
13601360
}
13611361
} else if (urb->sg) {
1362-
struct scatterlist *sg;
1363-
1364-
sg = (struct scatterlist *) urb->sg;
1362+
struct scatterlist *sg = urb->sg;
13651363
urb->transfer_dma = dma_map_page(
13661364
hcd->self.controller,
13671365
sg_page(sg),

drivers/usb/core/message.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
413413
sg->length;
414414
}
415415
}
416-
io->urbs[0]->sg = io;
416+
io->urbs[0]->sg = sg;
417417
io->urbs[0]->num_sgs = io->entries;
418418
io->entries = 1;
419419
} else {
@@ -454,7 +454,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
454454
}
455455
io->urbs[i]->transfer_buffer_length = len;
456456

457-
io->urbs[i]->sg = (struct usb_sg_request *) sg;
457+
io->urbs[i]->sg = sg;
458458
}
459459
io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT;
460460
}

drivers/usb/host/ehci-q.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ qh_urb_transaction (
663663
*/
664664
i = urb->num_sgs;
665665
if (len > 0 && i > 0) {
666-
sg = urb->sg->sg;
666+
sg = urb->sg;
667667
buf = sg_dma_address(sg);
668668

669669
/* urb->transfer_buffer_length may be smaller than the

drivers/usb/host/whci/qset.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ static int qset_add_urb_sg(struct whc *whc, struct whc_qset *qset, struct urb *u
443443

444444
remaining = urb->transfer_buffer_length;
445445

446-
for_each_sg(urb->sg->sg, sg, urb->num_sgs, i) {
446+
for_each_sg(urb->sg, sg, urb->num_sgs, i) {
447447
dma_addr_t dma_addr;
448448
size_t dma_remaining;
449449
dma_addr_t sp, ep;
@@ -561,7 +561,7 @@ static int qset_add_urb_sg_linearize(struct whc *whc, struct whc_qset *qset,
561561

562562
remaining = urb->transfer_buffer_length;
563563

564-
for_each_sg(urb->sg->sg, sg, urb->sg->nents, i) {
564+
for_each_sg(urb->sg, sg, urb->num_sgs, i) {
565565
size_t len;
566566
size_t sg_remaining;
567567
void *orig;

drivers/usb/host/xhci-ring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb)
17881788

17891789
xhci_dbg(xhci, "count sg list trbs: \n");
17901790
num_trbs = 0;
1791-
for_each_sg(urb->sg->sg, sg, num_sgs, i) {
1791+
for_each_sg(urb->sg, sg, num_sgs, i) {
17921792
unsigned int previous_total_trbs = num_trbs;
17931793
unsigned int len = sg_dma_len(sg);
17941794

@@ -1951,7 +1951,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
19511951
* the amount of memory allocated for this scatter-gather list.
19521952
* 3. TRBs buffers can't cross 64KB boundaries.
19531953
*/
1954-
sg = urb->sg->sg;
1954+
sg = urb->sg;
19551955
addr = (u64) sg_dma_address(sg);
19561956
this_sg_len = sg_dma_len(sg);
19571957
trb_buff_len = TRB_MAX_BUFF_SIZE -

drivers/usb/mon/mon_bin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static unsigned int mon_bin_get_data(const struct mon_reader_bin *rp,
422422
}
423423

424424
/* 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) {
426426
if (length == 0 || PageHighMem(sg_page(sg)))
427427
break;
428428
this_len = min_t(unsigned int, sg->length, length);

drivers/usb/mon/mon_text.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
159159
if (src == NULL)
160160
return 'Z'; /* '0' would be not as pretty. */
161161
} else {
162-
struct scatterlist *sg = urb->sg->sg;
162+
struct scatterlist *sg = urb->sg;
163163

164164
if (PageHighMem(sg_page(sg)))
165165
return 'D';

include/linux/usb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ struct urb {
11951195
unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
11961196
void *transfer_buffer; /* (in) associated data buffer */
11971197
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 */
11991199
int num_sgs; /* (in) number of entries in the sg list */
12001200
u32 transfer_buffer_length; /* (in) data buffer length */
12011201
u32 actual_length; /* (return) actual transfer length */

0 commit comments

Comments
 (0)