Re: [PATCH v2] Add multicolor support to BlinkM LED driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> > > ---
> > > 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 [李琼斯]



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux