]> Pileus Git - ~andy/linux/commitdiff
resources: add resource_overlaps()
authorWei Yang <weiyang@linux.vnet.ibm.com>
Thu, 26 Apr 2012 07:32:55 +0000 (15:32 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 7 May 2012 16:58:57 +0000 (10:58 -0600)
Add resource_overlaps(), which returns true if two resources overlap at all.

Use this to replace the complicated check in coalesce_windows().

Signed-Off-By: Wei Yang <weiyang@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
arch/x86/pci/acpi.c
include/linux/ioport.h

index 8a17b23f8c8467dd1e419619c7178b2923039dd6..fc09c2754e0897eab4ee796153d01670a0141f4f 100644 (file)
@@ -245,13 +245,6 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
        return AE_OK;
 }
 
-static bool resource_contains(struct resource *res, resource_size_t point)
-{
-       if (res->start <= point && point <= res->end)
-               return true;
-       return false;
-}
-
 static void coalesce_windows(struct pci_root_info *info, unsigned long type)
 {
        int i, j;
@@ -272,10 +265,7 @@ static void coalesce_windows(struct pci_root_info *info, unsigned long type)
                         * our resources no longer match the ACPI _CRS, but
                         * the kernel resource tree doesn't allow overlaps.
                         */
-                       if (resource_contains(res1, res2->start) ||
-                           resource_contains(res1, res2->end) ||
-                           resource_contains(res2, res1->start) ||
-                           resource_contains(res2, res1->end)) {
+                       if (resource_overlaps(res1, res2)) {
                                res1->start = min(res1->start, res2->start);
                                res1->end = max(res1->end, res2->end);
                                dev_info(&info->bridge->dev,
index e885ba23de7017882457ff0dc2d6fbb6f6575b13..589e0e75efae2dc1146da2cc0f92e6c649f834ed 100644 (file)
@@ -223,5 +223,12 @@ extern int
 walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
                void *arg, int (*func)(unsigned long, unsigned long, void *));
 
+/* True if any part of r1 overlaps r2 */
+static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
+{
+       return (r1->start <= r2->end && r1->end >= r2->start);
+}
+
+
 #endif /* __ASSEMBLY__ */
 #endif /* _LINUX_IOPORT_H */