diff options
author | Peter Tyser <ptyser@xes-inc.com> | 2009-04-19 03:34:04 (GMT) |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-06-12 18:39:46 (GMT) |
commit | e96ad5d3aba42f8ffe99f7cc5ec1bb9f21810035 (patch) | |
tree | bd49baf2b54ace66628a47ccef98488ebcaca34d /common | |
parent | 0f89c54be92773b23d66ac401ba6acb6144100c3 (diff) | |
download | u-boot-e96ad5d3aba42f8ffe99f7cc5ec1bb9f21810035.tar.xz |
cmd_i2c: Clean up i2c command argument parsing
argc and argv should only be modified once instead of once for
every i2c sub-command
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_i2c.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 903856d..3d3127c 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -1274,35 +1274,39 @@ int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { + /* Strip off leading 'i2c' command argument */ + argc--; + argv++; + #if defined(CONFIG_I2C_MUX) - if (!strncmp(argv[1], "bu", 2)) - return do_i2c_add_bus(cmdtp, flag, --argc, ++argv); + if (!strncmp(argv[0], "bu", 2)) + return do_i2c_add_bus(cmdtp, flag, argc, argv); #endif /* CONFIG_I2C_MUX */ - if (!strncmp(argv[1], "sp", 2)) - return do_i2c_bus_speed(cmdtp, flag, --argc, ++argv); + if (!strncmp(argv[0], "sp", 2)) + return do_i2c_bus_speed(cmdtp, flag, argc, argv); #if defined(CONFIG_I2C_MULTI_BUS) - if (!strncmp(argv[1], "de", 2)) - return do_i2c_bus_num(cmdtp, flag, --argc, ++argv); + if (!strncmp(argv[0], "de", 2)) + return do_i2c_bus_num(cmdtp, flag, argc, argv); #endif /* CONFIG_I2C_MULTI_BUS */ - if (!strncmp(argv[1], "md", 2)) - return do_i2c_md(cmdtp, flag, --argc, ++argv); - if (!strncmp(argv[1], "mm", 2)) - return do_i2c_mm(cmdtp, flag, --argc, ++argv); - if (!strncmp(argv[1], "mw", 2)) - return do_i2c_mw(cmdtp, flag, --argc, ++argv); - if (!strncmp(argv[1], "nm", 2)) - return do_i2c_nm(cmdtp, flag, --argc, ++argv); - if (!strncmp(argv[1], "cr", 2)) - return do_i2c_crc(cmdtp, flag, --argc, ++argv); - if (!strncmp(argv[1], "pr", 2)) - return do_i2c_probe(cmdtp, flag, --argc, ++argv); - if (!strncmp(argv[1], "re", 2)) - return do_i2c_reset(cmdtp, flag, --argc, ++argv); - if (!strncmp(argv[1], "lo", 2)) - return do_i2c_loop(cmdtp, flag, --argc, ++argv); + if (!strncmp(argv[0], "md", 2)) + return do_i2c_md(cmdtp, flag, argc, argv); + if (!strncmp(argv[0], "mm", 2)) + return do_i2c_mm(cmdtp, flag, argc, argv); + if (!strncmp(argv[0], "mw", 2)) + return do_i2c_mw(cmdtp, flag, argc, argv); + if (!strncmp(argv[0], "nm", 2)) + return do_i2c_nm(cmdtp, flag, argc, argv); + if (!strncmp(argv[0], "cr", 2)) + return do_i2c_crc(cmdtp, flag, argc, argv); + if (!strncmp(argv[0], "pr", 2)) + return do_i2c_probe(cmdtp, flag, argc, argv); + if (!strncmp(argv[0], "re", 2)) + return do_i2c_reset(cmdtp, flag, argc, argv); + if (!strncmp(argv[0], "lo", 2)) + return do_i2c_loop(cmdtp, flag, argc, argv); #if defined(CONFIG_CMD_SDRAM) - if (!strncmp(argv[1], "sd", 2)) - return do_sdram(cmdtp, flag, --argc, ++argv); + if (!strncmp(argv[0], "sd", 2)) + return do_sdram(cmdtp, flag, argc, argv); #endif else cmd_usage(cmdtp); |