From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] Add 'led' command
Date: Sat, 13 Nov 2010 18:31:39 -0500 [thread overview]
Message-ID: <201011131831.40670.vapier@gentoo.org> (raw)
In-Reply-To: <AANLkTi=80UFcq_SzDxox=mzcQeruPup9DGdu8TjSnJeE@mail.gmail.com>
On Friday, November 12, 2010 09:42:52 Jason Kridner wrote:
> On Tue, Nov 9, 2010 at 8:52 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On Friday, November 05, 2010 01:50:36 Jason Kridner wrote:
> >> + if (strcmp(argv[2], "off") == 0) {
> >> + state = 0;
> >> + } else if (strcmp(argv[2], "on") == 0) {
> >> + state = 1;
> >
> > i could have sworn we had a helper somewhere to handle "boolean strings"
> > ...
>
> common/cmd_cache.c has an internal on_off function. All other places
> seem to do individual strcmp. Let me know if you find such a helper.
> Is there value to putting this in a function like the one in
> cmd_cache.c?
i think there's value in moving this to generalizing and moving to common
code. there are other places where we handle env vars which could have the
value "on" or "off".
> >> +#if defined(STATUS_LED_BIT) && defined(CONFIG_BOARD_SPECIFIC_LED)
> >> + if (strcmp(argv[1], "0") == 0) {
> >> + mask = STATUS_LED_BIT;
> >> + __led_set(mask, state);
> >> + }
> >> + else
> >> +#endif
> >> +#if defined(STATUS_LED_BIT1) && defined(CONFIG_BOARD_SPECIFIC_LED)
> >> + if (strcmp(argv[1], "1") == 0) {
> >> + mask = STATUS_LED_BIT1;
> >> + __led_set(mask, state);
> >> + }
> >> + else
> >> +#endif
> >> +#if defined(STATUS_LED_BIT2) && defined(CONFIG_BOARD_SPECIFIC_LED)
> >> + if (strcmp(argv[1], "2") == 0) {
> >> + mask = STATUS_LED_BIT2;
> >> + __led_set(mask, state);
> >> + }
> >> + else
> >> +#endif
> >> +#if defined(STATUS_LED_BIT3) && defined(CONFIG_BOARD_SPECIFIC_LED)
> >> + if (strcmp(argv[1], "3") == 0) {
> >> + mask = STATUS_LED_BIT3;
> >> + __led_set(mask, state);
> >> + }
> >> + else
> >> +#endif
> >
> > i dont know why you need the mask variable here at all
>
> It is an ugly hack at avoiding definition of the bit pattern to be
> passed into __led_set(), to keep that function lean as defined by the
> platform.
i dont follow. why are these two things different ?
...
mask = STATUS_LED_BIT3;
__led_set(mask, state);
...
__led_set(STATUS_LED_BIT3, state);
...
> > also, these #ifdef trees scream for some sort of unification
>
> It impacts performance, but what do you think if I just put them into
> a data structure and loop, like what I'm suggesting above with my
> functions?
i mean at least create a single define that expands into the duplicated code
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101113/e66ae631/attachment.pgp
next prev parent reply other threads:[~2010-11-13 23:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-05 5:50 [U-Boot] [RFC] Add 'led' command Jason Kridner
2010-11-05 12:21 ` Wolfgang Denk
2010-11-05 13:13 ` Reinhard Meyer
2010-11-05 17:04 ` Jason Kridner
2011-12-13 23:55 ` Ulf Samuelsson
2011-12-14 19:11 ` Simon Glass
[not found] ` <4EE8FB51.8010108@telia.com>
2011-12-14 21:31 ` Simon Glass
2011-12-15 18:17 ` Jason Kridner
2011-12-16 7:58 ` Ulf Samuelsson
2010-11-09 13:52 ` Mike Frysinger
2010-11-12 14:42 ` Jason Kridner
2010-11-13 23:31 ` Mike Frysinger [this message]
2010-11-18 10:37 ` Mike Frysinger
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=201011131831.40670.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/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