Skip to content

Commit 7d33c0a

Browse files
andredbroonie
authored andcommitted
regulator: add REGULATOR_LINEAR_VRANGE macro
REGULATOR_LINEAR_VRANGE is similar to REGULATOR_LINEAR_RANGE, but allows a more natural declaration of a voltage range for a regulator, in that it expects the minimum and maximum values as voltages rather than as selectors. Using voltages arguably makes this macro easier to use by drivers and code using it can become easier to read compared to REGULATOR_LINEAR_RANGE. Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20260122-s2mpg1x-regulators-v7-10-3b1f9831fffd@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 030158c commit 7d33c0a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

include/linux/regulator/driver.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ enum regulator_detection_severity {
5353
#define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \
5454
LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV)
5555

56+
/* Initialize struct linear_range using voltages, not selectors */
57+
#define REGULATOR_LINEAR_VRANGE(_offs_uV, _min_uV, _max_uV, _step_uV) \
58+
LINEAR_RANGE(_min_uV, ((_min_uV) - (_offs_uV)) / (_step_uV), \
59+
((_max_uV) - (_offs_uV)) / (_step_uV), _step_uV)
60+
5661
/**
5762
* struct regulator_ops - regulator operations.
5863
*

0 commit comments

Comments
 (0)