From 719c039f5daf2ecf99a1c02669745486be36ba43 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Wed, 24 Aug 2016 17:39:23 +0800 Subject: [PATCH 28/43] devtree: Add add_device_tree_info() sysfs contains symbolic link (of_node) for each device which has correspoding device tree entry. It helps user space tool to parse firmware information for that device. This patch adds logic to add location code for given sysfs path. Signed-off-by: Jeremy Kerr Signed-off-by: Vasant Hegde --- src/core/device-tree.cc | 19 +++++++++++++++++++ src/core/device-tree.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc index 0bba4e9..1e49f3a 100644 --- a/src/core/device-tree.cc +++ b/src/core/device-tree.cc @@ -1208,3 +1208,22 @@ bool scan_device_tree(hwNode & n) return true; } + +void add_device_tree_info(hwNode & n, string sysfs_path) +{ + string of_node = sysfs_path + "/of_node"; + string val; + + if (!exists(of_node)) + return; + + /* read location / slot data */ + val = hw::strip(get_string(of_node + "/ibm,loc-code", "")); + if (val == "") + val = hw::strip(get_string(of_node + "/ibm,slot-location-code", "")); + if (val == "") + val = hw::strip(get_string(of_node + "/ibm,slot-label")); + + if (val != "") + n.setSlot(val); +} diff --git a/src/core/device-tree.h b/src/core/device-tree.h index 62313aa..91ecb7d 100644 --- a/src/core/device-tree.h +++ b/src/core/device-tree.h @@ -4,4 +4,6 @@ #include "hw.h" bool scan_device_tree(hwNode & n); + +void add_device_tree_info(hwNode & n, string sysfs_path); #endif -- 2.10.2