From: Pavel Machek <pavel@ucw.cz>
To: Lubomir Rintel <lkundrak@v3.sk>
Cc: Dan Murphy <dmurphy@ti.com>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>,
linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH v3] leds: ariel: Add driver for status LEDs on Dell Wyse 3020
Date: Fri, 24 Apr 2020 11:18:06 +0200 [thread overview]
Message-ID: <20200424091806.GA2647@amd> (raw)
In-Reply-To: <20200417095041.GA448088@furthur.local>
[-- Attachment #1: Type: text/plain, Size: 1881 bytes --]
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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
prev parent reply other threads:[~2020-04-24 9:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-22 7:41 [PATCH v3] leds: ariel: Add driver for status LEDs on Dell Wyse 3020 Lubomir Rintel
2020-04-03 19:37 ` Dan Murphy
2020-04-06 20:12 ` Pavel Machek
2020-04-17 9:58 ` Lubomir Rintel
2020-04-24 9:18 ` Pavel Machek [this message]
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=20200424091806.GA2647@amd \
--to=pavel@ucw.cz \
--cc=dmurphy@ti.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=lkundrak@v3.sk \
/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.