diff options
author | Heinrich Schuchardt | 2022-04-25 22:26:45 +0200 |
---|---|---|
committer | Tom Rini | 2022-05-05 15:06:02 -0400 |
commit | 54d24d72601321f4470c4edf31c6b29adae424a7 (patch) | |
tree | edc082ec54051b84431fc912979a33ebe87ddaa2 /cmd | |
parent | e4269636bec4e64dc363e237c2d1efa0e8645310 (diff) |
cmd: simplify do_adc_single()
If argc is not < 3, it must be >= 3.
If argc >= 3, argv[2] cannot be NULL.
Fixes: 9de612ae4ded ("cmd: adc: Add support for storing ADC result in env variable")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/adc.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/cmd/adc.c b/cmd/adc.c index 8de9121cad6..195efa8661c 100644 --- a/cmd/adc.c +++ b/cmd/adc.c @@ -71,7 +71,6 @@ 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; @@ -79,9 +78,6 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 3) return CMD_RET_USAGE; - if (argc >= 3) - varname = argv[2]; - ret = adc_channel_single_shot(argv[1], simple_strtol(argv[2], NULL, 0), &data); if (ret) { @@ -99,8 +95,7 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc, printf("%u\n", data); } - if (varname) - env_set_ulong(varname, val); + env_set_ulong(argv[2], val); return CMD_RET_SUCCESS; } |