mirror of
https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9.git
synced 2026-09-10 00:22:43 +08:00
JIRA: https://issues.redhat.com/browse/RHEL-81536 commit 66418687ac895717dc2f6ddffe24cf9b74cd0d3e Author: Ira Weiny <ira.weiny@intel.com> Date: Thu Oct 10 10:24:42 2024 -0500 range_contains() does not modify the range values. David suggested it is safer to keep those parameters as const.[1] Make range parameters const Link: https://lore.kernel.org/all/20241008161032.GB1609@twin.jikos.cz/ [1] Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: David Sterba <dsterba@suse.com> Link: https://patch.msgid.link/20241010-const-range-v1-1-afb6e4bfd8ce@intel.com Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
36 lines
761 B
C
36 lines
761 B
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;
|
|
}
|
|
|
|
static inline bool range_contains(const struct range *r1,
|
|
const 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);
|
|
|
|
|
|
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);
|
|
|
|
#endif
|