diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commonlib/include/commonlib/region.h | 3 | ||||
-rw-r--r-- | src/commonlib/region.c | 14 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h index 3f7d3bd52f..45484dddd6 100644 --- a/src/commonlib/include/commonlib/region.h +++ b/src/commonlib/include/commonlib/region.h @@ -112,6 +112,9 @@ void region_device_init(struct region_device *rdev, 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 051fe3479b..541a125ad4 100644 --- a/src/commonlib/region.c +++ b/src/commonlib/region.c @@ -22,7 +22,7 @@ static inline size_t region_end(const struct region *r) 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 is_subregion(const struct region *p, const struct region *c) 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 @@ ssize_t rdev_relative_offset(const struct region_device *p, 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 @@ static void *xlate_mmap(const struct region_device *rd, size_t offset, 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 @@ static ssize_t xlate_readat(const struct region_device *rd, void *b, 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 @@ static ssize_t xlate_writeat(const struct region_device *rd, const void *b, 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 @@ static ssize_t xlate_eraseat(const struct region_device *rd, 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); |