2021-11-16 00:07:32

by Marijn Suijten

[permalink] [raw]
Subject: [PATCH v3 5/9] backlight: qcom-wled: Override default length with qcom,enabled-strings

The length of qcom,enabled-strings as property array is enough to
determine the number of strings to be enabled, without needing to set
qcom,num-strings to override the default number of strings when less
than the default (which is also the maximum) is provided in DT.

This also introduces an extra warning when qcom,num-strings is set,
denoting that it is not necessary to set both anymore. It is usually
more concise to set just qcom,num-length when a zero-based, contiguous
range of strings is needed (the majority of the cases), or to only set
qcom,enabled-strings when a specific set of indices is desired.

Fixes: 775d2ffb4af6 ("backlight: qcom-wled: Restructure the driver for WLED3")
Signed-off-by: Marijn Suijten <[email protected]>
Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/video/backlight/qcom-wled.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
index ab10910971e9..5306b06044b4 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -1520,6 +1520,8 @@ static int wled_configure(struct wled *wled)
return -EINVAL;
}
}
+
+ cfg->num_strings = string_len;
}

rc = of_property_read_u32(dev->of_node, "qcom,num-strings", &val);
@@ -1530,9 +1532,13 @@ static int wled_configure(struct wled *wled)
return -EINVAL;
}

- if (string_len > 0 && val > string_len) {
- dev_err(dev, "qcom,num-strings exceeds qcom,enabled-strings\n");
- return -EINVAL;
+ if (string_len > 0) {
+ dev_warn(dev, "Only one of qcom,num-strings or qcom,enabled-strings"
+ " should be set\n");
+ if (val > string_len) {
+ dev_err(dev, "qcom,num-strings exceeds qcom,enabled-strings\n");
+ return -EINVAL;
+ }
}

cfg->num_strings = val;
--
2.33.1



2021-11-16 12:02:38

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH v3 5/9] backlight: qcom-wled: Override default length with qcom,enabled-strings

On Mon, Nov 15, 2021 at 09:34:55PM +0100, Marijn Suijten wrote:
> The length of qcom,enabled-strings as property array is enough to
> determine the number of strings to be enabled, without needing to set
> qcom,num-strings to override the default number of strings when less
> than the default (which is also the maximum) is provided in DT.
>
> This also introduces an extra warning when qcom,num-strings is set,
> denoting that it is not necessary to set both anymore. It is usually
> more concise to set just qcom,num-length when a zero-based, contiguous
> range of strings is needed (the majority of the cases), or to only set
> qcom,enabled-strings when a specific set of indices is desired.
>
> Fixes: 775d2ffb4af6 ("backlight: qcom-wled: Restructure the driver for WLED3")
> Signed-off-by: Marijn Suijten <[email protected]>
> Reviewed-by: AngeloGioacchino Del Regno <[email protected]>

Reviewed-by: Daniel Thompson <[email protected]>


Daniel.

2021-12-22 11:17:34

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v3 5/9] backlight: qcom-wled: Override default length with qcom,enabled-strings

On Mon, 15 Nov 2021, Marijn Suijten wrote:

> The length of qcom,enabled-strings as property array is enough to
> determine the number of strings to be enabled, without needing to set
> qcom,num-strings to override the default number of strings when less
> than the default (which is also the maximum) is provided in DT.
>
> This also introduces an extra warning when qcom,num-strings is set,
> denoting that it is not necessary to set both anymore. It is usually
> more concise to set just qcom,num-length when a zero-based, contiguous
> range of strings is needed (the majority of the cases), or to only set
> qcom,enabled-strings when a specific set of indices is desired.
>
> Fixes: 775d2ffb4af6 ("backlight: qcom-wled: Restructure the driver for WLED3")
> Signed-off-by: Marijn Suijten <[email protected]>
> Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
> ---
> drivers/video/backlight/qcom-wled.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)

Applied, thanks.

--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog