From: Armin Wolf <W_Armin@gmx.de>
To: Lee Jones <lee@kernel.org>
Cc: pavel@kernel.org, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org, i@rong.moe
Subject: Re: [PATCH v3 11/11] leds: multicolor: Adjust maximum subled intensity during initialization
Date: Sat, 28 Nov 2026 14:21:57 +0100 [thread overview]
Message-ID: <bf3fdfc5-7345-4271-8098-b9cd00154abb@gmx.de> (raw)
In-Reply-To: <179568582896.32537.166831565181132392@kernel.org>
Am 27.11.26 um 15:37 schrieb Lee Jones:
> --- checkpatch.pl (1 issue) ---
> Line 77: ERROR: that open brace { should be on the previous line
> ----------------------------------
>
> On Fri, 20 Nov 2026, Armin Wolf wrote:
>
>> The maximum brightness of a LED device is fixed after having called
>> led_classdev_init(), so performing the adjustment during runtime is
>> no longer necessary.
>>
>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
>> ---
>> drivers/leds/led-class-multicolor.c | 40 ++++++++++++-----------------
>> 1 file changed, 16 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c
>> index 0656ca2361b3..09c52bc1a55a 100644
>> --- a/drivers/leds/led-class-multicolor.c
>> +++ b/drivers/leds/led-class-multicolor.c
>> @@ -14,24 +14,6 @@
>> #include <linux/uaccess.h>
>> #include "leds.h"
>>
>> -static unsigned int led_mc_get_max_intensity(struct led_classdev_mc *mcled_cdev, size_t index)
>> -{
>> - unsigned int max_intensity;
>> -
>> - /*
>> - * The maximum global brightness value might still be changed by
>> - * led_classdev_register_ext() using devicetree properties. This
>> - * prevents us from changing subled_info[X].max_intensity when
>> - * registering a multicolor LED class device, so we have to do
>> - * this during runtime.
>> - */
>> - max_intensity = mcled_cdev->subled_info[index].max_intensity;
>> - if (max_intensity)
>> - return max_intensity;
>> -
>> - return mcled_cdev->led_cdev.max_brightness;
>> -}
>> -
>> int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev,
>> enum led_brightness brightness)
>> {
>> @@ -53,12 +35,10 @@ static ssize_t multi_max_intensity_show(struct device *dev,
>> {
>> struct led_classdev *led_cdev = dev_get_drvdata(dev);
>> struct led_classdev_mc *mcled_cdev = lcdev_to_mccdev(led_cdev);
>> - unsigned int max_intensity;
>> int len = 0;
>>
>> - for (int i = 0; i < mcled_cdev->num_colors; i++) {
>> - max_intensity = led_mc_get_max_intensity(mcled_cdev, i);
>> - len += sysfs_emit_at(buf, len, "%u", max_intensity);
>> + for (unsigned int i = 0; i < mcled_cdev->num_colors; i++) {
> How many colours are you expecting?
>
> It's usual (although not unheard of) to use unsigned for this.
I decided to use unsigned int because num_colors itself is unsigned, so
IMHO having matching types is better here.
>> + len += sysfs_emit_at(buf, len, "%u", mcled_cdev->subled_info[i].max_intensity);
>> if (i < mcled_cdev->num_colors - 1)
>> len += sprintf(buf + len, " ");
>> }
>> @@ -98,8 +78,8 @@ static ssize_t multi_intensity_store(struct device *dev,
>> goto err_out;
>> }
>>
>> - for (int i = 0; i < mcled_cdev->num_colors; i++) {
>> - max_intensity = led_mc_get_max_intensity(mcled_cdev, i);
>> + for (unsigned int i = 0; i < mcled_cdev->num_colors; i++) {
>> + max_intensity = mcled_cdev->subled_info[i].max_intensity;
>> mcled_cdev->subled_info[i].intensity = min(intensity_value[i], max_intensity);
>> }
>>
>> @@ -187,6 +167,18 @@ int led_classdev_multicolor_register_ext(struct device *parent,
>> if (ret < 0)
>> return ret;
>>
>> + /*
>> + * The maximum global brightness value might have been changed by
>> + * led_classdev_init() using devicetree properties. Because of this
>> + * we can only adjust subled_info[X].max_intensity after said function
>> + * was called.
>> + */
>> + for (unsigned int i = 0; i < mcled_cdev->num_colors; i++)
>> + {
> Nit: Misplaced '{'.
Good catch, it seems i forgot to install by post-commit hook for running checkpatch xd.
Thanks,
Armin Wolf
>> + if (!mcled_cdev->subled_info[i].max_intensity)
>> + mcled_cdev->subled_info[i].max_intensity = led_cdev->max_brightness;
>> + }
>> +
>> led_cdev->dev->type = &led_multicolor_device_type;
>>
>> return led_classdev_add(led_cdev, init_data);
>> --
>> 2.56.1
>>
>>
next prev parent reply other threads:[~2026-11-28 13:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 21:22 [PATCH v3 00/11] leds: class: Support custom sysfs groups on multicolor and flash LEDs Armin Wolf
2026-11-20 21:22 ` [PATCH v3 01/11] leds: class: Constify sysfs attributes Armin Wolf
2026-11-20 21:22 ` [PATCH v3 02/11] leds: multicolor: " Armin Wolf
2026-11-20 21:22 ` [PATCH v3 03/11] leds: flash: " Armin Wolf
2026-11-20 21:22 ` [PATCH v3 04/11] leds: class: Create "brightness_hw_changed" attribute atomically Armin Wolf
2026-11-20 21:22 ` [PATCH v3 05/11] leds: class: Fix race condition when creating the device Armin Wolf
2026-11-20 21:22 ` [PATCH v3 06/11] leds: class: Access brightness_hw_changed exactly once Armin Wolf
2026-11-20 21:22 ` [PATCH v3 07/11] leds: class: Use correct type for brightness_hw_changed field Armin Wolf
2026-11-20 21:22 ` [PATCH v3 08/11] leds: class: Split led_classdev_register_ext() Armin Wolf
2026-11-27 14:42 ` Lee Jones
2026-11-28 13:24 ` Armin Wolf
2026-11-20 21:22 ` [PATCH v3 09/11] leds: Support custom sysfs groups on multicolor and flash LEDs Armin Wolf
2026-11-27 14:40 ` Lee Jones
2026-11-20 21:22 ` [PATCH v3 10/11] leds: rgb: ktd202x: Initialize max_brightness before registering LED Armin Wolf
2026-11-21 12:53 ` Armin Wolf
2026-11-27 14:39 ` Lee Jones
2026-11-20 21:22 ` [PATCH v3 11/11] leds: multicolor: Adjust maximum subled intensity during initialization Armin Wolf
2026-11-27 14:37 ` Lee Jones
2026-11-28 13:21 ` Armin Wolf [this message]
2026-11-21 11:21 ` [PATCH v3 00/11] leds: class: Support custom sysfs groups on multicolor and flash LEDs Rong Zhang
2026-11-21 12:42 ` Armin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf3fdfc5-7345-4271-8098-b9cd00154abb@gmx.de \
--to=w_armin@gmx.de \
--cc=i@rong.moe \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®