diff options
author | Burt P <pburt0@gmail.com> | 2017-07-17 00:04:23 -0500 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2017-07-19 07:20:40 -0700 |
commit | b818ca070f7e70ab0249b093958e24cd9588d9c9 (patch) | |
tree | 49de120d4578b54dc4ee4f01e50e3ac9c9736351 /modules | |
parent | 2ca9d0b1099b841abd6b11dcdb7502cca79b7eae (diff) |
device tree: Add 'compatible' to default summary, fix rpi bug
Fixes a bug where a Raspberry Pi with a generic arm kernel will
be detected but not have a revision code in cpuinfo to lookup
information with.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/devices/devicetree.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/modules/devices/devicetree.c b/modules/devices/devicetree.c index 91be3bfb..b153b79a 100644 --- a/modules/devices/devicetree.c +++ b/modules/devices/devicetree.c @@ -157,14 +157,17 @@ void dt_raw_free(dt_raw *s) { free(s); } -static char *get_dt_string(char *p) { +static char *get_dt_string(char *p, int decode) { dt_raw *prop; char *ret, *rep; prop = get_dt_raw(p); if (prop != NULL) { - ret = g_strdup(prop->data); - if (ret) { - while((rep = strchr(ret, '\n'))) *rep = ' '; + if (decode) + ret = dt_str(prop); + else { + ret = g_strdup(prop->data); + if (ret) + while((rep = strchr(ret, '\n'))) *rep = ' '; } dt_raw_free(prop); return ret; @@ -223,9 +226,10 @@ gchar *get_node(char *np) { } gchar *get_summary() { - char *model = NULL, *serial = NULL, *ret = NULL; - model = get_dt_string("model"); - serial = get_dt_string("serial-number"); + char *model = NULL, *serial = NULL, *compat = NULL, *ret = NULL; + model = get_dt_string("model", 0); + serial = get_dt_string("serial-number", 0); + compat = get_dt_string("compatible", 1); /* Expand on the DT information from known machines, like RPi. * RPi stores a revision value in /proc/cpuinfo that can be used @@ -235,14 +239,18 @@ gchar *get_summary() { * machine identifiers in /proc/cpuinfo. */ if ( strstr(model, "Raspberry Pi") != NULL ) ret = rpi_board_details(); - else + + if (ret == NULL) { ret = g_strdup_printf( "[%s]\n" "%s=%s\n" + "%s=%s\n" "%s=%s\n", _("Board"), _("Model"), model, - _("Serial Number"), serial); + _("Serial Number"), serial, + _("Compatible"), compat); + } free(model); free(serial); @@ -273,7 +281,7 @@ void add_keys(char *np) { if ( g_file_test(ftmp, G_FILE_TEST_IS_DIR) ) { ntmp = g_strdup_printf("%s/%s", np, fn); ptmp = g_strdup_printf("%s/name", ntmp, fn); - n_name = get_dt_string(ptmp); + n_name = get_dt_string(ptmp, 0); n_info = get_node(ntmp); mi_add(ntmp, n_info); g_free(n_name); |