]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
io mapping: clean up #ifdefs
authorKeith Packard <keithp@keithp.com>
Mon, 3 Nov 2008 17:21:45 +0000 (18:21 +0100)
committerIngo Molnar <mingo@elte.hu>
Mon, 3 Nov 2008 17:21:45 +0000 (18:21 +0100)
Impact: cleanup

clean up ifdefs: change #ifdef CONFIG_X86_32/64 to
CONFIG_HAVE_ATOMIC_IOMAP.

flip around the #ifdef sections to clean up the structure.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/Kconfig
include/linux/io-mapping.h

index 6f20718d3156b27badfe7774f09bb89f8bfe34f7..e60c59b81bdd78b2f29607d0ceb5b8ecc48c86b6 100644 (file)
@@ -1894,6 +1894,10 @@ config SYSVIPC_COMPAT
 endmenu
 
 
+config HAVE_ATOMIC_IOMAP
+       def_bool y
+       depends on X86_32
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
index 1b566993db6e07530128beb4aa878bb6ca7c6fea..82df31726a546de40a1d010c588f56f7c1d3955c 100644 (file)
 /* this struct isn't actually defined anywhere */
 struct io_mapping;
 
-#ifdef CONFIG_X86_64
+#ifdef CONFIG_HAVE_ATOMIC_IOMAP
+
+/*
+ * For small address space machines, mapping large objects
+ * into the kernel virtual space isn't practical. Where
+ * available, use fixmap support to dynamically map pages
+ * of the object at run time.
+ */
 
-/* Create the io_mapping object*/
 static inline struct io_mapping *
 io_mapping_create_wc(unsigned long base, unsigned long size)
 {
-       return (struct io_mapping *) ioremap_wc(base, size);
+       return (struct io_mapping *) base;
 }
 
 static inline void
 io_mapping_free(struct io_mapping *mapping)
 {
-       iounmap(mapping);
 }
 
 /* Atomic map/unmap */
 static inline void *
 io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
 {
-       return ((char *) mapping) + offset;
+       offset += (unsigned long) mapping;
+       return iomap_atomic_prot_pfn(offset >> PAGE_SHIFT, KM_USER0,
+                                    __pgprot(__PAGE_KERNEL_WC));
 }
 
 static inline void
 io_mapping_unmap_atomic(void *vaddr)
 {
+       iounmap_atomic(vaddr, KM_USER0);
 }
 
-/* Non-atomic map/unmap */
 static inline void *
 io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
 {
-       return ((char *) mapping) + offset;
+       offset += (unsigned long) mapping;
+       return ioremap_wc(offset, PAGE_SIZE);
 }
 
 static inline void
 io_mapping_unmap(void *vaddr)
 {
+       iounmap(vaddr);
 }
 
-#endif /* CONFIG_X86_64 */
+#else
 
-#ifdef CONFIG_X86_32
+/* Create the io_mapping object*/
 static inline struct io_mapping *
 io_mapping_create_wc(unsigned long base, unsigned long size)
 {
-       return (struct io_mapping *) base;
+       return (struct io_mapping *) ioremap_wc(base, size);
 }
 
 static inline void
 io_mapping_free(struct io_mapping *mapping)
 {
+       iounmap(mapping);
 }
 
 /* Atomic map/unmap */
 static inline void *
 io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
 {
-       offset += (unsigned long) mapping;
-       return iomap_atomic_prot_pfn(offset >> PAGE_SHIFT, KM_USER0,
-                                    __pgprot(__PAGE_KERNEL_WC));
+       return ((char *) mapping) + offset;
 }
 
 static inline void
 io_mapping_unmap_atomic(void *vaddr)
 {
-       iounmap_atomic(vaddr, KM_USER0);
 }
 
+/* Non-atomic map/unmap */
 static inline void *
 io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
 {
-       offset += (unsigned long) mapping;
-       return ioremap_wc(offset, PAGE_SIZE);
+       return ((char *) mapping) + offset;
 }
 
 static inline void
 io_mapping_unmap(void *vaddr)
 {
-       iounmap(vaddr);
 }
-#endif /* CONFIG_X86_32 */
+
+#endif /* HAVE_ATOMIC_IOMAP */
 
 #endif /* _LINUX_IO_MAPPING_H */