public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle()
@ 2019-04-15  8:08 Thierry Reding
  2019-04-15  8:08 ` [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() Thierry Reding
  2019-04-25 13:25 ` [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() Thierry Reding
  0 siblings, 2 replies; 10+ messages in thread
From: Thierry Reding @ 2019-04-15  8:08 UTC (permalink / raw)
  To: u-boot

From: Thierry Reding <treding@nvidia.com>

The fdt_setprop_u32() function does everything that we need, so we
really only use the function as a convenience wrapper, in which case it
can simply be a static inline function.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 include/fdtdec.h | 5 ++++-
 lib/fdtdec.c     | 7 -------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 266c58271f0b..110aa6ab6dea 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1029,7 +1029,10 @@ int fdtdec_setup_memory_banksize(void);
  * @param phandle	phandle to set for the given node
  * @return 0 on success or a negative error code on failure
  */
-int fdtdec_set_phandle(void *blob, int node, uint32_t phandle);
+static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
+{
+	return fdt_setprop_u32(blob, node, "phandle", phandle);
+}
 
 /**
  * fdtdec_add_reserved_memory() - add or find a reserved-memory node
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 9c9c30234732..fea44a9a8c65 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1261,13 +1261,6 @@ __weak void *board_fdt_blob_setup(void)
 }
 #endif
 
-int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
-{
-	fdt32_t value = cpu_to_fdt32(phandle);
-
-	return fdt_setprop(blob, node, "phandle", &value, sizeof(value));
-}
-
 static int fdtdec_init_reserved_memory(void *blob)
 {
 	int na, ns, node, err;
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/2] fdtdec: test: Fix memory leak
@ 2019-05-20 16:05 Thierry Reding
  2019-05-20 16:05 ` [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() Thierry Reding
  0 siblings, 1 reply; 10+ messages in thread
From: Thierry Reding @ 2019-05-20 16:05 UTC (permalink / raw)
  To: u-boot

From: Thierry Reding <treding@nvidia.com>

Free the memory allocated to store the test FDT upon test completion to
avoid leaking the memory. We don't bother cleaning up on test failure
since the code is broken in that case and should be fixed, in which case
the leak would also go away.

Reported-by: Tom Rini <tom.rini@gmail.com>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 lib/fdtdec_test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c
index f6defe16c5a6..54efcc3d46ac 100644
--- a/lib/fdtdec_test.c
+++ b/lib/fdtdec_test.c
@@ -138,6 +138,7 @@ static int run_test(const char *aliases, const char *nodes, const char *expect)
 	}
 
 	printf("pass\n");
+	free(blob);
 	return 0;
 }
 
@@ -288,6 +289,7 @@ static int check_carveout(void)
 	CHECKVAL(make_fdt_carveout(fdt, FDT_SIZE, 2, 2), 0);
 	CHECKOK(check_fdt_carveout(fdt, 2, 2));
 
+	free(fdt);
 	return 0;
 }
 
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-22 13:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-15  8:08 [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() Thierry Reding
2019-04-15  8:08 ` [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() Thierry Reding
2019-04-26 12:01   ` Thierry Reding
2019-05-07  3:52     ` Simon Glass
2019-05-07  8:34       ` Thierry Reding
2019-04-25 13:25 ` [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() Thierry Reding
2019-05-07  3:52   ` Simon Glass
2019-05-07  8:31     ` Thierry Reding
  -- strict thread matches above, loose matches on Subject: below --
2019-05-20 16:05 [U-Boot] [PATCH 1/2] fdtdec: test: Fix memory leak Thierry Reding
2019-05-20 16:05 ` [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() Thierry Reding
2019-05-22 13:21   ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox