Re: [PATCH 0/3] dma-mapping:remove CONFIG_HAVE_DMA_ATTRS

From: Ming Lei
Date: Sun Jul 05 2009 - 09:37:32 EST


2009/7/5 Ming Lei <tom.leiming@xxxxxxxxx>:
> On Sun, 5 Jul 2009 13:19:36 +0200
> Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
>> On Saturday 04 July 2009, tom.leiming@xxxxxxxxx wrote:
>> > 2,Disabling CONFIG_HAVE_DMA_ATTRS may lead to a compile failure;
>>
>> I'm not sure I understand this point. CONFIG_HAVE_DMA_ATTRS tells
>> the common code whether the architecture understands dma attributes.
>
> If a new arch does not define CONFIG_HAVE_DMA_ATTRS but uses
> dma-mapping-common.h, it will lead to a compile failure.
>
> include/asm-generic/dma-mapping-common.h
>
>        #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a,
>        s, r, NULL)
>        ...
>
> include/linux/dma-mapping.h
>
>        #ifndef CONFIG_HAVE_DMA_ATTRS
>        struct dma_attrs;
>
>        #define dma_map_single_attrs(dev, cpu_addr, size, dir, attrs) \
>        dma_map_single(dev, cpu_addr, size, dir)
>        ...
>        #endif
>
>

I have another idea to fix the possible compile failure. Does the
following patch
work?

diff --git a/include/asm-generic/dma-mapping-common.h
b/include/asm-generic/dma-mapping-common.h
index 5406a60..39e2ec5 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -6,6 +6,8 @@
#include <linux/dma-debug.h>
#include <linux/dma-attrs.h>

+#define ARCH_USE_DMA_MAPPING_COMMON
+
static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
size_t size,
enum dma_data_direction dir,
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 07dfd46..4be1121 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -219,6 +219,7 @@ static inline void
dmam_release_declared_memory(struct device *dev)
}
#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */

+#ifndef ARCH_USE_DMA_MAPPING_COMMON
#ifndef CONFIG_HAVE_DMA_ATTRS
struct dma_attrs;

@@ -235,5 +236,7 @@ struct dma_attrs;
dma_unmap_sg(dev, sgl, nents, dir)

#endif /* CONFIG_HAVE_DMA_ATTRS */
+#endif /* ARCH_USE_DMA_MAPPING_COMMON */
+

#endif



--
Lei Ming
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/