From 9b2982813bdb1241e2149bd48893d03e139d24bb Mon Sep 17 00:00:00 2001 From: Burt P Date: Wed, 19 Jul 2017 00:55:42 -0500 Subject: device tree: reworked and cleaned up * Moved device tree functions to modules/devices/devicetree/dt_util.c * The dtr_* functions usable from outside devicetree.c, for example in get_motherboard(). Must #include "dt_util.h" * Now possible to use an alternate device tree root for testing -DOVRDTRROOT=\"/some/path\" * Alternately, pass dtr_new() an alternate base path. * Abandoned the tuple grouping and inherited properties stuff for now. Signed-off-by: Burt P --- modules/devices.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules/devices.c') diff --git a/modules/devices.c b/modules/devices.c index fe430621..afa645d6 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -37,6 +37,7 @@ #include #include "devices.h" +#include "dt_util.h" gchar *callback_processors(); gchar *callback_memory(); @@ -218,12 +219,12 @@ gchar *get_motherboard(void) return g_strconcat(board_name, _(" (vendor unknown)"), NULL); else if (board_vendor && *board_vendor) return g_strconcat(board_vendor, _(" (model unknown)"), NULL); -#else +#endif + /* use device tree "model" */ - if (g_file_get_contents("/proc/device-tree/model", &board_vendor, NULL, NULL)) { + board_vendor = dtr_get_string("/model"); + if (board_vendor != NULL) return board_vendor; - } -#endif return g_strdup(_("Unknown")); } -- cgit v1.2.3