From: Tzung-Bi Shih <tzungbi@kernel.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
chrome-platform@lists.linux.dev,
Dustin Howett <dustin@howett.net>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: Re: [PATCH 4/5] leds: add ChromeOS EC driver
Date: Tue, 28 May 2024 07:15:07 +0000 [thread overview]
Message-ID: <ZlWEeyPP57TT_FKv@google.com> (raw)
In-Reply-To: <2d03e62c-13ad-4c6f-94e1-7dff817386a4@t-8ch.de>
On Tue, May 28, 2024 at 07:25:07AM +0200, Thomas Weißschuh wrote:
> On 2024-05-28 05:09:29+0000, Tzung-Bi Shih wrote:
> > On Mon, May 20, 2024 at 12:00:32PM +0200, Thomas Weißschuh wrote:
> > > +static int cros_ec_led_count_subleds(struct device *dev,
> > > + struct ec_response_led_control *resp,
> > > + unsigned int *max_brightness)
> > > +{
> > > + unsigned int range, common_range = 0;
> > > + int num_subleds = 0;
> > > + size_t i;
> > > +
> > > + for (i = 0; i < EC_LED_COLOR_COUNT; i++) {
> > > + range = resp->brightness_range[i];
> > > +
> > > + if (!range)
> > > + continue;
> > > +
> > > + num_subleds++;
> > > +
> > > + if (!common_range)
> > > + common_range = range;
> > > +
> > > + if (common_range != range) {
> > > + /* The multicolor LED API expects a uniform max_brightness */
> > > + dev_warn(dev, "Inconsistent LED brightness values\n");
> > > + return -EINVAL;
> > > + }
> >
> > What if the array is [0, 1, 1]?
>
> The "0" will be skipped by
>
> if (!range)
> continue;
>
> And the two "1" will pass the check.
Ack.
> > > +static int __init cros_ec_led_init(void)
> > > +{
> > > + int ret;
> > > +
> > > + ret = led_trigger_register(&cros_ec_led_trigger);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + ret = platform_driver_register(&cros_ec_led_driver);
> > > + if (ret)
> > > + led_trigger_unregister(&cros_ec_led_trigger);
> > > +
> > > + return ret;
> > > +};
> > > +module_init(cros_ec_led_init);
> > > +
> > > +static void __exit cros_ec_led_exit(void)
> > > +{
> > > + platform_driver_unregister(&cros_ec_led_driver);
> > > + led_trigger_unregister(&cros_ec_led_trigger);
> > > +};
> > > +module_exit(cros_ec_led_exit);
> >
> > I wonder it could use module_led_trigger() and module_platform_driver().
>
> This won't compile as the macros generate various duplicate symbols.
>
> Also the order is important, so I think the explicit logic is clearer.
I'm not sure if it is feasible by separating the trigger part to
drivers/leds/trigger/ and specify it in `default_trigger`.
next prev parent reply other threads:[~2024-05-28 7:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 10:00 [PATCH 0/5] ChromeOS Embedded Controller LED driver Thomas Weißschuh
2024-05-20 10:00 ` [PATCH 1/5] leds: introduce led_color_name function Thomas Weißschuh
2024-05-31 15:42 ` Lee Jones
2024-05-20 10:00 ` [PATCH 2/5] leds: multicolor: use " Thomas Weißschuh
2024-05-20 10:00 ` [PATCH 3/5] leds: unexport led_colors array Thomas Weißschuh
2024-05-20 10:00 ` [PATCH 4/5] leds: add ChromeOS EC driver Thomas Weißschuh
2024-05-28 5:09 ` Tzung-Bi Shih
2024-05-28 5:25 ` Thomas Weißschuh
2024-05-28 7:15 ` Tzung-Bi Shih [this message]
2024-05-28 7:23 ` Thomas Weißschuh
2024-05-20 10:00 ` [PATCH 5/5] mfd: cros_ec: Register LED subdevice Thomas Weißschuh
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=ZlWEeyPP57TT_FKv@google.com \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dustin@howett.net \
--cc=groeck@chromium.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=mario.limonciello@amd.com \
--cc=pavel@ucw.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.