Merge branch 'v4l_for_2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/mcheha...
[safe/jmp/linux-2.6] / include / linux / io-mapping.h
index f1ed66c..25085dd 100644 (file)
@@ -19,6 +19,7 @@
 #define _LINUX_IO_MAPPING_H
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/page.h>
 #include <asm/iomap.h>
@@ -51,23 +52,28 @@ io_mapping_create_wc(resource_size_t base, unsigned long size)
        struct io_mapping *iomap;
        pgprot_t prot;
 
-       if (!reserve_io_memtype_wc(base, size, &prot))
-               return NULL;
-
        iomap = kmalloc(sizeof(*iomap), GFP_KERNEL);
        if (!iomap)
-               return NULL;
+               goto out_err;
+
+       if (iomap_create_wc(base, size, &prot))
+               goto out_free;
 
        iomap->base = base;
        iomap->size = size;
        iomap->prot = prot;
        return iomap;
+
+out_free:
+       kfree(iomap);
+out_err:
+       return NULL;
 }
 
 static inline void
 io_mapping_free(struct io_mapping *mapping)
 {
-       free_io_memtype(mapping->base, mapping->size);
+       iomap_free(mapping->base, mapping->size);
        kfree(mapping);
 }
 
@@ -93,8 +99,11 @@ io_mapping_unmap_atomic(void *vaddr)
 static inline void *
 io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
 {
+       resource_size_t phys_addr;
+
        BUG_ON(offset >= mapping->size);
-       resource_size_t phys_addr = mapping->base + offset;
+       phys_addr = mapping->base + offset;
+
        return ioremap_wc(phys_addr, PAGE_SIZE);
 }