Make irq_*_affinity depend on CONFIG_GENERIC_HARDIRQS too.
[safe/jmp/linux-2.6] / kernel / resource.c
index 4337063..fd5d7d5 100644 (file)
@@ -620,10 +620,11 @@ resource_size_t resource_alignment(struct resource *res)
  * @start: resource start address
  * @n: resource region size
  * @name: reserving caller's ID string
+ * @flags: IO resource flags
  */
 struct resource * __request_region(struct resource *parent,
                                   resource_size_t start, resource_size_t n,
-                                  const char *name)
+                                  const char *name, int flags)
 {
        struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
 
@@ -634,6 +635,7 @@ struct resource * __request_region(struct resource *parent,
        res->start = start;
        res->end = start + n - 1;
        res->flags = IORESOURCE_BUSY;
+       res->flags |= flags;
 
        write_lock(&resource_lock);
 
@@ -679,7 +681,7 @@ int __check_region(struct resource *parent, resource_size_t start,
 {
        struct resource * res;
 
-       res = __request_region(parent, start, n, "check-region");
+       res = __request_region(parent, start, n, "check-region", 0);
        if (!res)
                return -EBUSY;
 
@@ -776,7 +778,7 @@ struct resource * __devm_request_region(struct device *dev,
        dr->start = start;
        dr->n = n;
 
-       res = __request_region(parent, start, n, name);
+       res = __request_region(parent, start, n, name, 0);
        if (res)
                devres_add(dev, dr);
        else
@@ -853,6 +855,15 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
                if (PFN_DOWN(p->start) <= PFN_DOWN(addr) &&
                    PFN_DOWN(p->end) >= PFN_DOWN(addr + size - 1))
                        continue;
+               /*
+                * if a resource is "BUSY", it's not a hardware resource
+                * but a driver mapping of such a resource; we don't want
+                * to warn for those; some drivers legitimately map only
+                * partial hardware resources. (example: vesafb)
+                */
+               if (p->flags & IORESOURCE_BUSY)
+                       continue;
+
                printk(KERN_WARNING "resource map sanity check conflict: "
                       "0x%llx 0x%llx 0x%llx 0x%llx %s\n",
                       (unsigned long long)addr,
@@ -867,3 +878,57 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
 
        return err;
 }
+
+#ifdef CONFIG_STRICT_DEVMEM
+static int strict_iomem_checks = 1;
+#else
+static int strict_iomem_checks;
+#endif
+
+/*
+ * check if an address is reserved in the iomem resource tree
+ * returns 1 if reserved, 0 if not reserved.
+ */
+int iomem_is_exclusive(u64 addr)
+{
+       struct resource *p = &iomem_resource;
+       int err = 0;
+       loff_t l;
+       int size = PAGE_SIZE;
+
+       if (!strict_iomem_checks)
+               return 0;
+
+       addr = addr & PAGE_MASK;
+
+       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)
+                       break;
+               if (p->end < addr)
+                       continue;
+               if (p->flags & IORESOURCE_BUSY &&
+                    p->flags & IORESOURCE_EXCLUSIVE) {
+                       err = 1;
+                       break;
+               }
+       }
+       read_unlock(&resource_lock);
+
+       return err;
+}
+
+static int __init strict_iomem(char *str)
+{
+       if (strstr(str, "relaxed"))
+               strict_iomem_checks = 0;
+       if (strstr(str, "strict"))
+               strict_iomem_checks = 1;
+       return 1;
+}
+
+__setup("iomem=", strict_iomem);