Fix overlay creation logic to use reg value for node names
This commit fixes device tree overlay creation logic and templates
to use reg values for node names.
Change-Id: I0945ad204c74a52a96ac283884a699e125b703fe
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index f80994f..697456d 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -30,6 +30,7 @@
constexpr const char *OUTPUT_DIR = "/tmp/overlays";
constexpr const char *TEMPLATE_DIR = "/usr/share/overlay_templates";
constexpr const char *TEMPLATE_CHAR = "$";
+constexpr const char *HEX_FORMAT_STR = "0x";
constexpr const char *PLATFORM = "aspeed,ast2500";
constexpr const char *I2C_DEVS_DIR = "/sys/class/i2c-dev";
@@ -173,6 +174,21 @@
keyPair.value().get<std::string>(), ILLEGAL_NAME_REGEX, "_");
name = subsituteString;
}
+ else if (keyPair.key() == "address")
+ {
+ if (keyPair.value().type() == nlohmann::json::value_t::string)
+ {
+ subsituteString = keyPair.value().get<std::string>();
+ subsituteString.erase(
+ 0, subsituteString.find_first_not_of(HEX_FORMAT_STR));
+ }
+ else
+ {
+ std::ostringstream hex;
+ hex << std::hex << keyPair.value().get<unsigned int>();
+ subsituteString = hex.str();
+ }
+ }
else
{
subsituteString = jsonToString(keyPair.value());
@@ -289,4 +305,4 @@
}
return true;
-}
\ No newline at end of file
+}