summaryrefslogtreecommitdiff
path: root/src/commonlib/region.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/commonlib/region.c')
-rw-r--r--src/commonlib/region.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/commonlib/region.c b/src/commonlib/region.c
index 8b0b0d9748..2cd273a883 100644
--- a/src/commonlib/region.c
+++ b/src/commonlib/region.c
@@ -48,6 +48,18 @@ static const struct region_device *rdev_root(const struct region_device *rdev)
return rdev->root;
}
+ssize_t rdev_relative_offset(const struct region_device *p,
+ const struct region_device *c)
+{
+ if (rdev_root(p) != rdev_root(c))
+ return -1;
+
+ if (!is_subregion(&p->region, &c->region))
+ return -1;
+
+ return region_device_offset(c) - region_device_offset(p);
+}
+
void *rdev_mmap(const struct region_device *rd, size_t offset, size_t size)
{
const struct region_device *rdev;