diff options
author | Wei Yang <weiyang@linux.vnet.ibm.com> | 2012-04-26 03:32:55 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-05-07 12:58:57 -0400 |
commit | 74d24b219bc4ebb20b75d63af2bb577bc1b10b5e (patch) | |
tree | d6653a2d125e0bbde0c14aa17c54dcfe8c944f34 | |
parent | 1267b3a325f00291e847ea4a001ccabe5d5516f2 (diff) |
resources: add resource_overlaps()
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>
-rw-r--r-- | arch/x86/pci/acpi.c | 12 | ||||
-rw-r--r-- | include/linux/ioport.h | 7 |
2 files changed, 8 insertions, 11 deletions
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 8a17b23f8c84..fc09c2754e08 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -245,13 +245,6 @@ setup_resource(struct acpi_resource *acpi_res, void *data) | |||
245 | return AE_OK; | 245 | return AE_OK; |
246 | } | 246 | } |
247 | 247 | ||
248 | static bool resource_contains(struct resource *res, resource_size_t point) | ||
249 | { | ||
250 | if (res->start <= point && point <= res->end) | ||
251 | return true; | ||
252 | return false; | ||
253 | } | ||
254 | |||
255 | static void coalesce_windows(struct pci_root_info *info, unsigned long type) | 248 | static void coalesce_windows(struct pci_root_info *info, unsigned long type) |
256 | { | 249 | { |
257 | int i, j; | 250 | int i, j; |
@@ -272,10 +265,7 @@ static void coalesce_windows(struct pci_root_info *info, unsigned long type) | |||
272 | * our resources no longer match the ACPI _CRS, but | 265 | * our resources no longer match the ACPI _CRS, but |
273 | * the kernel resource tree doesn't allow overlaps. | 266 | * the kernel resource tree doesn't allow overlaps. |
274 | */ | 267 | */ |
275 | if (resource_contains(res1, res2->start) || | 268 | if (resource_overlaps(res1, res2)) { |
276 | resource_contains(res1, res2->end) || | ||
277 | resource_contains(res2, res1->start) || | ||
278 | resource_contains(res2, res1->end)) { | ||
279 | res1->start = min(res1->start, res2->start); | 269 | res1->start = min(res1->start, res2->start); |
280 | res1->end = max(res1->end, res2->end); | 270 | res1->end = max(res1->end, res2->end); |
281 | dev_info(&info->bridge->dev, | 271 | dev_info(&info->bridge->dev, |
diff --git a/include/linux/ioport.h b/include/linux/ioport.h index e885ba23de70..589e0e75efae 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h | |||
@@ -223,5 +223,12 @@ extern int | |||
223 | walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, | 223 | walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, |
224 | void *arg, int (*func)(unsigned long, unsigned long, void *)); | 224 | void *arg, int (*func)(unsigned long, unsigned long, void *)); |
225 | 225 | ||
226 | /* True if any part of r1 overlaps r2 */ | ||
227 | static inline bool resource_overlaps(struct resource *r1, struct resource *r2) | ||
228 | { | ||
229 | return (r1->start <= r2->end && r1->end >= r2->start); | ||
230 | } | ||
231 | |||
232 | |||
226 | #endif /* __ASSEMBLY__ */ | 233 | #endif /* __ASSEMBLY__ */ |
227 | #endif /* _LINUX_IOPORT_H */ | 234 | #endif /* _LINUX_IOPORT_H */ |