diff mbox series

[v9,05/10] lib: add linear range index macro

Message ID 20220830034042.9354-6-peterwu.pub@gmail.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series Add MediaTek MT6370 PMIC support | expand

Commit Message

ChiaEn Wu Aug. 30, 2022, 3:40 a.m. UTC
From: ChiaEn Wu <chiaen_wu@richtek.com>

Add linear_range_idx macro for declaring the linear_range struct simply.

Signed-off-by: ChiaEn Wu <chiaen_wu@richtek.com>
---

v9
- Revise LINEAR_RANGE() and LINEAR_RANGE_IDX()
---
 include/linux/linear_range.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Matti Vaittinen Aug. 30, 2022, 10:22 a.m. UTC | #1
On 8/30/22 06:40, ChiaEn Wu wrote:
> From: ChiaEn Wu <chiaen_wu@richtek.com>
> 
> Add linear_range_idx macro for declaring the linear_range struct simply.
> 
> Signed-off-by: ChiaEn Wu <chiaen_wu@richtek.com>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

> ---
> 
> v9
> - Revise LINEAR_RANGE() and LINEAR_RANGE_IDX()
> ---
>   include/linux/linear_range.h | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/include/linux/linear_range.h b/include/linux/linear_range.h
> index fd3d0b3..2e4f4c3 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);
diff mbox series

Patch

diff --git a/include/linux/linear_range.h b/include/linux/linear_range.h
index fd3d0b3..2e4f4c3 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);