summaryrefslogtreecommitdiff
path: root/include/linux/ioport.h
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-11-03 22:45:07 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2020-11-17 18:06:28 +0100
commitf65674df1b23cdcb6f656a14f659ffea83e7acaa (patch)
tree9770430d7c42d179b937b690dc96d8677bdcb2b4 /include/linux/ioport.h
parent5562f35d7feabfd68cd58a1ee28b451f90e82417 (diff)
resource: Introduce resource_intersection() for overlapping resources
There will be at least one user that can utilize new helper. Provide the helper for future user and for wider use. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/ioport.h')
-rw-r--r--include/linux/ioport.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 40320eb5bc0e..ece1a8db309c 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -237,6 +237,16 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
}
static inline bool
+resource_intersection(struct resource *r1, struct resource *r2, struct resource *r)
+{
+ if (!resource_overlaps(r1, r2))
+ return false;
+ r->start = max(r1->start, r2->start);
+ r->end = min(r1->end, r2->end);
+ return true;
+}
+
+static inline bool
resource_union(struct resource *r1, struct resource *r2, struct resource *r)
{
if (!resource_overlaps(r1, r2))