Re: [PATCH v3] leds: ariel: Add driver for status LEDs on Dell Wyse 3020

From: Pavel Machek
Date: Fri Apr 24 2020 - 05:18:11 EST


Hi!

> > > +enum ec_index {
> > > + EC_BLUE_LED = 0x01,
> > > + EC_AMBER_LED = 0x02,
> >
> > Defining the value after the 0x0 is unnecessary as enums are incremental
> > only the first value needs to be defined if the following values are in
> > numerical order
>
> I believe this improves readability, especially in case such as this
> where the actual numeric values matter.
>
> > Can these also be #defined instead of an enum?  Not requesting them to be
> > just wondering about the design decision here.
>
> It seems to be that this is what enums are for and theres is no need to
> get the preprocessor involved?
>
> I guess this might be a personal preference, but it seems to me that
> both enums and preprocessor defines are used across the code base.

enums are okay.

> > > + if (regmap_read(led->ec_ram, led->ec_index, &led_status))
> > > + return LED_OFF;
> > > +
> > > + if (led_status == EC_LED_STILL)
> > > + return LED_FULL;
> > > + else
> > else is not needed here
> > > + return LED_OFF;
> > > +}
>
> Yes, but should it be dropped? To me it seems like explicit else is
> better than implicit fallthrough. It is better when it's obvious that
> the LED_OFF is returned precisely only when the status is not
> EC_LED_STILL and that nothing ever happens afterwards -- and the
> compiler/linter will warn when anything unreachable is added afterwards.
>
> Not that it matters too much here. It's just that I've done this
> deliberately because it seems more readable to be and would prefer to
> leave it that way unless you really really care about that.

Both versions are okay. I may have tiny bit of preference for deleting
the else, but...

Thank you,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature