commonlib/region: expose subregion helper function

Export region_is_subregion() for determinig if a region is a child of
a parent region.

BUG=b:69614064

Change-Id: I6363fe4fdb33342f9d025a726ec7e17e87adf7e0
Signed-off-by: Aaron Durbn <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/22878
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h
index 3f7d3bd..45484dd 100644
--- a/src/commonlib/include/commonlib/region.h
+++ b/src/commonlib/include/commonlib/region.h
@@ -112,6 +112,9 @@
 			const struct region_device_ops *ops, size_t offset,
 			size_t size);
 
+/* Return 1 if child is subregion of parent, else 0. */
+int region_is_subregion(const struct region *p, const struct region *c);
+
 static inline size_t region_offset(const struct region *r)
 {
 	return r->offset;
diff --git a/src/commonlib/region.c b/src/commonlib/region.c
index 051fe34..541a125 100644
--- a/src/commonlib/region.c
+++ b/src/commonlib/region.c
@@ -22,7 +22,7 @@
 	return region_sz(r) + region_offset(r);
 }
 
-static int is_subregion(const struct region *p, const struct region *c)
+int region_is_subregion(const struct region *p, const struct region *c)
 {
 	if (region_offset(c) < region_offset(p))
 		return 0;
@@ -39,7 +39,7 @@
 static int normalize_and_ok(const struct region *outer, struct region *inner)
 {
 	inner->offset += region_offset(outer);
-	return is_subregion(outer, inner);
+	return region_is_subregion(outer, inner);
 }
 
 static const struct region_device *rdev_root(const struct region_device *rdev)
@@ -55,7 +55,7 @@
 	if (rdev_root(p) != rdev_root(c))
 		return -1;
 
-	if (!is_subregion(&p->region, &c->region))
+	if (!region_is_subregion(&p->region, &c->region))
 		return -1;
 
 	return region_device_offset(c) - region_device_offset(p);
@@ -350,7 +350,7 @@
 
 	xldev = container_of(rd, __typeof__(*xldev), rdev);
 
-	if (!is_subregion(&xldev->sub_region, &req))
+	if (!region_is_subregion(&xldev->sub_region, &req))
 		return NULL;
 
 	offset -= region_offset(&xldev->sub_region);
@@ -378,7 +378,7 @@
 
 	xldev = container_of(rd, __typeof__(*xldev), rdev);
 
-	if (!is_subregion(&xldev->sub_region, &req))
+	if (!region_is_subregion(&xldev->sub_region, &req))
 		return -1;
 
 	offset -= region_offset(&xldev->sub_region);
@@ -397,7 +397,7 @@
 
 	xldev = container_of(rd, __typeof__(*xldev), rdev);
 
-	if (!is_subregion(&xldev->sub_region, &req))
+	if (!region_is_subregion(&xldev->sub_region, &req))
 		return -1;
 
 	offset -= region_offset(&xldev->sub_region);
@@ -416,7 +416,7 @@
 
 	xldev = container_of(rd, __typeof__(*xldev), rdev);
 
-	if (!is_subregion(&xldev->sub_region, &req))
+	if (!region_is_subregion(&xldev->sub_region, &req))
 		return -1;
 
 	offset -= region_offset(&xldev->sub_region);