Commit 2b4b4960 authored by Marijn Suijten's avatar Marijn Suijten Committed by Lee Jones

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: 775d2ffb ("backlight: qcom-wled: Restructure the driver for WLED3")
Signed-off-by: default avatarMarijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20211115203459.1634079-6-marijn.suijten@somainline.org
parent 5ada78b2
......@@ -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,10 +1532,14 @@ static int wled_configure(struct wled *wled)
return -EINVAL;
}
if (string_len > 0 && val > string_len) {
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment