* [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 2/2] fdtdec: Remove fdt_{addr,size}_unpack() 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 ` Thierry Reding 2019-04-26 12:01 ` Thierry Reding 2019-04-25 13:25 ` [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() Thierry Reding 1 sibling, 1 reply; 10+ messages in thread From: Thierry Reding @ 2019-04-15 8:08 UTC (permalink / raw) To: u-boot From: Thierry Reding <treding@nvidia.com> U-Boot already defines the {upper,lower}_32_bits() macros that have the same purpose. Use the existing macros instead of defining new APIs. Signed-off-by: Thierry Reding <treding@nvidia.com> --- include/fdtdec.h | 24 ------------------------ lib/fdtdec.c | 8 ++++++-- lib/fdtdec_test.c | 8 ++++++-- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 110aa6ab6dea..fa8e34f6f960 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -24,30 +24,6 @@ typedef phys_addr_t fdt_addr_t; typedef phys_size_t fdt_size_t; -static inline fdt32_t fdt_addr_unpack(fdt_addr_t addr, fdt32_t *upper) -{ - if (upper) -#ifdef CONFIG_PHYS_64BIT - *upper = addr >> 32; -#else - *upper = 0; -#endif - - return addr; -} - -static inline fdt32_t fdt_size_unpack(fdt_size_t size, fdt32_t *upper) -{ - if (upper) -#ifdef CONFIG_PHYS_64BIT - *upper = size >> 32; -#else - *upper = 0; -#endif - - return size; -} - #ifdef CONFIG_PHYS_64BIT #define FDT_ADDR_T_NONE (-1U) #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index fea44a9a8c65..d0ba88897335 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1300,6 +1300,7 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, fdt32_t cells[4] = {}, *ptr = cells; uint32_t upper, lower, phandle; int parent, node, na, ns, err; + fdt_size_t size; char name[64]; /* create an empty /reserved-memory node if one doesn't exist */ @@ -1340,7 +1341,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, * Unpack the start address and generate the name of the new node * base on the basename and the unit-address. */ - lower = fdt_addr_unpack(carveout->start, &upper); + upper = upper_32_bits(carveout->start); + lower = lower_32_bits(carveout->start); if (na > 1 && upper > 0) snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, @@ -1374,7 +1376,9 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, *ptr++ = cpu_to_fdt32(lower); /* store one or two size cells */ - lower = fdt_size_unpack(carveout->end - carveout->start + 1, &upper); + size = carveout->end - carveout->start + 1; + upper = upper_32_bits(size); + lower = lower_32_bits(size); if (ns > 1) *ptr++ = cpu_to_fdt32(upper); diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c index f6defe16c5a6..1f4f27054057 100644 --- a/lib/fdtdec_test.c +++ b/lib/fdtdec_test.c @@ -155,11 +155,13 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns) }; fdt32_t cells[4], *ptr = cells; uint32_t upper, lower; + fdt_size_t size; char name[32]; int offset; /* store one or two address cells */ - lower = fdt_addr_unpack(carveout.start, &upper); + upper = upper_32_bits(carveout.start); + lower = lower_32_bits(carveout.start); if (na > 1 && upper > 0) snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, @@ -173,7 +175,9 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns) *ptr++ = cpu_to_fdt32(lower); /* store one or two size cells */ - lower = fdt_size_unpack(carveout.end - carveout.start + 1, &upper); + size = carveout.end - carveout.start + 1; + upper = upper_32_bits(size); + lower = lower_32_bits(size); if (ns > 1) *ptr++ = cpu_to_fdt32(upper); -- 2.21.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() 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 0 siblings, 1 reply; 10+ messages in thread From: Thierry Reding @ 2019-04-26 12:01 UTC (permalink / raw) To: u-boot On Mon, Apr 15, 2019 at 10:08:21AM +0200, Thierry Reding wrote: > From: Thierry Reding <treding@nvidia.com> > > U-Boot already defines the {upper,lower}_32_bits() macros that have the > same purpose. Use the existing macros instead of defining new APIs. > > Signed-off-by: Thierry Reding <treding@nvidia.com> > --- > include/fdtdec.h | 24 ------------------------ > lib/fdtdec.c | 8 ++++++-- > lib/fdtdec_test.c | 8 ++++++-- > 3 files changed, 12 insertions(+), 28 deletions(-) Hi Simon, you picked up patch 1/2 of this set. Did you have any comments on v2, or did you overlook it? Thierry > diff --git a/include/fdtdec.h b/include/fdtdec.h > index 110aa6ab6dea..fa8e34f6f960 100644 > --- a/include/fdtdec.h > +++ b/include/fdtdec.h > @@ -24,30 +24,6 @@ > typedef phys_addr_t fdt_addr_t; > typedef phys_size_t fdt_size_t; > > -static inline fdt32_t fdt_addr_unpack(fdt_addr_t addr, fdt32_t *upper) > -{ > - if (upper) > -#ifdef CONFIG_PHYS_64BIT > - *upper = addr >> 32; > -#else > - *upper = 0; > -#endif > - > - return addr; > -} > - > -static inline fdt32_t fdt_size_unpack(fdt_size_t size, fdt32_t *upper) > -{ > - if (upper) > -#ifdef CONFIG_PHYS_64BIT > - *upper = size >> 32; > -#else > - *upper = 0; > -#endif > - > - return size; > -} > - > #ifdef CONFIG_PHYS_64BIT > #define FDT_ADDR_T_NONE (-1U) > #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) > diff --git a/lib/fdtdec.c b/lib/fdtdec.c > index fea44a9a8c65..d0ba88897335 100644 > --- a/lib/fdtdec.c > +++ b/lib/fdtdec.c > @@ -1300,6 +1300,7 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, > fdt32_t cells[4] = {}, *ptr = cells; > uint32_t upper, lower, phandle; > int parent, node, na, ns, err; > + fdt_size_t size; > char name[64]; > > /* create an empty /reserved-memory node if one doesn't exist */ > @@ -1340,7 +1341,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, > * Unpack the start address and generate the name of the new node > * base on the basename and the unit-address. > */ > - lower = fdt_addr_unpack(carveout->start, &upper); > + upper = upper_32_bits(carveout->start); > + lower = lower_32_bits(carveout->start); > > if (na > 1 && upper > 0) > snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, > @@ -1374,7 +1376,9 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, > *ptr++ = cpu_to_fdt32(lower); > > /* store one or two size cells */ > - lower = fdt_size_unpack(carveout->end - carveout->start + 1, &upper); > + size = carveout->end - carveout->start + 1; > + upper = upper_32_bits(size); > + lower = lower_32_bits(size); > > if (ns > 1) > *ptr++ = cpu_to_fdt32(upper); > diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c > index f6defe16c5a6..1f4f27054057 100644 > --- a/lib/fdtdec_test.c > +++ b/lib/fdtdec_test.c > @@ -155,11 +155,13 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns) > }; > fdt32_t cells[4], *ptr = cells; > uint32_t upper, lower; > + fdt_size_t size; > char name[32]; > int offset; > > /* store one or two address cells */ > - lower = fdt_addr_unpack(carveout.start, &upper); > + upper = upper_32_bits(carveout.start); > + lower = lower_32_bits(carveout.start); > > if (na > 1 && upper > 0) > snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, > @@ -173,7 +175,9 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns) > *ptr++ = cpu_to_fdt32(lower); > > /* store one or two size cells */ > - lower = fdt_size_unpack(carveout.end - carveout.start + 1, &upper); > + size = carveout.end - carveout.start + 1; > + upper = upper_32_bits(size); > + lower = lower_32_bits(size); > > if (ns > 1) > *ptr++ = cpu_to_fdt32(upper); > -- > 2.21.0 > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190426/89d896b3/attachment.sig> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() 2019-04-26 12:01 ` Thierry Reding @ 2019-05-07 3:52 ` Simon Glass 2019-05-07 8:34 ` Thierry Reding 0 siblings, 1 reply; 10+ messages in thread From: Simon Glass @ 2019-05-07 3:52 UTC (permalink / raw) To: u-boot Hi Thierry, On Fri, 26 Apr 2019 at 06:01, Thierry Reding <thierry.reding@gmail.com> wrote: > > On Mon, Apr 15, 2019 at 10:08:21AM +0200, Thierry Reding wrote: > > From: Thierry Reding <treding@nvidia.com> > > > > U-Boot already defines the {upper,lower}_32_bits() macros that have the > > same purpose. Use the existing macros instead of defining new APIs. > > > > Signed-off-by: Thierry Reding <treding@nvidia.com> > > --- > > include/fdtdec.h | 24 ------------------------ > > lib/fdtdec.c | 8 ++++++-- > > lib/fdtdec_test.c | 8 ++++++-- > > 3 files changed, 12 insertions(+), 28 deletions(-) > > Hi Simon, > > you picked up patch 1/2 of this set. Did you have any comments on v2, or > did you overlook it? I marked it as superseded. http://patchwork.ozlabs.org/patch/1085480/ Is that incorrect? Regards, Simon ^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() 2019-05-07 3:52 ` Simon Glass @ 2019-05-07 8:34 ` Thierry Reding 0 siblings, 0 replies; 10+ messages in thread From: Thierry Reding @ 2019-05-07 8:34 UTC (permalink / raw) To: u-boot On Mon, May 06, 2019 at 09:52:02PM -0600, Simon Glass wrote: > Hi Thierry, > > On Fri, 26 Apr 2019 at 06:01, Thierry Reding <thierry.reding@gmail.com> wrote: > > > > On Mon, Apr 15, 2019 at 10:08:21AM +0200, Thierry Reding wrote: > > > From: Thierry Reding <treding@nvidia.com> > > > > > > U-Boot already defines the {upper,lower}_32_bits() macros that have the > > > same purpose. Use the existing macros instead of defining new APIs. > > > > > > Signed-off-by: Thierry Reding <treding@nvidia.com> > > > --- > > > include/fdtdec.h | 24 ------------------------ > > > lib/fdtdec.c | 8 ++++++-- > > > lib/fdtdec_test.c | 8 ++++++-- > > > 3 files changed, 12 insertions(+), 28 deletions(-) > > > > Hi Simon, > > > > you picked up patch 1/2 of this set. Did you have any comments on v2, or > > did you overlook it? > > I marked it as superseded. > > http://patchwork.ozlabs.org/patch/1085480/ > > Is that incorrect? I think I messed up my earlier email. What I meant to say was whether you had any comments on patch 2/2. There's no v2 of this patch and it hasn't been applied. It's also not superseeded by anything. So I think this should still be applied. Thierry -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190507/69ec294b/attachment.sig> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() 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-25 13:25 ` Thierry Reding 2019-05-07 3:52 ` Simon Glass 1 sibling, 1 reply; 10+ messages in thread From: Thierry Reding @ 2019-04-25 13:25 UTC (permalink / raw) To: u-boot On Mon, Apr 15, 2019 at 10:08:20AM +0200, Thierry Reding wrote: > 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(-) Hi Simon, gentle reminder on these. These are the two follow-up patches that you had suggested I make on top of the other fdtdec series that you applied a couple of weeks ago. Thierry > 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 > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190425/de82259d/attachment.sig> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() 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 0 siblings, 1 reply; 10+ messages in thread From: Simon Glass @ 2019-05-07 3:52 UTC (permalink / raw) To: u-boot Hi Thierry, On Thu, 25 Apr 2019 at 07:25, Thierry Reding <thierry.reding@gmail.com> wrote: > > On Mon, Apr 15, 2019 at 10:08:20AM +0200, Thierry Reding wrote: > > 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(-) > > Hi Simon, > > gentle reminder on these. These are the two follow-up patches that you > had suggested I make on top of the other fdtdec series that you applied > a couple of weeks ago. I think this is applied now? Regards, Simon ^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() 2019-05-07 3:52 ` Simon Glass @ 2019-05-07 8:31 ` Thierry Reding 0 siblings, 0 replies; 10+ messages in thread From: Thierry Reding @ 2019-05-07 8:31 UTC (permalink / raw) To: u-boot On Mon, May 06, 2019 at 09:52:00PM -0600, Simon Glass wrote: > Hi Thierry, > > On Thu, 25 Apr 2019 at 07:25, Thierry Reding <thierry.reding@gmail.com> wrote: > > > > On Mon, Apr 15, 2019 at 10:08:20AM +0200, Thierry Reding wrote: > > > 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(-) > > > > Hi Simon, > > > > gentle reminder on these. These are the two follow-up patches that you > > had suggested I make on top of the other fdtdec series that you applied > > a couple of weeks ago. > > I think this is applied now? Yes, I can see this in origin/master now. Thierry -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190507/dc191840/attachment.sig> ^ permalink raw reply [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* [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() 2019-05-20 16:05 [U-Boot] [PATCH 1/2] fdtdec: test: Fix memory leak Thierry Reding @ 2019-05-20 16:05 ` Thierry Reding 2019-05-22 13:21 ` Simon Glass 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> U-Boot already defines the {upper,lower}_32_bits() macros that have the same purpose. Use the existing macros instead of defining new APIs. Signed-off-by: Thierry Reding <treding@nvidia.com> --- include/fdtdec.h | 24 ------------------------ lib/fdtdec.c | 8 ++++++-- lib/fdtdec_test.c | 8 ++++++-- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 110aa6ab6dea..fa8e34f6f960 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -24,30 +24,6 @@ typedef phys_addr_t fdt_addr_t; typedef phys_size_t fdt_size_t; -static inline fdt32_t fdt_addr_unpack(fdt_addr_t addr, fdt32_t *upper) -{ - if (upper) -#ifdef CONFIG_PHYS_64BIT - *upper = addr >> 32; -#else - *upper = 0; -#endif - - return addr; -} - -static inline fdt32_t fdt_size_unpack(fdt_size_t size, fdt32_t *upper) -{ - if (upper) -#ifdef CONFIG_PHYS_64BIT - *upper = size >> 32; -#else - *upper = 0; -#endif - - return size; -} - #ifdef CONFIG_PHYS_64BIT #define FDT_ADDR_T_NONE (-1U) #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index fea44a9a8c65..d0ba88897335 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1300,6 +1300,7 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, fdt32_t cells[4] = {}, *ptr = cells; uint32_t upper, lower, phandle; int parent, node, na, ns, err; + fdt_size_t size; char name[64]; /* create an empty /reserved-memory node if one doesn't exist */ @@ -1340,7 +1341,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, * Unpack the start address and generate the name of the new node * base on the basename and the unit-address. */ - lower = fdt_addr_unpack(carveout->start, &upper); + upper = upper_32_bits(carveout->start); + lower = lower_32_bits(carveout->start); if (na > 1 && upper > 0) snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, @@ -1374,7 +1376,9 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, *ptr++ = cpu_to_fdt32(lower); /* store one or two size cells */ - lower = fdt_size_unpack(carveout->end - carveout->start + 1, &upper); + size = carveout->end - carveout->start + 1; + upper = upper_32_bits(size); + lower = lower_32_bits(size); if (ns > 1) *ptr++ = cpu_to_fdt32(upper); diff --git a/lib/fdtdec_test.c b/lib/fdtdec_test.c index 54efcc3d46ac..e8bfd1fb1ec3 100644 --- a/lib/fdtdec_test.c +++ b/lib/fdtdec_test.c @@ -156,11 +156,13 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns) }; fdt32_t cells[4], *ptr = cells; uint32_t upper, lower; + fdt_size_t size; char name[32]; int offset; /* store one or two address cells */ - lower = fdt_addr_unpack(carveout.start, &upper); + upper = upper_32_bits(carveout.start); + lower = lower_32_bits(carveout.start); if (na > 1 && upper > 0) snprintf(name, sizeof(name), "%s@%x,%x", basename, upper, @@ -174,7 +176,9 @@ static int make_fdt_carveout_device(void *fdt, uint32_t na, uint32_t ns) *ptr++ = cpu_to_fdt32(lower); /* store one or two size cells */ - lower = fdt_size_unpack(carveout.end - carveout.start + 1, &upper); + size = carveout.end - carveout.start + 1; + upper = upper_32_bits(size); + lower = lower_32_bits(size); if (ns > 1) *ptr++ = cpu_to_fdt32(upper); -- 2.21.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/2] fdtdec: Remove fdt_{addr,size}_unpack() 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 0 siblings, 0 replies; 10+ messages in thread From: Simon Glass @ 2019-05-22 13:21 UTC (permalink / raw) To: u-boot On Mon, 20 May 2019 at 10:05, Thierry Reding <thierry.reding@gmail.com> wrote: > > From: Thierry Reding <treding@nvidia.com> > > U-Boot already defines the {upper,lower}_32_bits() macros that have the > same purpose. Use the existing macros instead of defining new APIs. > > Signed-off-by: Thierry Reding <treding@nvidia.com> > --- > include/fdtdec.h | 24 ------------------------ > lib/fdtdec.c | 8 ++++++-- > lib/fdtdec_test.c | 8 ++++++-- > 3 files changed, 12 insertions(+), 28 deletions(-) Applied to u-boot-dm, thanks! ^ permalink raw reply [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