|
@@ -827,3 +827,36 @@ static int __init reserve_setup(char *str)
|
|
|
}
|
|
|
|
|
|
__setup("reserve=", reserve_setup);
|
|
|
+
|
|
|
+/*
|
|
|
+ * Check if the requested addr and size spans more than any slot in the
|
|
|
+ * iomem resource tree.
|
|
|
+ */
|
|
|
+int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
|
|
|
+{
|
|
|
+ struct resource *p = &iomem_resource;
|
|
|
+ int err = 0;
|
|
|
+ loff_t l;
|
|
|
+
|
|
|
+ read_lock(&resource_lock);
|
|
|
+ for (p = p->child; p ; p = r_next(NULL, p, &l)) {
|
|
|
+ /*
|
|
|
+ * We can probably skip the resources without
|
|
|
+ * IORESOURCE_IO attribute?
|
|
|
+ */
|
|
|
+ if (p->start >= addr + size)
|
|
|
+ continue;
|
|
|
+ if (p->end < addr)
|
|
|
+ continue;
|
|
|
+ if (p->start <= addr && (p->end >= addr + size - 1))
|
|
|
+ continue;
|
|
|
+ printk(KERN_WARNING "resource map sanity check conflict: "
|
|
|
+ "0x%llx 0x%llx 0x%llx 0x%llx %s\n",
|
|
|
+ addr, addr + size - 1, p->start, p->end, p->name);
|
|
|
+ err = -1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ read_unlock(&resource_lock);
|
|
|
+
|
|
|
+ return err;
|
|
|
+}
|