On Mon, May 18, 2009 at 00:45, Arnd Bergmann <arnd@xxxxxxxx> wrote: > --- /dev/null > +++ b/include/asm-generic/dma-mapping.h > @@ -0,0 +1,399 @@ > +#ifndef _ASM_GENERIC_DMA_MAPPING_H > +#define _ASM_GENERIC_DMA_MAPPING_H > +/* > + * This provides a no-op variant of the DMA mapping API, > + * for use by architectures that do not actually support > + * DMA, or that are fully consistent and linear-mapped > + * in their DMA implementation. > + */ > + > +#include <asm/scatterlist.h> > + > +/* > + * If any driver asks for DMA, it's not supported. > + */ > +#ifndef dma_supported > +static inline int > +dma_supported(struct device *dev, u64 mask) > +{ > + return 0; > +} > +#endif > + > +#ifndef dma_set_mask > +static inline int > +dma_set_mask(struct device *dev, u64 dma_mask) > +{ > + if (!dev->dma_mask || !dma_supported(dev, dma_mask)) > + return -EIO; > + > + *dev->dma_mask = dma_mask; > + return 0; > +} > +#endif > + > +/** > + * dma_alloc_coherent - allocate consistent memory for DMA > + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices > + * @size: required memory size > + * @handle: bus-specific DMA address > + * > + * Allocate some uncached, unbuffered memory for a device for > + * performing DMA. This function allocates pages, and will > + * return the CPU-viewed address, and sets @handle to be the > + * device-viewed address. > + */ > +#ifndef dma_alloc_coherent > +static inline void * > +dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, > + gfp_t flag) > +{ > + void *virt = kmalloc(size, flag); kmalloc() may fail. > + *dma_handle = virt_to_phys(virt); Not all variants of virt_to_phys() may handle the NULL case very well. I took a statistically invalid sample: some just cast to unsigned long, other subtract PAGE_OFFSET. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html