diff mbox series

[U-Boot,2/2] fdtdec: Remove fdt_{addr,size}_unpack()

Message ID 20190415080821.441-2-thierry.reding@gmail.com
State Accepted
Delegated to: Simon Glass
Headers show
Series [U-Boot,1/2] fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle() | expand

Commit Message

Thierry Reding April 15, 2019, 8:08 a.m. UTC
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(-)

Comments

Thierry Reding April 26, 2019, 12:01 p.m. UTC | #1
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
>
Simon Glass May 7, 2019, 3:52 a.m. UTC | #2
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
Thierry Reding May 7, 2019, 8:34 a.m. UTC | #3
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
diff mbox series

Patch

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);