]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
x86: use a fallback dev for i386
authorGlauber Costa <gcosta@redhat.com>
Tue, 8 Apr 2008 16:21:04 +0000 (13:21 -0300)
committerIngo Molnar <mingo@elte.hu>
Sat, 19 Apr 2008 17:19:58 +0000 (19:19 +0200)
We can use a fallback dev for cases of a NULL device being passed (mostly ISA)
This comes from x86_64 implementation.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/pci-dma_32.c

index 0d630ae3d9106928a931e79bbcc12dbdb59ddb1b..0600a37ba835753422851c1446aaa5b29055aa24 100644 (file)
 #include <linux/module.h>
 #include <asm/io.h>
 
+/* Dummy device used for NULL arguments (normally ISA). Better would
+   be probably a smaller DMA mask, but this is bug-to-bug compatible
+   to i386. */
+struct device fallback_dev = {
+       .bus_id = "fallback device",
+       .coherent_dma_mask = DMA_32BIT_MASK,
+       .dma_mask = &fallback_dev.coherent_dma_mask,
+};
+
+
 static int dma_alloc_from_coherent_mem(struct device *dev, ssize_t size,
                                       dma_addr_t *dma_handle, void **ret)
 {
@@ -75,6 +85,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
        if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
                gfp |= GFP_DMA;
 
+       if (!dev)
+               dev = &fallback_dev;
+
        page = dma_alloc_pages(dev, gfp, order);
        if (page == NULL)
                return NULL;