]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - lib/swiotlb.c
V4L/DVB (9743): em28xx: fix oops audio
[linux-2.6-omap-h63xx.git] / lib / swiotlb.c
index 240a67c2c979f8f7f3230f27b28bc610288c373e..78330c37a61bd1682768a61148be00a9a083003a 100644 (file)
@@ -276,11 +276,7 @@ cleanup1:
 static int
 address_needs_mapping(struct device *hwdev, dma_addr_t addr, size_t size)
 {
-       dma_addr_t mask = 0xffffffff;
-       /* If the device has a mask, use it, otherwise default to 32 bits */
-       if (hwdev && hwdev->dma_mask)
-               mask = *hwdev->dma_mask;
-       return !is_buffer_dma_capable(mask, addr, size);
+       return !is_buffer_dma_capable(dma_get_mask(hwdev), addr, size);
 }
 
 static int is_swiotlb_buffer(char *addr)
@@ -501,8 +497,10 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
                printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n",
                       (unsigned long long)*hwdev->dma_mask,
                       (unsigned long long)dev_addr);
-               panic("swiotlb_alloc_coherent: allocated memory is out of "
-                     "range for device");
+
+               /* DMA_TO_DEVICE to avoid memcpy in unmap_single */
+               unmap_single(hwdev, ret, size, DMA_TO_DEVICE);
+               return NULL;
        }
        *dma_handle = dev_addr;
        return ret;