diff options
author | Dan Williams <dan.j.williams@intel.com> | 2023-02-10 01:06:21 -0800 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2023-02-10 17:32:37 -0800 |
commit | 93c177fd6ff0655a5fa43ec945a57d7b0200ad80 (patch) | |
tree | 6a38288f81007a412c79cda2cd0002bb84c01dc2 /include/linux/range.h | |
parent | 9995576cef48dcbb0ba3de068292ed14f72fa0eb (diff) |
kernel/range: Uplevel the cxl subsystem's range_contains() helper
In support of the CXL subsystem's use of 'struct range' to track decode
address ranges, add a common range_contains() implementation with
identical semantics as resource_contains();
The existing 'range_contains()' in lib/stackinit_kunit.c is namespaced
with a 'stackinit_' prefix.
Cc: Kees Cook <keescook@chromium.org>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Gregory Price <gregory.price@memverge.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Tested-by: Fan Ni <fan.ni@samsung.com>
Link: https://lore.kernel.org/r/167601998163.1924368.6067392174077323935.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'include/linux/range.h')
-rw-r--r-- | include/linux/range.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/range.h b/include/linux/range.h index 274681cc3154..7efb6a9b069b 100644 --- a/include/linux/range.h +++ b/include/linux/range.h @@ -13,6 +13,11 @@ static inline u64 range_len(const struct range *range) return range->end - range->start + 1; } +static inline bool range_contains(struct range *r1, struct range *r2) +{ + return r1->start <= r2->start && r1->end >= r2->end; +} + int add_range(struct range *range, int az, int nr_range, u64 start, u64 end); |