diff options
Diffstat (limited to 'cmd/adc.c')
-rw-r--r-- | cmd/adc.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -71,6 +71,7 @@ static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int argc, static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + char *varname = NULL; struct udevice *dev; unsigned int data; int ret, uV, val; @@ -78,6 +79,9 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 3) return CMD_RET_USAGE; + if (argc >= 4) + varname = argv[3]; + ret = adc_channel_single_shot(argv[1], simple_strtol(argv[2], NULL, 0), &data); if (ret) { @@ -95,7 +99,8 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, printf("%u\n", data); } - env_set_ulong(argv[2], val); + if (varname) + env_set_ulong(varname, val); return CMD_RET_SUCCESS; } @@ -160,5 +165,5 @@ static char adc_help_text[] = U_BOOT_CMD_WITH_SUBCMDS(adc, "ADC sub-system", adc_help_text, U_BOOT_SUBCMD_MKENT(list, 1, 1, do_adc_list), U_BOOT_SUBCMD_MKENT(info, 2, 1, do_adc_info), - U_BOOT_SUBCMD_MKENT(single, 3, 1, do_adc_single), + U_BOOT_SUBCMD_MKENT(single, 4, 1, do_adc_single), U_BOOT_SUBCMD_MKENT(scan, 3, 1, do_adc_scan)); |