From: ChiaEn Wu Date: Thu, 15 Sep 2022 09:47:32 +0000 (+0800) Subject: lib: add linear range index macro X-Git-Tag: v6.1-rc1~125^2~7^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2f2e2c3aecdbabf822272a4b6e7d91537633cd9;p=thirdparty%2Fkernel%2Flinux.git lib: add linear range index macro Add linear_range_idx macro for declaring the linear_range struct simply. Reviewed-by: Matti Vaittinen Signed-off-by: ChiaEn Wu Signed-off-by: Sebastian Reichel --- diff --git a/include/linux/linear_range.h b/include/linux/linear_range.h index fd3d0b358f228..2e4f4c3539c07 100644 --- a/include/linux/linear_range.h +++ b/include/linux/linear_range.h @@ -26,6 +26,17 @@ struct linear_range { unsigned int step; }; +#define LINEAR_RANGE(_min, _min_sel, _max_sel, _step) \ + { \ + .min = _min, \ + .min_sel = _min_sel, \ + .max_sel = _max_sel, \ + .step = _step, \ + } + +#define LINEAR_RANGE_IDX(_idx, _min, _min_sel, _max_sel, _step) \ + [_idx] = LINEAR_RANGE(_min, _min_sel, _max_sel, _step) + unsigned int linear_range_values_in_range(const struct linear_range *r); unsigned int linear_range_values_in_range_array(const struct linear_range *r, int ranges);