Messages in this thread | | | From | Arnd Bergmann <> | Subject | Re: [PATCH] asm-generic: add a dma-mapping.h file | Date | Tue, 26 May 2009 13:35:41 +0100 |
| |
On Tuesday 26 May 2009, FUJITA Tomonori wrote: > > dma_get_cache_alignment() is still less generic than > > the other functions, as this is still architecture > > specific. Should I leave that out as well then? > > Yes, I think that only adding generic functions is a better > approach. Overriding with #ifdef is really ugly. >
Ok, will do.
[trimming Cc list a bit, as the subject has changed]
Could you be more specific as to why you think the #ifdef in this file is ugly? I agree that we should always avoid #ifdef in a device driver file or around the usage of an API, but we use it everywhere when defining an optional API, e.g.
#ifdef CONFIG_DMA_API_DEBUG extern void dma_debug_add_bus(struct bus_type *bus); #else static inline void dma_debug_add_bus(struct bus_type *bus) { { #endif
or
#ifndef clear_user_highpage static inline void clear_user_highpage(struct page *page, unsigned long vaddr) { void *addr = kmap_atomic(page, KM_USER0); clear_user_page(addr, vaddr, page); kunmap_atomic(addr, KM_USER0); } #endif
This has always made a lot of sense to me when you are defining something that you want to become a No-op in certain configurations or that only needs special handling in a few cases. IIRC, Linus has stated that he prefers the second of the two styles above when you have the choice, which is why I started out that way, while for the dma_debug stuff, the CONFIG_ symbol clearly makes sense.
Arnd <><
| |