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