From: Lee Jones <lee@kernel.org>
To: Joseph Strauss <jstrauss@mailbox.org>
Cc: pavel@ucw.cz, jansimon.moeller@gmx.de,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Add multicolor support to BlinkM LED driver
Date: Thu, 23 Mar 2023 12:28:09 +0000 [thread overview]
Message-ID: <20230323122809.GK2673958@google.com> (raw)
In-Reply-To: <20230322232109.zddbr4umzfr76wgf@libretux>
On Wed, 22 Mar 2023, Joseph Strauss wrote:
> On 23/03/15 04:16PM, Lee Jones wrote:
> > On Tue, 27 Dec 2022, Joseph Strauss wrote:
> >
> > > Added multicolor support to the BlinkM driver, making it easier to
> > > control from userspace. The BlinkM LED is a programmable RGB LED. The
> > > driver currently supports only the regular LED sysfs class, resulting in
> > > the creation of three distinct classes, one for red, green, and blue.
> > > The user then has to input three values into the three seperate
> > > brightness files within those classes. The multicolor LED framework
> > > makes the device easier to control with the multi_intensity file: the
> > > user can input three values at once to form a color, while still
> > > controlling the lightness with the brightness file.
> > >
> > > The main struct blinkm_led has changed slightly. A struct
> > > led_classdev_mc has been added to represent the multicolor sysfs class,
> > > and an additional struct led_classdev pointer has been added for
> > > convenience, which points to the struct led_classdev within struct
> > > led_classdev_mc. The struct led_classdev for the regular sysfs classes
> > > remain. Additionally, a field representing the multicolor LED has been
> > > added to the struct blinkm_data, seperate from the blinkm_leds[3] array.
> > >
> > > In the blinkm_probe function, the multicolor LED class is registered
> > > after the regular LED classes. The blinkm_set_mc_brightness() function
> > > had to be added to calculate the three color components and then set the
> > > fields of the blinkm_data structure accordingly.
> > >
> > > Signed-off-by: Joseph Strauss <jstrauss@mailbox.org>
> > > ---
> > > Changes in v2:
> > > - Replaced instances of the constant 3 with NUM_LEDS, where applicable
> > > - Fixed formatting errors
> > > - Replaced loop inside of blinkm_set_mc_brightness() with equivalent
> > > statements
> > > - Changed id of multicolor class from 4 to 3
> > > - Replaced call to devm_kmalloc_array() with devm_kcalloc()
> > >
> > > Documentation/leds/leds-blinkm.rst | 26 +++++-
> > > drivers/leds/Kconfig | 1 +
> > > drivers/leds/leds-blinkm.c | 143 +++++++++++++++++++++++------
> > > 3 files changed, 137 insertions(+), 33 deletions(-)
[...]
> > + mc_led_info[1].color_index = LED_COLOR_ID_GREEN;
> > > + mc_led_info[1].channel = 1;
> > > + mc_led_info[2].color_index = LED_COLOR_ID_BLUE;
> > > + mc_led_info[2].channel = 2;
> > > + mc_led->mcled_cdev.subled_info = mc_led_info;
> > > + mc_led->mcled_cdev.num_colors = NUM_LEDS;
> > > +
> > > + mc_led->led_cdev = &mc_led->mcled_cdev.led_cdev;
> > > + mc_led->led_cdev->brightness = 255;
> > > + mc_led->led_cdev->max_brightness = 255;
> > > + mc_led->led_cdev->flags = LED_CORE_SUSPENDRESUME;
> > > + snprintf(blinkm_led_name, sizeof(blinkm_led_name),
> > > + "blinkm-%d-%d-multi",
> > > + client->adapter->nr,
> > > + client->addr);
> > > + mc_led->led_cdev->name = blinkm_led_name;
> > > + mc_led->led_cdev->brightness_set_blocking =
> > > + blinkm_set_mc_brightness;
> >
> > 100-chars.
> >
>
> I am not sure what you mean by this. The following line is 78
> characters.
No need to wrap. You have 100-chars to play with.
Review comments pertain to the lines that preceded them.
> > > +
> > > exit:
> >
> > If you want to submit a patch to get rid of this exit label ...
> >
>
> This exit label existed before my patch and is used in several places. I
> don't quite see what's wrong with it. Would you please clarify?
That's why I asked for a follow-up patch.
gotos are useful when there is a bunch of unwinding/deallocating/freeing
of resources. This one is pointless. Just `return err;` instead.
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2023-03-23 12:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-28 1:09 [PATCH v2] Add multicolor support to BlinkM LED driver Joseph Strauss
2023-01-09 16:56 ` Lee Jones
2023-03-01 14:26 ` Lee Jones
2023-03-15 16:16 ` Lee Jones
2023-03-22 23:21 ` Joseph Strauss
2023-03-23 12:28 ` Lee Jones [this message]
2023-03-23 11:33 ` Pavel Machek
2023-03-25 15:53 ` Joseph Strauss
2023-03-25 16:09 ` Pavel Machek
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=20230323122809.GK2673958@google.com \
--to=lee@kernel.org \
--cc=jansimon.moeller@gmx.de \
--cc=jstrauss@mailbox.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).