[U-Boot-Users] [Patch 5/9 Try 3]U-boot-V2:cmd: add I2C commands

Sascha Hauer s.hauer at pengutronix.de
Tue Jun 24 08:18:24 CEST 2008


On Sun, Jun 22, 2008 at 01:56:12PM -0500, Menon, Nishanth wrote:
> i2cdev command is introduced here. This allows
> for device creation for doing i2c ops. With tab
> indents corrected.

Nice and short ;) , just one comment...

 +
> +       while ((opt = getopt(argc, argv, "arb:d:")) > 0) {
> +               switch (opt) {
> +               case 'a':
> +                       if (rem) {
> +                               fprintf(stderr,
> +                                       "you cannot add when you selected "
> +                                       "delete!\n");
> +                               goto fail_ret;
> +                       }
> +                       add = 1;
> +                       break;
> +               case 'r':
> +                       if (add) {
> +                               fprintf(stderr,
> +                                       "you cannot delete when you selected "
> +                                       "add!\n");
> +                               goto fail_ret;
> +                       }
> +                       rem = 1;
> +                       break;
> +               case 'b':
> +                       bus_dev = optarg;
> +                       break;
> +               case 'd':
> +                       dev_addr = (int)simple_strtoul(optarg, NULL, 10);
> +                       if (dev_addr > 0xFF) {
> +                               fprintf(stderr, "I2C address are b/w 0 and "
> +                                       "0x7f\n");
> +                               goto fail_ret;
> +                       }
> +                       break;
> +               default:
> +                       fprintf(stderr, "unknown arg %s\n", opt);
> +                       goto fail_ret;
> +               }
> +       }

Instead of two seperate if claues above:

if (add && rem) {
	printf("both remove and add are selected\n");
	goto fail_ret;
}

Regards,
   Sascha

-- 
Pengutronix e.K. - Linux Solutions for Science and Industry
-----------------------------------------------------------
Kontakt-Informationen finden Sie im Header dieser Mail oder
auf der Webseite -> http://www.pengutronix.de/impressum/ <-




More information about the U-Boot mailing list