aboutsummaryrefslogtreecommitdiff
path: root/modules/devices
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-07-19 16:49:44 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2017-07-21 05:14:20 -0700
commite3c217f47dcfff0967bf48cdd9efa3e3e4f07d50 (patch)
tree8a124a9f1e79f7a263c9c7434658d9cc8a867ed7 /modules/devices
parent41a3cde484b21c24c9a5f88461591c4a42603960 (diff)
device tree: try harder to find device-tree root
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/devices')
-rw-r--r--modules/devices/devicetree/dt_util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/devices/devicetree/dt_util.c b/modules/devices/devicetree/dt_util.c
index dbeda3a6..845ea8da 100644
--- a/modules/devices/devicetree/dt_util.c
+++ b/modules/devices/devicetree/dt_util.c
@@ -192,6 +192,22 @@ void _dtr_read_aliases(dtr *);
void _dtr_read_symbols(dtr *);
void _dtr_map_phandles(dtr *, char *np);
+const char *dtr_find_device_tree_root() {
+ char *candidates[] = {
+ "/proc/device-tree",
+ "/sys/firmware/devicetree/base",
+ /* others? */
+ NULL
+ };
+ int i = 0;
+ while (candidates[i] != NULL) {
+ if(access(candidates[i], F_OK) != -1)
+ return candidates[i];
+ i++;
+ }
+ return "/did/not/find/device-tree";
+}
+
dtr *dtr_new_x(char *base_path, int fast) {
dtr *dt = malloc(sizeof(dtr));
if (dt != NULL) {