Commit 45a07e77 authored by Glauber Costa's avatar Glauber Costa Committed by Ingo Molnar

x86: use a fallback dev for i386

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: default avatarGlauber Costa <gcosta@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent d1a07902
...@@ -14,6 +14,16 @@ ...@@ -14,6 +14,16 @@
#include <linux/module.h> #include <linux/module.h>
#include <asm/io.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, static int dma_alloc_from_coherent_mem(struct device *dev, ssize_t size,
dma_addr_t *dma_handle, void **ret) dma_addr_t *dma_handle, void **ret)
{ {
...@@ -75,6 +85,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size, ...@@ -75,6 +85,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff)) if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
gfp |= GFP_DMA; gfp |= GFP_DMA;
if (!dev)
dev = &fallback_dev;
page = dma_alloc_pages(dev, gfp, order); page = dma_alloc_pages(dev, gfp, order);
if (page == NULL) if (page == NULL)
return NULL; return NULL;
......
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