Commit 58f2266f authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Greg Kroah-Hartman

usb: core: Allow compilation on platforms where NO_DMA=y

Some platforms don't have DMA, but we should still be able to build USB
drivers for these platforms. They could still be used through vhci_hcd,
usbip_host, or maybe something like USB passthrough in UML from a
capable host.

If NO_DMA=y:

    ERROR: "dma_pool_destroy" [drivers/usb/core/usbcore.ko] undefined!
    ERROR: "bad_dma_ops" [drivers/usb/core/usbcore.ko] undefined!
    ERROR: "dma_pool_free" [drivers/usb/core/usbcore.ko] undefined!
    ERROR: "dma_pool_alloc" [drivers/usb/core/usbcore.ko] undefined!
    ERROR: "dma_pool_create" [drivers/usb/core/usbcore.ko] undefined!

Add a few checks for CONFIG_HAS_DMA to fix this.
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ef976ea3
...@@ -62,8 +62,9 @@ int hcd_buffer_create(struct usb_hcd *hcd) ...@@ -62,8 +62,9 @@ int hcd_buffer_create(struct usb_hcd *hcd)
char name[16]; char name[16];
int i, size; int i, size;
if (!hcd->self.controller->dma_mask && if (!IS_ENABLED(CONFIG_HAS_DMA) ||
!(hcd->driver->flags & HCD_LOCAL_MEM)) (!hcd->self.controller->dma_mask &&
!(hcd->driver->flags & HCD_LOCAL_MEM)))
return 0; return 0;
for (i = 0; i < HCD_BUFFER_POOLS; i++) { for (i = 0; i < HCD_BUFFER_POOLS; i++) {
...@@ -93,6 +94,9 @@ void hcd_buffer_destroy(struct usb_hcd *hcd) ...@@ -93,6 +94,9 @@ void hcd_buffer_destroy(struct usb_hcd *hcd)
{ {
int i; int i;
if (!IS_ENABLED(CONFIG_HAS_DMA))
return;
for (i = 0; i < HCD_BUFFER_POOLS; i++) { for (i = 0; i < HCD_BUFFER_POOLS; i++) {
struct dma_pool *pool = hcd->pool[i]; struct dma_pool *pool = hcd->pool[i];
...@@ -119,8 +123,9 @@ void *hcd_buffer_alloc( ...@@ -119,8 +123,9 @@ void *hcd_buffer_alloc(
int i; int i;
/* some USB hosts just use PIO */ /* some USB hosts just use PIO */
if (!bus->controller->dma_mask && if (!IS_ENABLED(CONFIG_HAS_DMA) ||
!(hcd->driver->flags & HCD_LOCAL_MEM)) { (!bus->controller->dma_mask &&
!(hcd->driver->flags & HCD_LOCAL_MEM))) {
*dma = ~(dma_addr_t) 0; *dma = ~(dma_addr_t) 0;
return kmalloc(size, mem_flags); return kmalloc(size, mem_flags);
} }
...@@ -145,8 +150,9 @@ void hcd_buffer_free( ...@@ -145,8 +150,9 @@ void hcd_buffer_free(
if (!addr) if (!addr)
return; return;
if (!bus->controller->dma_mask && if (!IS_ENABLED(CONFIG_HAS_DMA) ||
!(hcd->driver->flags & HCD_LOCAL_MEM)) { (!bus->controller->dma_mask &&
!(hcd->driver->flags & HCD_LOCAL_MEM))) {
kfree(addr); kfree(addr);
return; return;
} }
......
...@@ -1428,7 +1428,8 @@ static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle, ...@@ -1428,7 +1428,8 @@ static void hcd_free_coherent(struct usb_bus *bus, dma_addr_t *dma_handle,
void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb) void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb)
{ {
if (urb->transfer_flags & URB_SETUP_MAP_SINGLE) if (IS_ENABLED(CONFIG_HAS_DMA) &&
(urb->transfer_flags & URB_SETUP_MAP_SINGLE))
dma_unmap_single(hcd->self.controller, dma_unmap_single(hcd->self.controller,
urb->setup_dma, urb->setup_dma,
sizeof(struct usb_ctrlrequest), sizeof(struct usb_ctrlrequest),
...@@ -1460,17 +1461,20 @@ void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) ...@@ -1460,17 +1461,20 @@ void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
usb_hcd_unmap_urb_setup_for_dma(hcd, urb); usb_hcd_unmap_urb_setup_for_dma(hcd, 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 (IS_ENABLED(CONFIG_HAS_DMA) &&
(urb->transfer_flags & URB_DMA_MAP_SG))
dma_unmap_sg(hcd->self.controller, dma_unmap_sg(hcd->self.controller,
urb->sg, urb->sg,
urb->num_sgs, urb->num_sgs,
dir); dir);
else if (urb->transfer_flags & URB_DMA_MAP_PAGE) else if (IS_ENABLED(CONFIG_HAS_DMA) &&
(urb->transfer_flags & URB_DMA_MAP_PAGE))
dma_unmap_page(hcd->self.controller, dma_unmap_page(hcd->self.controller,
urb->transfer_dma, urb->transfer_dma,
urb->transfer_buffer_length, urb->transfer_buffer_length,
dir); dir);
else if (urb->transfer_flags & URB_DMA_MAP_SINGLE) else if (IS_ENABLED(CONFIG_HAS_DMA) &&
(urb->transfer_flags & URB_DMA_MAP_SINGLE))
dma_unmap_single(hcd->self.controller, dma_unmap_single(hcd->self.controller,
urb->transfer_dma, urb->transfer_dma,
urb->transfer_buffer_length, urb->transfer_buffer_length,
...@@ -1512,7 +1516,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, ...@@ -1512,7 +1516,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
if (usb_endpoint_xfer_control(&urb->ep->desc)) { if (usb_endpoint_xfer_control(&urb->ep->desc)) {
if (hcd->self.uses_pio_for_control) if (hcd->self.uses_pio_for_control)
return ret; return ret;
if (hcd->self.uses_dma) { if (IS_ENABLED(CONFIG_HAS_DMA) && hcd->self.uses_dma) {
urb->setup_dma = dma_map_single( urb->setup_dma = dma_map_single(
hcd->self.controller, hcd->self.controller,
urb->setup_packet, urb->setup_packet,
...@@ -1538,7 +1542,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, ...@@ -1538,7 +1542,7 @@ int usb_hcd_map_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_buffer_length != 0 if (urb->transfer_buffer_length != 0
&& !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) {
if (hcd->self.uses_dma) { if (IS_ENABLED(CONFIG_HAS_DMA) && hcd->self.uses_dma) {
if (urb->num_sgs) { if (urb->num_sgs) {
int n; int n;
......
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