From 2ca9d0b1099b841abd6b11dcdb7502cca79b7eae Mon Sep 17 00:00:00 2001 From: Burt P Date: Sun, 16 Jul 2017 22:55:22 -0500 Subject: device tree: display ints Signed-off-by: Burt P --- modules/devices/devicetree.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/devices/devicetree.c b/modules/devices/devicetree.c index 5f473d8e..91be3bfb 100644 --- a/modules/devices/devicetree.c +++ b/modules/devices/devicetree.c @@ -20,6 +20,7 @@ */ #include #include +#include #include "devices.h" enum { @@ -29,6 +30,8 @@ enum { enum { DTP_UNK, DTP_STR, + DTP_INT, + DTP_HEX, }; typedef struct { @@ -48,6 +51,9 @@ static struct { { "reg", DTP_UNK }, { "#address-cells", DTP_UNK }, { "#size-cells", DTP_UNK }, + { "regulator-min-microvolt", DTP_INT }, + { "regulator-max-microvolt", DTP_INT }, + { "clock-frequency", DTP_INT }, { NULL, 0 }, }; @@ -74,13 +80,16 @@ static int dt_guess_type(dt_raw *prop) { if ( isprint(*tmp) || *tmp == 0 ) continue; might_be_str = 0; - return DTP_UNK; + break; } if (might_be_str && ( anc >= prop->length - 2 /* all alpha-nums but ^/ and \0$ */ || anc >= 5 ) /*arbitrary*/) return DTP_STR; + if (prop->length == 4) /* maybe an int */ + return DTP_INT; + return DTP_UNK; } @@ -112,6 +121,8 @@ static char* dt_str(dt_raw *prop) { tl += l + 1; next_str += l + 1; if (tl >= prop->length) break; } + } else if (i == DTP_INT && prop->length == 4) { + ret = g_strdup_printf("%d", be32toh(*(int*)prop->data) ); } else { ret = g_strdup_printf("{data} (%d bytes)", prop->length); } -- cgit v1.2.3