mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
a83383e2ae
Add preparation patches for coming soon DCD changes. - Add range_overlaps() - Add CDAT/DSMAS shared and read only flag in ACPICA - Add documentation to struct dev_dax_range - Delay event buffer allocation in CXL PCI - Use guard() in cxl_dpa_set_mode() - Refactor common create region code to reduce redudant code
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_RANGE_H
|
|
#define _LINUX_RANGE_H
|
|
#include <linux/types.h>
|
|
|
|
struct range {
|
|
u64 start;
|
|
u64 end;
|
|
};
|
|
|
|
static inline u64 range_len(const struct range *range)
|
|
{
|
|
return range->end - range->start + 1;
|
|
}
|
|
|
|
/* True if r1 completely contains r2 */
|
|
static inline bool range_contains(const struct range *r1,
|
|
const struct range *r2)
|
|
{
|
|
return r1->start <= r2->start && r1->end >= r2->end;
|
|
}
|
|
|
|
/* True if any part of r1 overlaps r2 */
|
|
static inline bool range_overlaps(const struct range *r1,
|
|
const struct range *r2)
|
|
{
|
|
return r1->start <= r2->end && r1->end >= r2->start;
|
|
}
|
|
|
|
int add_range(struct range *range, int az, int nr_range,
|
|
u64 start, u64 end);
|
|
|
|
|
|
int add_range_with_merge(struct range *range, int az, int nr_range,
|
|
u64 start, u64 end);
|
|
|
|
void subtract_range(struct range *range, int az, u64 start, u64 end);
|
|
|
|
int clean_sort_range(struct range *range, int az);
|
|
|
|
void sort_range(struct range *range, int nr_range);
|
|
|
|
#define DEFINE_RANGE(_start, _end) \
|
|
(struct range) { \
|
|
.start = (_start), \
|
|
.end = (_end), \
|
|
}
|
|
|
|
#endif
|