sched: move test_sd_parent() to an SMP section of sched.h
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / mm / testmmiotrace.c
blobab50a8d7402c8c7f4320f0fd803a22a2d9abf84a
1 /*
2 * Written by Pekka Paalanen, 2008 <pq@iki.fi>
3 */
4 #include <linux/module.h>
5 #include <linux/io.h>
6 #include <linux/mmiotrace.h>
8 #define MODULE_NAME "testmmiotrace"
10 static unsigned long mmio_address;
11 module_param(mmio_address, ulong, 0);
12 MODULE_PARM_DESC(mmio_address, "Start address of the mapping of 16 kB.");
14 static void do_write_test(void __iomem *p)
16 unsigned int i;
17 mmiotrace_printk("Write test.\n");
18 for (i = 0; i < 256; i++)
19 iowrite8(i, p + i);
20 for (i = 1024; i < (5 * 1024); i += 2)
21 iowrite16(i * 12 + 7, p + i);
22 for (i = (5 * 1024); i < (16 * 1024); i += 4)
23 iowrite32(i * 212371 + 13, p + i);
26 static void do_read_test(void __iomem *p)
28 unsigned int i;
29 mmiotrace_printk("Read test.\n");
30 for (i = 0; i < 256; i++)
31 ioread8(p + i);
32 for (i = 1024; i < (5 * 1024); i += 2)
33 ioread16(p + i);
34 for (i = (5 * 1024); i < (16 * 1024); i += 4)
35 ioread32(p + i);
38 static void do_test(void)
40 void __iomem *p = ioremap_nocache(mmio_address, 0x4000);
41 if (!p) {
42 pr_err(MODULE_NAME ": could not ioremap, aborting.\n");
43 return;
45 mmiotrace_printk("ioremap returned %p.\n", p);
46 do_write_test(p);
47 do_read_test(p);
48 iounmap(p);
51 static int __init init(void)
53 if (mmio_address == 0) {
54 pr_err(MODULE_NAME ": you have to use the module argument "
55 "mmio_address.\n");
56 pr_err(MODULE_NAME ": DO NOT LOAD THIS MODULE UNLESS"
57 " YOU REALLY KNOW WHAT YOU ARE DOING!\n");
58 return -ENXIO;
61 pr_warning(MODULE_NAME ": WARNING: mapping 16 kB @ 0x%08lx "
62 "in PCI address space, and writing "
63 "rubbish in there.\n", mmio_address);
64 do_test();
65 return 0;
68 static void __exit cleanup(void)
70 pr_debug(MODULE_NAME ": unloaded.\n");
73 module_init(init);
74 module_exit(cleanup);
75 MODULE_LICENSE("GPL");