]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: adc: print single conversion also in uV
authorFabrice Gasnier <fabrice.gasnier@st.com>
Mon, 12 Nov 2018 13:04:00 +0000 (14:04 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 20 Nov 2018 17:35:34 +0000 (12:35 -0500)
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 <fabrice.gasnier@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/adc.c

index 39f61c13b29a1f89486467858b6a62db96eb8d55..7360a960b7396c095dbc7c732378eaa70276a98d 100644 (file)
--- 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;
 }