]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/linux/linear_range.h
Merge tag 'pm-5.14-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
[mirror_ubuntu-jammy-kernel.git] / include / linux / linear_range.h
CommitLineData
d2218d4e
MV
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (C) 2020 ROHM Semiconductors */
3
4#ifndef LINEAR_RANGE_H
5#define LINEAR_RANGE_H
6
7#include <linux/types.h>
8
9/**
10 * struct linear_range - table of selector - value pairs
11 *
12 * Define a lookup-table for range of values. Intended to help when looking
13 * for a register value matching certaing physical measure (like voltage).
14 * Usable when increment of one in register always results a constant increment
15 * of the physical measure (like voltage).
16 *
17 * @min: Lowest value in range
18 * @min_sel: Lowest selector for range
19 * @max_sel: Highest selector for range
20 * @step: Value step size
21 */
22struct linear_range {
23 unsigned int min;
24 unsigned int min_sel;
25 unsigned int max_sel;
26 unsigned int step;
27};
28
29unsigned int linear_range_values_in_range(const struct linear_range *r);
30unsigned int linear_range_values_in_range_array(const struct linear_range *r,
31 int ranges);
32unsigned int linear_range_get_max_value(const struct linear_range *r);
33
34int linear_range_get_value(const struct linear_range *r, unsigned int selector,
35 unsigned int *val);
36int linear_range_get_value_array(const struct linear_range *r, int ranges,
37 unsigned int selector, unsigned int *val);
38int linear_range_get_selector_low(const struct linear_range *r,
39 unsigned int val, unsigned int *selector,
40 bool *found);
41int linear_range_get_selector_high(const struct linear_range *r,
42 unsigned int val, unsigned int *selector,
43 bool *found);
44int linear_range_get_selector_low_array(const struct linear_range *r,
45 int ranges, unsigned int val,
46 unsigned int *selector, bool *found);
47
48#endif