From: Fabrice Gasnier Date: Mon, 12 Nov 2018 13:04:00 +0000 (+0100) Subject: cmd: adc: print single conversion also in uV X-Git-Tag: v2025.01-rc5-pxa1908~3273^2~3 X-Git-Url: http://git.dujemihanovic.xyz/img/%7B%7B%20%24image.RelPermalink%20%7D%7D?a=commitdiff_plain;h=c56fc49a60397d59b3949efa8c26ab15d7ffa417;p=u-boot.git cmd: adc: print single conversion also in uV Use newly introduced adc_raw_to_uV() API to print conversion result both as raw value and micro-volts by default. Signed-off-by: Fabrice Gasnier Reviewed-by: Simon Glass --- diff --git a/cmd/adc.c b/cmd/adc.c index 39f61c13b2..7360a960b7 100644 --- a/cmd/adc.c +++ b/cmd/adc.c @@ -71,8 +71,9 @@ static int do_adc_info(cmd_tbl_t *cmdtp, int flag, int argc, static int do_adc_single(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { + struct udevice *dev; unsigned int data; - int ret; + int ret, uV; if (argc < 3) return CMD_RET_USAGE; @@ -85,7 +86,11 @@ static int do_adc_single(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } - printf("%u\n", data); + ret = uclass_get_device_by_name(UCLASS_ADC, argv[1], &dev); + if (!ret && !adc_raw_to_uV(dev, data, &uV)) + printf("%u, %d uV\n", data, uV); + else + printf("%u\n", data); return CMD_RET_SUCCESS; }