1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_RANGE_H
3 #define _LINUX_RANGE_H
4 #include <linux/types.h>
5
6 struct range {
7 u64 start;
8 u64 end;
9 };
10
range_len(const struct range * range)11 static inline u64 range_len(const struct range *range)
12 {
13 return range->end - range->start + 1;
14 }
15
range_contains(struct range * r1,struct range * r2)16 static inline bool range_contains(struct range *r1, struct range *r2)
17 {
18 return r1->start <= r2->start && r1->end >= r2->end;
19 }
20
21 int add_range(struct range *range, int az, int nr_range,
22 u64 start, u64 end);
23
24
25 int add_range_with_merge(struct range *range, int az, int nr_range,
26 u64 start, u64 end);
27
28 void subtract_range(struct range *range, int az, u64 start, u64 end);
29
30 int clean_sort_range(struct range *range, int az);
31
32 void sort_range(struct range *range, int nr_range);
33
34 #endif
35