From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH][NEXT] hwmon: do not init sensors on startup
Date: Thu, 09 Dec 2010 16:45:15 +0100 [thread overview]
Message-ID: <4D00F98B.1010507@denx.de> (raw)
In-Reply-To: <20101209142643.2D162D08A93@gemini.denx.de>
Hello Wolfgang,
Wolfgang Denk wrote:
> In message <1291903238-29071-1-git-send-email-hs@denx.de> you wrote:
>> --- a/common/cmd_dtt.c
>> +++ b/common/cmd_dtt.c
>> @@ -28,6 +28,8 @@
>> #include <dtt.h>
>> #include <i2c.h>
>>
>> +static unsigned long sensors_init_done = 0;
>
> What if there are more then 32 sensors?
Ok, that would not work ... Hmm.. I can get the number of DTTs on a board
with ARRAY_SIZE(CONFIG_DTT_SENSORS) ... should I use this info to allocate
an array, which stores the info, if the DTTs are initialized?
>> int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
>> {
>> int i;
>> @@ -42,8 +44,16 @@ int do_dtt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
>> * Loop through sensors, read
>> * temperature, and output it.
>> */
>> - for (i = 0; i < sizeof (sensors); i++)
>> - printf ("DTT%d: %i C\n", i + 1, dtt_get_temp (sensors[i]));
>> + for (i = 0; i < sizeof (sensors); i++) {
>> + if ((sensors_init_done & (1 << i)) != (1 << i)) {
>> + if (dtt_init_one(sensors[i]) == 0)
>> + sensors_init_done |= (1 << i);
>> + else
>> + printf("DTT%d: Failed init!\n", i);
>> + }
>> + if ((sensors_init_done & (1 << i)) == (1 << i))
>> + printf ("DTT%d: %i C\n", i + 1, dtt_get_temp(sensors[i]));
>> + }
>
> This is overly complicated, it seems. Why not:
>
> for (i = 0; i < sizeof(sensors); i++) {
> if ((sensors_init_done & (1 << i)) == 0) {
> if (dtt_init_one(sensors[i]) != 0) {
> printf("DTT%d: init failed\n", i);
> continue;
> }
> sensors_init_done |= (1 << i);
> }
>
> printf("DTT%d: %i C\n", i + 1, dtt_get_temp(sensors[i]));
> }
Yep, that looks better, change this in v2.
bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2010-12-09 15:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-09 14:00 [U-Boot] [PATCH][NEXT] hwmon: do not init sensors on startup Heiko Schocher
2010-12-09 14:26 ` Wolfgang Denk
2010-12-09 15:45 ` Heiko Schocher [this message]
2010-12-09 18:50 ` Wolfgang Denk
2010-12-13 9:26 ` [U-Boot] [PATCH 1/2] common: introduce a genutils.h file Heiko Schocher
2011-01-09 16:46 ` Wolfgang Denk
2011-01-10 7:09 ` Heiko Schocher
2011-01-10 10:19 ` Wolfgang Denk
2011-06-09 9:07 ` [U-Boot] [PATCH v3 1/2] common: move BUILD_BUG_ON define to common.h Heiko Schocher
2011-07-27 21:46 ` Wolfgang Denk
2010-12-13 9:26 ` [U-Boot] [PATCH 2/2 v2] hwmon: do not init sensors on startup Heiko Schocher
2011-01-09 16:49 ` Wolfgang Denk
2011-06-09 9:07 ` [U-Boot] [PATCH v3 2/2] " Heiko Schocher
2011-08-01 7:23 ` Holger Brunck
2011-08-01 10:13 ` Wolfgang Denk
2011-08-01 10:12 ` Wolfgang Denk
2011-08-01 11:08 ` [U-Boot] [PATCH v4 " Heiko Schocher
2011-08-01 13:28 ` Wolfgang Denk
2011-08-01 13:54 ` Heiko Schocher
2011-08-01 14:01 ` [U-Boot] [PATCH v5 " Heiko Schocher
2011-08-04 21:31 ` Wolfgang Denk
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=4D00F98B.1010507@denx.de \
--to=hs@denx.de \
--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