leds: led-class-multicolor: Accept trailing RGB components

- Allow shorter writes for <=3 sub-LEDs (e.g. "R,G")
- Improve sysfs usability for RGB patterns
- Maintain compatibility with full-length writes

Signed-off-by: Maxim Laschinsky <maxim.laschinsky@wago.com>
This commit is contained in:
Maxim Laschinksy
2026-01-21 08:27:41 +01:00
committed by Heinrich Toews
parent 521d9c5001
commit 15229763fa
+10 -5
View File
@@ -42,22 +42,27 @@ static ssize_t multi_intensity_store(struct device *dev,
mutex_lock(&led_cdev->led_access);
for (i = 0; i < mcled_cdev->num_colors; i++) {
for (i = 0; i < LED_COLOR_ID_MAX; i++) {
ret = sscanf(buf + offset, "%i%n",
&intensity_value[i], &nrchars);
if (ret != 1) {
ret = -EINVAL;
goto err_out;
}
if (ret != 1)
break;
offset += nrchars;
}
/* Expect newline; reject surplus trailing chars */
offset++;
if (offset < size) {
ret = -EINVAL;
goto err_out;
}
/* Require at least the physical number of colors */
if (i < mcled_cdev->num_colors) {
ret = -EINVAL;
goto err_out;
}
for (i = 0; i < mcled_cdev->num_colors; i++)
mcled_cdev->subled_info[i].intensity = intensity_value[i];