
Dear Heiko Schocher,
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?
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])); }
Best regards,
Wolfgang Denk