diff options
Diffstat (limited to 'kernel/resource.c')
-rw-r--r-- | kernel/resource.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 994f1e41269b..0041cedc47d6 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -496,31 +496,34 @@ EXPORT_SYMBOL_GPL(page_is_ram); | |||
496 | * region_intersects() - determine intersection of region with known resources | 496 | * region_intersects() - determine intersection of region with known resources |
497 | * @start: region start address | 497 | * @start: region start address |
498 | * @size: size of region | 498 | * @size: size of region |
499 | * @name: name of resource (in iomem_resource) | 499 | * @flags: flags of resource (in iomem_resource) |
500 | * @desc: descriptor of resource (in iomem_resource) or IORES_DESC_NONE | ||
500 | * | 501 | * |
501 | * Check if the specified region partially overlaps or fully eclipses a | 502 | * Check if the specified region partially overlaps or fully eclipses a |
502 | * resource identified by @name. Return REGION_DISJOINT if the region | 503 | * resource identified by @flags and @desc (optional with IORES_DESC_NONE). |
503 | * does not overlap @name, return REGION_MIXED if the region overlaps | 504 | * Return REGION_DISJOINT if the region does not overlap @flags/@desc, |
504 | * @type and another resource, and return REGION_INTERSECTS if the | 505 | * return REGION_MIXED if the region overlaps @flags/@desc and another |
505 | * region overlaps @type and no other defined resource. Note, that | 506 | * resource, and return REGION_INTERSECTS if the region overlaps @flags/@desc |
506 | * REGION_INTERSECTS is also returned in the case when the specified | 507 | * and no other defined resource. Note that REGION_INTERSECTS is also |
507 | * region overlaps RAM and undefined memory holes. | 508 | * returned in the case when the specified region overlaps RAM and undefined |
509 | * memory holes. | ||
508 | * | 510 | * |
509 | * region_intersect() is used by memory remapping functions to ensure | 511 | * region_intersect() is used by memory remapping functions to ensure |
510 | * the user is not remapping RAM and is a vast speed up over walking | 512 | * the user is not remapping RAM and is a vast speed up over walking |
511 | * through the resource table page by page. | 513 | * through the resource table page by page. |
512 | */ | 514 | */ |
513 | int region_intersects(resource_size_t start, size_t size, const char *name) | 515 | int region_intersects(resource_size_t start, size_t size, unsigned long flags, |
516 | unsigned long desc) | ||
514 | { | 517 | { |
515 | unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
516 | resource_size_t end = start + size - 1; | 518 | resource_size_t end = start + size - 1; |
517 | int type = 0; int other = 0; | 519 | int type = 0; int other = 0; |
518 | struct resource *p; | 520 | struct resource *p; |
519 | 521 | ||
520 | read_lock(&resource_lock); | 522 | read_lock(&resource_lock); |
521 | for (p = iomem_resource.child; p ; p = p->sibling) { | 523 | for (p = iomem_resource.child; p ; p = p->sibling) { |
522 | bool is_type = strcmp(p->name, name) == 0 && | 524 | bool is_type = (((p->flags & flags) == flags) && |
523 | ((p->flags & flags) == flags); | 525 | ((desc == IORES_DESC_NONE) || |
526 | (desc == p->desc))); | ||
524 | 527 | ||
525 | if (start >= p->start && start <= p->end) | 528 | if (start >= p->start && start <= p->end) |
526 | is_type ? type++ : other++; | 529 | is_type ? type++ : other++; |
@@ -539,6 +542,7 @@ int region_intersects(resource_size_t start, size_t size, const char *name) | |||
539 | 542 | ||
540 | return REGION_DISJOINT; | 543 | return REGION_DISJOINT; |
541 | } | 544 | } |
545 | EXPORT_SYMBOL_GPL(region_intersects); | ||
542 | 546 | ||
543 | void __weak arch_remove_reservations(struct resource *avail) | 547 | void __weak arch_remove_reservations(struct resource *avail) |
544 | { | 548 | { |