Dear Heiko Schocher,

In message <1291903238-29071-1-git-send-email...@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

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"We don't have to protect the environment -- the Second Coming is  at
hand."                                                   - James Watt
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to