USB: Change the scatterlist type in struct urb
authorMatthew Wilcox <matthew@wil.cx>
Sat, 1 May 2010 18:20:01 +0000 (12:20 -0600)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 20 May 2010 20:21:41 +0000 (13:21 -0700)
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>
drivers/usb/core/hcd.c
drivers/usb/core/message.c
drivers/usb/host/ehci-q.c
drivers/usb/host/whci/qset.c
drivers/usb/host/xhci-ring.c
drivers/usb/mon/mon_bin.c
drivers/usb/mon/mon_text.c
include/linux/usb.h

index 0abc5c537f39ce99a5f1cd4de88cd6530ad34f12..297c92e4bf8d48a5123ce49077174df0230ed62c 100644 (file)
@@ -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;
        if (urb->transfer_flags & URB_DMA_MAP_SG)
                dma_unmap_sg(hcd->self.controller,
-                               urb->sg->sg,
+                               urb->sg,
                                urb->num_sgs,
                                dir);
        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,
                        if (urb->num_sgs) {
                                int n = dma_map_sg(
                                                hcd->self.controller,
-                                               urb->sg->sg,
+                                               urb->sg,
                                                urb->num_sgs,
                                                dir);
                                if (n <= 0)
@@ -1359,9 +1359,7 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
                                                        URB_DMA_SG_COMBINED;
                                }
                        } else if (urb->sg) {
-                               struct scatterlist *sg;
-
-                               sg = (struct scatterlist *) urb->sg;
+                               struct scatterlist *sg = urb->sg;
                                urb->transfer_dma = dma_map_page(
                                                hcd->self.controller,
                                                sg_page(sg),
index d8329eb47d4ffc26cd9f88bea8e466459ce56c1c..63919b8abee1e3c0bf34644453effd27642cd569 100644 (file)
@@ -413,7 +413,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
                                        sg->length;
                        }
                }
-               io->urbs[0]->sg = io;
+               io->urbs[0]->sg = sg;
                io->urbs[0]->num_sgs = io->entries;
                io->entries = 1;
        } else {
@@ -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]->sg = (struct usb_sg_request *) sg;
+                       io->urbs[i]->sg = sg;
                }
                io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT;
        }
index 89521775c567abeaeb856e2ca3106ec4996ef9e0..11a79c4f4a9dbb67d5fad13ede3ae86a0c7097f5 100644 (file)
@@ -663,7 +663,7 @@ qh_urb_transaction (
         */
        i = urb->num_sgs;
        if (len > 0 && i > 0) {
-               sg = urb->sg->sg;
+               sg = urb->sg;
                buf = sg_dma_address(sg);
 
                /* urb->transfer_buffer_length may be smaller than the
index b388dd1fb4c4013fab6b47803a3aef3d63b7ee79..ab5a14fbfeeba0faf7a78e5e0a1870ee63e274a5 100644 (file)
@@ -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;
 
-       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;
                size_t dma_remaining;
                dma_addr_t sp, ep;
@@ -561,7 +561,7 @@ static int qset_add_urb_sg_linearize(struct whc *whc, struct whc_qset *qset,
 
        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 sg_remaining;
                void *orig;
index 9e27eb0c7004d31e03f4cc63fde93b99ddf08137..a67caef265b1e0b710d18be570bab0416c89817e 100644 (file)
@@ -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");
        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 len = sg_dma_len(sg);
 
@@ -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.
         * 3. TRBs buffers can't cross 64KB boundaries.
         */
-       sg = urb->sg->sg;
+       sg = urb->sg;
        addr = (u64) sg_dma_address(sg);
        this_sg_len = sg_dma_len(sg);
        trb_buff_len = TRB_MAX_BUFF_SIZE -
index 8a7968df278f95bb769853dc02b08a38d016205e..e7fa3644ba6a74ade9300d4cc5384e08bbfb30e2 100644 (file)
@@ -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 */
-               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)))
                                break;
                        this_len = min_t(unsigned int, sg->length, length);
index d56260280f54e38724a086643158d9dceb715b4f..a545d65f6e57b2e53bd81f104c90e2bd514e5028 100644 (file)
@@ -159,7 +159,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
                if (src == NULL)
                        return 'Z';     /* '0' would be not as pretty. */
        } else {
-               struct scatterlist *sg = urb->sg->sg;
+               struct scatterlist *sg = urb->sg;
 
                if (PageHighMem(sg_page(sg)))
                        return 'D';
index cf3b289a87a27dd4471f95408b6c284e1b0e3a90..eec9e74f332fbb799fa5a2008e9d0aad444252dc 100644 (file)
@@ -1195,7 +1195,7 @@ struct urb {
        unsigned int transfer_flags;    /* (in) URB_SHORT_NOT_OK | ...*/
        void *transfer_buffer;          /* (in) associated data 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 */
        u32 transfer_buffer_length;     /* (in) data buffer length */
        u32 actual_length;              /* (return) actual transfer length */