]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/sh/kernel/io_trapped.c
Merge branch 'fix' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa-linux-2.6
[mv-sheeva.git] / arch / sh / kernel / io_trapped.c
index 0bfdc9a34e1aeb00f1d18d9189acd4716bd5b865..c22853b059efd118528cbff82a02b399412add8c 100644 (file)
@@ -13,6 +13,8 @@
 #include <linux/mm.h>
 #include <linux/bitops.h>
 #include <linux/vmalloc.h>
+#include <linux/module.h>
+#include <linux/init.h>
 #include <asm/system.h>
 #include <asm/mmu_context.h>
 #include <asm/uaccess.h>
 #include <asm/io_trapped.h>
 
 #define TRAPPED_PAGES_MAX 16
-#define MAX(a, b) (((a) >= (b)) ? (a) : (b))
 
 #ifdef CONFIG_HAS_IOPORT
 LIST_HEAD(trapped_io);
+EXPORT_SYMBOL_GPL(trapped_io);
 #endif
 #ifdef CONFIG_HAS_IOMEM
 LIST_HEAD(trapped_mem);
+EXPORT_SYMBOL_GPL(trapped_mem);
 #endif
 static DEFINE_SPINLOCK(trapped_lock);
 
-int __init register_trapped_io(struct trapped_io *tiop)
+static int trapped_io_disable __read_mostly;
+
+static int __init trapped_io_setup(char *__unused)
+{
+       trapped_io_disable = 1;
+       return 1;
+}
+__setup("noiotrap", trapped_io_setup);
+
+int register_trapped_io(struct trapped_io *tiop)
 {
        struct resource *res;
        unsigned long len = 0, flags = 0;
        struct page *pages[TRAPPED_PAGES_MAX];
        int k, n;
 
+       if (unlikely(trapped_io_disable))
+               return 0;
+
        /* structure must be page aligned */
        if ((unsigned long)tiop & (PAGE_SIZE - 1))
                goto bad;
@@ -87,6 +102,7 @@ int __init register_trapped_io(struct trapped_io *tiop)
        pr_warning("unable to install trapped io filter\n");
        return -1;
 }
+EXPORT_SYMBOL_GPL(register_trapped_io);
 
 void __iomem *match_trapped_io_handler(struct list_head *list,
                                       unsigned long offset,
@@ -114,6 +130,7 @@ void __iomem *match_trapped_io_handler(struct list_head *list,
        spin_unlock_irq(&trapped_lock);
        return NULL;
 }
+EXPORT_SYMBOL_GPL(match_trapped_io_handler);
 
 static struct trapped_io *lookup_tiop(unsigned long address)
 {
@@ -211,7 +228,9 @@ static unsigned long from_device(void *dst, const void *src, unsigned long cnt)
        if (!src_addr)
                return cnt;
 
-       tmp = copy_word(src_addr, MAX(cnt, (tiop->minimum_bus_width / 8)),
+       tmp = copy_word(src_addr,
+                       max_t(unsigned long, cnt,
+                             (tiop->minimum_bus_width / 8)),
                        (unsigned long)dst, cnt);
 
        pr_debug("trapped io read 0x%08lx -> 0x%08llx\n", src_addr, tmp);
@@ -233,7 +252,8 @@ static unsigned long to_device(void *dst, const void *src, unsigned long cnt)
                return cnt;
 
        tmp = copy_word((unsigned long)src, cnt,
-                       dst_addr, MAX(cnt, (tiop->minimum_bus_width / 8)));
+                       dst_addr, max_t(unsigned long, cnt,
+                                       (tiop->minimum_bus_width / 8)));
 
        pr_debug("trapped io write 0x%08lx -> 0x%08llx\n", dst_addr, tmp);
        return 0;