diff options
author | Burt P <pburt0@gmail.com> | 2017-07-16 22:55:22 -0500 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2017-07-19 07:20:40 -0700 |
commit | 2ca9d0b1099b841abd6b11dcdb7502cca79b7eae (patch) | |
tree | 6fc5f4aef3fd8e06915b8f8da8396b7f245ea26d /modules | |
parent | 9f6a082af753af22b426dfa1b31e524998fe0dea (diff) |
device tree: display ints
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/devices/devicetree.c | 13 |
1 files changed, 12 insertions, 1 deletions
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 <unistd.h> #include <sys/types.h> +#include <endian.h> #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); } |