USB: introduce unmap_urb_setup_for_dma()
authorMartin Fuzzey <mfuzzey@gmail.com>
Thu, 30 Sep 2010 22:21:55 +0000 (00:21 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 22 Oct 2010 17:22:03 +0000 (10:22 -0700)
Split unmap_urb_for_dma() to allow just the setup buffer
to be unmapped. This allows HCDs to use PIO for the setup
buffer if it is not suitable for DMA.

Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hcd.c
include/linux/usb/hcd.h

index cb2d894321da7d86424c81731ed3a4bda214cbcb..61800f77dac80f0064cd7184f858241a35e2fc8c 100644 (file)
@@ -1263,10 +1263,8 @@ static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle,
        *dma_handle = 0;
 }
 
-void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
+void unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb)
 {
-       enum dma_data_direction dir;
-
        if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
                dma_unmap_single(hcd->self.controller,
                                urb->setup_dma,
@@ -1279,6 +1277,17 @@ void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
                                sizeof(struct usb_ctrlrequest),
                                DMA_TO_DEVICE);
 
+       /* Make it safe to call this routine more than once */
+       urb->transfer_flags &= ~(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL);
+}
+EXPORT_SYMBOL_GPL(unmap_urb_setup_for_dma);
+
+void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
+{
+       enum dma_data_direction dir;
+
+       unmap_urb_setup_for_dma(hcd, 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,
@@ -1303,8 +1312,7 @@ void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
                                dir);
 
        /* Make it safe to call this routine more than once */
-       urb->transfer_flags &= ~(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL |
-                       URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
+       urb->transfer_flags &= ~(URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
                        URB_DMA_MAP_SINGLE | URB_MAP_LOCAL);
 }
 EXPORT_SYMBOL_GPL(unmap_urb_for_dma);
index fe89f7c298aa06ed8f4abe4bbb55c09147671281..0b6e751ea0b15ec6f5cd1682a7244a0ed490ae20 100644 (file)
@@ -329,6 +329,7 @@ extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags);
 extern int usb_hcd_unlink_urb(struct urb *urb, int status);
 extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb,
                int status);
+extern void unmap_urb_setup_for_dma(struct usb_hcd *, struct urb *);
 extern void unmap_urb_for_dma(struct usb_hcd *, struct urb *);
 extern void usb_hcd_flush_endpoint(struct usb_device *udev,
                struct usb_host_endpoint *ep);