QcomModulePkg: Add a flag to enable/disable new node searching function
Add a flag to enable/disable new node searching function.
Default is enabled.
Change-Id: Ia4da7b28cdebf54c13751ebb25984d3adf7e8979
diff --git a/QcomModulePkg/Include/Library/FdtRw.h b/QcomModulePkg/Include/Library/FdtRw.h
index a0204d1..488cd32 100644
--- a/QcomModulePkg/Include/Library/FdtRw.h
+++ b/QcomModulePkg/Include/Library/FdtRw.h
@@ -45,19 +45,23 @@
#define FDT_ALIGN(x, a) (((x) + (a)-1) & ~((a)-1))
#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
-#define FdtPropUpdateFunc(Fdt, Offset, Name, Val, FdtUpdateFunc, RetValue) \
- do { \
- INT32 OldLen = FdtGetPropLen (Fdt, Offset, Name); \
- RetValue = FdtUpdateFunc (Fdt, Offset, Name, Val); \
- if (RetValue == 0) { \
- INT32 NewLen = FdtGetPropLen (Fdt, Offset, Name); \
- if (OldLen == 0 && \
- NewLen) { \
- NewLen = sizeof (struct fdt_property) + FDT_TAGALIGN (NewLen); \
- } \
- /* Update the node's offset in the list */ \
- FdtUpdateNodeOffsetInList ( \
- Offset, FDT_TAGALIGN (NewLen) - FDT_TAGALIGN (OldLen)); \
- } \
+#define FdtPropUpdateFunc(Fdt, Offset, Name, Val, FdtUpdateFunc, RetValue) \
+ do { \
+ if (FixedPcdGetBool (EnableNewNodeSearchFuc)) { \
+ INT32 OldLen = FdtGetPropLen (Fdt, Offset, Name); \
+ RetValue = FdtUpdateFunc (Fdt, Offset, Name, Val); \
+ if (RetValue == 0) { \
+ INT32 NewLen = FdtGetPropLen (Fdt, Offset, Name); \
+ if (OldLen == 0 && \
+ NewLen) { \
+ NewLen = sizeof (struct fdt_property) + FDT_TAGALIGN (NewLen); \
+ } \
+ /* Update the node's offset in the list */ \
+ FdtUpdateNodeOffsetInList ( \
+ Offset, FDT_TAGALIGN (NewLen) - FDT_TAGALIGN (OldLen)); \
+ } \
+ } else { \
+ RetValue = FdtUpdateFunc (Fdt, Offset, Name, Val); \
+ } \
} while (0)
#endif
diff --git a/QcomModulePkg/Library/BootLib/BootLib.inf b/QcomModulePkg/Library/BootLib/BootLib.inf
index 4df4550..adfeaf2 100644
--- a/QcomModulePkg/Library/BootLib/BootLib.inf
+++ b/QcomModulePkg/Library/BootLib/BootLib.inf
@@ -162,6 +162,7 @@
gQcomTokenSpaceGuid.EnableDisplayMenu
gQcomTokenSpaceGuid.KernelLoadAddress32
gQcomTokenSpaceGuid.EnableMdtpSupport
+ gQcomTokenSpaceGuid.EnableNewNodeSearchFuc
[Depex]
TRUE
diff --git a/QcomModulePkg/Library/BootLib/FdtRw.c b/QcomModulePkg/Library/BootLib/FdtRw.c
index 07aa46b..f561e98 100644
--- a/QcomModulePkg/Library/BootLib/FdtRw.c
+++ b/QcomModulePkg/Library/BootLib/FdtRw.c
@@ -305,44 +305,48 @@
UINT32 Level = 0;
INT32 Ret;
- if ((Ret = fdt_check_header (Fdt)) != 0) {
- return Ret;
- }
-
- /* see if we have an alias */
- if (*Path != '/') {
- Qtr = strchr (Path, '/');
- if (!Qtr) {
- Qtr = End;
+ if (FixedPcdGetBool (EnableNewNodeSearchFuc)) {
+ if ((Ret = fdt_check_header (Fdt)) != 0) {
+ return Ret;
}
- Ptr = fdt_get_alias_namelen (Fdt, Ptr, Qtr - Ptr);
- if (!Ptr) {
- return -FDT_ERR_BADPATH;
+ /* see if we have an alias */
+ if (*Path != '/') {
+ Qtr = strchr (Path, '/');
+ if (!Qtr) {
+ Qtr = End;
+ }
+
+ Ptr = fdt_get_alias_namelen (Fdt, Ptr, Qtr - Ptr);
+ if (!Ptr) {
+ return -FDT_ERR_BADPATH;
+ }
+
+ Offset = FdtPathOffset (Fdt, Ptr);
+ Ptr = Qtr;
}
- Offset = FdtPathOffset (Fdt, Ptr);
- Ptr = Qtr;
- }
+ while (*Ptr) {
+ while (*Ptr == '/') {
+ Ptr++;
+ }
+ if (! *Ptr) {
+ return Offset;
+ }
+ Qtr = strchr (Ptr, '/');
+ if (! Qtr) {
+ Qtr = End;
+ }
- while (*Ptr) {
- while (*Ptr == '/') {
- Ptr++;
+ Offset = FdtSubnodeOffsetNamelen (Fdt, Offset, Ptr, Qtr - Ptr, Level);
+ if (Offset < 0) {
+ return Offset;
+ }
+ Ptr = Qtr;
+ Level ++;
}
- if (! *Ptr) {
- return Offset;
- }
- Qtr = strchr (Ptr, '/');
- if (! Qtr) {
- Qtr = End;
- }
-
- Offset = FdtSubnodeOffsetNamelen (Fdt, Offset, Ptr, Qtr - Ptr, Level);
- if (Offset < 0) {
- return Offset;
- }
- Ptr = Qtr;
- Level ++;
+ } else {
+ Offset = fdt_path_offset (Fdt, Path);
}
return Offset;
@@ -395,23 +399,26 @@
INT32 OldLen, NewLen;
INT32 Ret = 0;
- OldLen = FdtGetPropLen (Fdt, Offset, Name);
- Ret = fdt_setprop (Fdt, Offset, Name, Val, Len);
- if (Ret == 0) {
- NewLen = FdtGetPropLen (Fdt, Offset, Name);
+ if (FixedPcdGetBool (EnableNewNodeSearchFuc)) {
+ OldLen = FdtGetPropLen (Fdt, Offset, Name);
+ Ret = fdt_setprop (Fdt, Offset, Name, Val, Len);
+ if (Ret == 0) {
+ NewLen = FdtGetPropLen (Fdt, Offset, Name);
+ } else {
+ return Ret;
+ }
+
+ /* New prop */
+ if (OldLen == 0 &&
+ NewLen) {
+ NewLen = sizeof (struct fdt_property) + FDT_TAGALIGN (NewLen);
+ }
+
+ /* Update the node's offset in the list */
+ FdtUpdateNodeOffsetInList (
+ Offset, FDT_TAGALIGN (NewLen) - FDT_TAGALIGN (OldLen));
} else {
- return Ret;
+ Ret = fdt_setprop (Fdt, Offset, Name, Val, Len);
}
-
- /* New prop */
- if (OldLen == 0 &&
- NewLen) {
- NewLen = sizeof (struct fdt_property) + FDT_TAGALIGN (NewLen);
- }
-
- /* Update the node's offset in the list */
- FdtUpdateNodeOffsetInList (
- Offset, FDT_TAGALIGN (NewLen) - FDT_TAGALIGN (OldLen));
-
return Ret;
}
diff --git a/QcomModulePkg/QcomModulePkg.dec b/QcomModulePkg/QcomModulePkg.dec
index 5cb00ab..c3baa60 100644
--- a/QcomModulePkg/QcomModulePkg.dec
+++ b/QcomModulePkg/QcomModulePkg.dec
@@ -156,3 +156,4 @@
gQcomTokenSpaceGuid.AllowEio|FALSE|BOOLEAN|0x00015008
gQcomTokenSpaceGuid.EnableBatteryVoltageCheck|TRUE|BOOLEAN|0x00015009
gQcomTokenSpaceGuid.RamdiskEndAddress32|0x03C00000|UINT32|0x0001500A
+ gQcomTokenSpaceGuid.EnableNewNodeSearchFuc|TRUE|BOOLEAN|0x0001500B