Commit f65674df authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Rafael J. Wysocki
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarHanjun Guo <guohanjun@huawei.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 5562f35d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -236,6 +236,16 @@ static inline bool resource_overlaps(struct resource *r1, struct resource *r2)
       return r1->start <= r2->end && r1->end >= r2->start;
}

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)
{