libfdt: overlay: Add fdt_ prefix to overlay_get_target()
PATCH 1/1 libfdt: overlay: Add fdt_ prefix to overlay_get_target()
Add fdt_ prefix to overlay_get_target() and remove static type.
This is done to get the target path for the overlay nodes which is very useful in many cases. For example, Xen hypervisor needs it when applying overlays because Xen needs to do further processing of the overlay nodes, e.g. mapping of resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc.
--- libfdt/fdt_overlay.c | 23 ++++------------------- libfdt/libfdt.h | 19 +++++++++++++++++++ libfdt/version.lds | 1 + 3 files changed, 24 insertions(+), 19 deletions(-)
libfdt/fdt_overlay.c +4 -19
@@ -40,22 +40,7 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)return fdt32_to_cpu (*val); } -/** -* overlay_get_target - retrieves the offset of a fragment's target -* @fdt: Base device tree blob -* @fdto: Device tree overlay blob -* @fragment: node offset of the fragment in the overlay -* @pathp: pointer which receives the path of the target (or NULL) -* -* overlay_get_target() retrieves the target offset in the base -* device tree of a fragment, no matter how the actual targeting is -* done (through a phandle or a path) -* -* returns: -* the targeted node offset in the base device tree -* Negative error code on error -*/ -static int overlay_get_target (const void *fdt,const void *fdto, +int fdt_overlay_get_target (const void *fdt,const void *fdto,int fragment,char const **pathp) {uint32_t phandle;
@@ -636,7 +621,7 @@ static int overlay_merge(void *fdt, void *fdto)if (overlay <0 )return overlay; - target =overlay_get_target (fdt, fdto, fragment,NULL ); + target =fdt_overlay_get_target (fdt, fdto, fragment,NULL );if (target <0 )return target;
@@ -779,7 +764,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)return -FDT_ERR_BADOVERLAY ;/* get the target of the fragment */ - ret =overlay_get_target (fdt, fdto, fragment, &target_path); + ret =fdt_overlay_get_target (fdt, fdto, fragment, &target_path);if (ret <0 )return ret; target = ret;
@@ -801,7 +786,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)if (!target_path) {/* again in case setprop_placeholder changed it */ - ret =overlay_get_target (fdt, fdto, fragment, &target_path); + ret =fdt_overlay_get_target (fdt, fdto, fragment, &target_path);if (ret <0 )return ret; target = ret;
libfdt/libfdt.h +19 -0
@@ -2116,6 +2116,25 @@ int fdt_del_node(void *fdt, int nodeoffset);*/ int fdt_overlay_apply (void *fdt,void *fdto); +/** +* fdt_overlay_get_target - retrieves the offset of a fragment's target +* @fdt: Base device tree blob +* @fdto: Device tree overlay blob +* @fragment: node offset of the fragment in the overlay +* @pathp: pointer which receives the path of the target (or NULL) +* +* fdt_overlay_get_target() retrieves the target offset in the base +* device tree of a fragment, no matter how the actual targeting is +* done (through a phandle or a path) +* +* returns: +* the targeted node offset in the base device tree +* Negative error code on error +*/ + +int fdt_overlay_get_target (const void *fdt,const void *fdto,int fragment, +char const **pathp); +/**********************************************************************/ /* Debugging / informational functions */ /**********************************************************************/
libfdt/version.lds +1 -0
@@ -77,6 +77,7 @@ LIBFDT_1.2 { fdt_appendprop_addrrange; fdt_setprop_inplace_namelen_partial; fdt_create_with_flags; + fdt_overlay_get_target; local: *; };
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 1637019043-452179-1-git-send-email-fnu.vikram-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org
Quoted 1 line · Vikram Garhwal
Add
fdt_prefix tooverlay_get_target()and remove static type.
The short description is burying the lede a bit, the key point is that you're making this function public.
Quoted 6 lines
This is done to get the target path for the overlay nodes which is very useful in many cases. For example, Xen hypervisor needs it when applying overlays because Xen needs to do further processing of the overlay nodes, e.g. mapping of resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc.
Signed-off-by Vikram Garhwal <[email protected]>
The concept looks fine to me. A few details to polish noted below:
Quoted 22 lines
--- libfdt/fdt_overlay.c | 23 ++++------------------- libfdt/libfdt.h | 19 +++++++++++++++++++ libfdt/version.lds | 1 + 3 files changed, 24 insertions(+), 19 deletions(-)libfdt/fdt_overlay.c +0
-8@@ -40,22 +40,7 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)return fdt32_to_cpu (*val); } -/** -* overlay_get_target - retrieves the offset of a fragment's target -* @fdt: Base device tree blob -* @fdto: Device tree overlay blob -* @fragment: node offset of the fragment in the overlay -* @pathp: pointer which receives the path of the target (or NULL) -* -* overlay_get_target() retrieves the target offset in the base
libfdt/fdt_overlay.c static uint32_t overlay_get_target_phandle(const void *fdto, int fragment) · line 44
Quoted 10 lines
libfdt/fdt_overlay.c +1
-8-* device tree of a fragment, no matter how the actual targeting is -* done (through a phandle or a path) -* -* returns: -* the targeted node offset in the base device tree -* Negative error code on error -*/ -static int overlay_get_target (const void *fdt,const void *fdto, +int fdt_overlay_get_target (const void *fdt,const void *fdto,int fragment,char const **pathp)
"overlay_get_target" was fine as an internal name. When published, I think "fdt_overlay_target_offset" would better fit the naming conventions for the rest of the interface.
Similarly, I'd like the @fragment parameter renamed @fragment_offset.
[The insistent use of explicit "offset" throughout the interface is
deliberate - it's an attempt to constantly remind users that these quantities are explicit offsets in the blob, which can be invalidated by other changes, rather than some sort of safe, stable handle on a node]
Quoted 71 lines
libfdt/fdt_overlay.c +3
-3{uint32_t phandle;@@ -636,7 +621,7 @@ static int overlay_merge(void *fdt, void *fdto)if (overlay <0 )return overlay; - target =overlay_get_target (fdt, fdto, fragment,NULL ); + target =fdt_overlay_get_target (fdt, fdto, fragment,NULL );if (target <0 )return target;@@ -779,7 +764,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)return -FDT_ERR_BADOVERLAY ;/* get the target of the fragment */ - ret =overlay_get_target (fdt, fdto, fragment, &target_path); + ret =fdt_overlay_get_target (fdt, fdto, fragment, &target_path);if (ret <0 )return ret; target = ret;@@ -801,7 +786,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)if (!target_path) {/* again in case setprop_placeholder changed it */ - ret =overlay_get_target (fdt, fdto, fragment, &target_path); + ret =fdt_overlay_get_target (fdt, fdto, fragment, &target_path);if (ret <0 )return ret; target = ret;libfdt/libfdt.h +19
-0@@ -2116,6 +2116,25 @@ int fdt_del_node(void *fdt, int nodeoffset);*/ int fdt_overlay_apply (void *fdt,void *fdto); +/** +* fdt_overlay_get_target - retrieves the offset of a fragment's target +* @fdt: Base device tree blob +* @fdto: Device tree overlay blob +* @fragment: node offset of the fragment in the overlay +* @pathp: pointer which receives the path of the target (or NULL) +* +* fdt_overlay_get_target() retrieves the target offset in the base +* device tree of a fragment, no matter how the actual targeting is +* done (through a phandle or a path) +* +* returns: +* the targeted node offset in the base device tree +* Negative error code on error +*/ + +int fdt_overlay_get_target (const void *fdt,const void *fdto,int fragment, +char const **pathp); +/**********************************************************************/ /* Debugging / informational functions */ /**********************************************************************/ libfdt/version.lds +1
-0@@ -77,6 +77,7 @@ LIBFDT_1.2 { fdt_appendprop_addrrange; fdt_setprop_inplace_namelen_partial; fdt_create_with_flags; + fdt_overlay_get_target; local: *; };
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 52 lines · David Gibson
Quoted 1 line · Vikram Garhwal
Add
fdt_prefix tooverlay_get_target()and remove static type.The short description is burying the lede a bit, the key point is that you're making this function public.
Quoted 6 lines
This is done to get the target path for the overlay nodes which is very useful in many cases. For example, Xen hypervisor needs it when applying overlays because Xen needs to do further processing of the overlay nodes, e.g. mapping of resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc.
Signed-off-by Vikram Garhwal <[email protected]>The concept looks fine to me. A few details to polish noted below:
Quoted 22 lines
--- libfdt/fdt_overlay.c | 23 ++++------------------- libfdt/libfdt.h | 19 +++++++++++++++++++ libfdt/version.lds | 1 + 3 files changed, 24 insertions(+), 19 deletions(-)libfdt/fdt_overlay.c +0
-8@@ -40,22 +40,7 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)return fdt32_to_cpu (*val); } -/** -* overlay_get_target - retrieves the offset of a fragment's target -* @fdt: Base device tree blob -* @fdto: Device tree overlay blob -* @fragment: node offset of the fragment in the overlay -* @pathp: pointer which receives the path of the target (or NULL) -* -* overlay_get_target() retrieves the target offset in the base libfdt/fdt_overlay.c static uint32_t overlay_get_target_phandle(const void *fdto, int fragment) · line 44
Quoted 10 lines
libfdt/fdt_overlay.c +1
-8-* device tree of a fragment, no matter how the actual targeting is -* done (through a phandle or a path) -* -* returns: -* the targeted node offset in the base device tree -* Negative error code on error -*/ -static int overlay_get_target (const void *fdt,const void *fdto, +int fdt_overlay_get_target (const void *fdt,const void *fdto,int fragment,char const **pathp)"
overlay_get_target" was fine as an internal name. When published, I think "fdt_overlay_target_offset" would better fit the naming conventions for the rest of the interface.
Quoted 8 lines
Similarly, I'd like the @fragment parameter renamed @fragment_offset.
[The insistent use of explicit "offset" throughout the interface is
deliberate - it's an attempt to constantly remind users that these quantities are explicit offsets in the blob, which can be invalidated by other changes, rather than some sort of safe, stable handle on a node]
Understood, i will make the changes and send v2 soon. Thanks for reviewing the patch.
Quoted 77 lines
Quoted 71 lines
libfdt/fdt_overlay.c +3
-3{uint32_t phandle;@@ -636,7 +621,7 @@ static int overlay_merge(void *fdt, void *fdto)if (overlay <0 )return overlay; - target =overlay_get_target (fdt, fdto, fragment,NULL ); + target =fdt_overlay_get_target (fdt, fdto, fragment,NULL );if (target <0 )return target;@@ -779,7 +764,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)return -FDT_ERR_BADOVERLAY ;/* get the target of the fragment */ - ret =overlay_get_target (fdt, fdto, fragment, &target_path); + ret =fdt_overlay_get_target (fdt, fdto, fragment, &target_path);if (ret <0 )return ret; target = ret;@@ -801,7 +786,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)if (!target_path) {/* again in case setprop_placeholder changed it */ - ret =overlay_get_target (fdt, fdto, fragment, &target_path); + ret =fdt_overlay_get_target (fdt, fdto, fragment, &target_path);if (ret <0 )return ret; target = ret;libfdt/libfdt.h +19
-0@@ -2116,6 +2116,25 @@ int fdt_del_node(void *fdt, int nodeoffset);*/ int fdt_overlay_apply (void *fdt,void *fdto); +/** +* fdt_overlay_get_target - retrieves the offset of a fragment's target +* @fdt: Base device tree blob +* @fdto: Device tree overlay blob +* @fragment: node offset of the fragment in the overlay +* @pathp: pointer which receives the path of the target (or NULL) +* +* fdt_overlay_get_target() retrieves the target offset in the base +* device tree of a fragment, no matter how the actual targeting is +* done (through a phandle or a path) +* +* returns: +* the targeted node offset in the base device tree +* Negative error code on error +*/ + +int fdt_overlay_get_target (const void *fdt,const void *fdto,int fragment, +char const **pathp); +/**********************************************************************/ /* Debugging / informational functions */ /**********************************************************************/ libfdt/version.lds +1
-0@@ -77,6 +77,7 @@ LIBFDT_1.2 { fdt_appendprop_addrrange; fdt_setprop_inplace_namelen_partial; fdt_create_with_flags; + fdt_overlay_get_target; local: *; };Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson