linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h
@ 2019-11-13  7:12 Masahiro Yamada
  2019-11-25  1:35 ` Masahiro Yamada
  2019-11-26 20:34 ` Rob Herring
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2019-11-13  7:12 UTC (permalink / raw)
  To: devicetree, Rob Herring, Frank Rowand
  Cc: Russell King, linux-kernel, Masahiro Yamada, Paul Mackerras,
	linuxppc-dev, linux-arm-kernel

The DTC v1.5.1 added references to (U)INT32_MAX.

This is no problem for user-space programs since <stdint.h> defines
(U)INT32_MAX along with (u)int32_t.

For the kernel space, libfdt_env.h needs to be adjusted before we
pull in the changes.

In the kernel, we usually use s/u32 instead of (u)int32_t for the
fixed-width types.

Accordingly, we already have S/U32_MAX for their max values.
So, we should not add (U)INT32_MAX to <linux/limits.h> any more.

Instead, add them to the in-kernel libfdt_env.h to compile the
latest libfdt.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

My initial plan was to change this in a series of 3 patches
since it is clean, and reduces the code.

[1/3] https://lore.kernel.org/patchwork/patch/1147095/
[2/3] https://lore.kernel.org/patchwork/patch/1147096/
[3/3] https://lore.kernel.org/patchwork/patch/1147097/

1/3 is stuck in the license bikeshed.

For 2/3, I have not been able to get Ack from Russell.

So, I chose a straight-forward fixup.


Changes in v3:
 - Resend as a single patch

 arch/arm/boot/compressed/libfdt_env.h | 4 +++-
 arch/powerpc/boot/libfdt_env.h        | 2 ++
 include/linux/libfdt_env.h            | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/libfdt_env.h b/arch/arm/boot/compressed/libfdt_env.h
index b36c0289a308..6a0f1f524466 100644
--- a/arch/arm/boot/compressed/libfdt_env.h
+++ b/arch/arm/boot/compressed/libfdt_env.h
@@ -2,11 +2,13 @@
 #ifndef _ARM_LIBFDT_ENV_H
 #define _ARM_LIBFDT_ENV_H
 
+#include <linux/limits.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <asm/byteorder.h>
 
-#define INT_MAX			((int)(~0U>>1))
+#define INT32_MAX	S32_MAX
+#define UINT32_MAX	U32_MAX
 
 typedef __be16 fdt16_t;
 typedef __be32 fdt32_t;
diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h
index 2abc8e83b95e..9757d4f6331e 100644
--- a/arch/powerpc/boot/libfdt_env.h
+++ b/arch/powerpc/boot/libfdt_env.h
@@ -6,6 +6,8 @@
 #include <string.h>
 
 #define INT_MAX			((int)(~0U>>1))
+#define UINT32_MAX		((u32)~0U)
+#define INT32_MAX		((s32)(UINT32_MAX >> 1))
 
 #include "of.h"
 
diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h
index edb0f0c30904..1adf54aad2df 100644
--- a/include/linux/libfdt_env.h
+++ b/include/linux/libfdt_env.h
@@ -7,6 +7,9 @@
 
 #include <asm/byteorder.h>
 
+#define INT32_MAX	S32_MAX
+#define UINT32_MAX	U32_MAX
+
 typedef __be16 fdt16_t;
 typedef __be32 fdt32_t;
 typedef __be64 fdt64_t;
-- 
2.17.1


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

* Re: [PATCH v3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h
  2019-11-13  7:12 [PATCH v3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h Masahiro Yamada
@ 2019-11-25  1:35 ` Masahiro Yamada
  2019-11-26 20:34 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2019-11-25  1:35 UTC (permalink / raw)
  To: DTML, Rob Herring, Frank Rowand
  Cc: Russell King, Linux Kernel Mailing List, Paul Mackerras,
	linuxppc-dev, linux-arm-kernel

On Wed, Nov 13, 2019 at 4:13 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> The DTC v1.5.1 added references to (U)INT32_MAX.
>
> This is no problem for user-space programs since <stdint.h> defines
> (U)INT32_MAX along with (u)int32_t.
>
> For the kernel space, libfdt_env.h needs to be adjusted before we
> pull in the changes.
>
> In the kernel, we usually use s/u32 instead of (u)int32_t for the
> fixed-width types.
>
> Accordingly, we already have S/U32_MAX for their max values.
> So, we should not add (U)INT32_MAX to <linux/limits.h> any more.
>
> Instead, add them to the in-kernel libfdt_env.h to compile the
> latest libfdt.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---

Please let me ping this
in case this is useful for future resync.




>
> My initial plan was to change this in a series of 3 patches
> since it is clean, and reduces the code.
>
> [1/3] https://lore.kernel.org/patchwork/patch/1147095/
> [2/3] https://lore.kernel.org/patchwork/patch/1147096/
> [3/3] https://lore.kernel.org/patchwork/patch/1147097/
>
> 1/3 is stuck in the license bikeshed.
>
> For 2/3, I have not been able to get Ack from Russell.
>
> So, I chose a straight-forward fixup.
>
>
> Changes in v3:
>  - Resend as a single patch
>
>  arch/arm/boot/compressed/libfdt_env.h | 4 +++-
>  arch/powerpc/boot/libfdt_env.h        | 2 ++
>  include/linux/libfdt_env.h            | 3 +++
>  3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/compressed/libfdt_env.h b/arch/arm/boot/compressed/libfdt_env.h
> index b36c0289a308..6a0f1f524466 100644
> --- a/arch/arm/boot/compressed/libfdt_env.h
> +++ b/arch/arm/boot/compressed/libfdt_env.h
> @@ -2,11 +2,13 @@
>  #ifndef _ARM_LIBFDT_ENV_H
>  #define _ARM_LIBFDT_ENV_H
>
> +#include <linux/limits.h>
>  #include <linux/types.h>
>  #include <linux/string.h>
>  #include <asm/byteorder.h>
>
> -#define INT_MAX                        ((int)(~0U>>1))
> +#define INT32_MAX      S32_MAX
> +#define UINT32_MAX     U32_MAX
>
>  typedef __be16 fdt16_t;
>  typedef __be32 fdt32_t;
> diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h
> index 2abc8e83b95e..9757d4f6331e 100644
> --- a/arch/powerpc/boot/libfdt_env.h
> +++ b/arch/powerpc/boot/libfdt_env.h
> @@ -6,6 +6,8 @@
>  #include <string.h>
>
>  #define INT_MAX                        ((int)(~0U>>1))
> +#define UINT32_MAX             ((u32)~0U)
> +#define INT32_MAX              ((s32)(UINT32_MAX >> 1))
>
>  #include "of.h"
>
> diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h
> index edb0f0c30904..1adf54aad2df 100644
> --- a/include/linux/libfdt_env.h
> +++ b/include/linux/libfdt_env.h
> @@ -7,6 +7,9 @@
>
>  #include <asm/byteorder.h>
>
> +#define INT32_MAX      S32_MAX
> +#define UINT32_MAX     U32_MAX
> +
>  typedef __be16 fdt16_t;
>  typedef __be32 fdt32_t;
>  typedef __be64 fdt64_t;
> --
> 2.17.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH v3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h
  2019-11-13  7:12 [PATCH v3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h Masahiro Yamada
  2019-11-25  1:35 ` Masahiro Yamada
@ 2019-11-26 20:34 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2019-11-26 20:34 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: devicetree, linuxppc-dev, Russell King, linux-kernel,
	Paul Mackerras, Frank Rowand, linux-arm-kernel

On Wed, Nov 13, 2019 at 04:12:02PM +0900, Masahiro Yamada wrote:
> The DTC v1.5.1 added references to (U)INT32_MAX.
> 
> This is no problem for user-space programs since <stdint.h> defines
> (U)INT32_MAX along with (u)int32_t.
> 
> For the kernel space, libfdt_env.h needs to be adjusted before we
> pull in the changes.
> 
> In the kernel, we usually use s/u32 instead of (u)int32_t for the
> fixed-width types.
> 
> Accordingly, we already have S/U32_MAX for their max values.
> So, we should not add (U)INT32_MAX to <linux/limits.h> any more.
> 
> Instead, add them to the in-kernel libfdt_env.h to compile the
> latest libfdt.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
> My initial plan was to change this in a series of 3 patches
> since it is clean, and reduces the code.
> 
> [1/3] https://lore.kernel.org/patchwork/patch/1147095/
> [2/3] https://lore.kernel.org/patchwork/patch/1147096/
> [3/3] https://lore.kernel.org/patchwork/patch/1147097/
> 
> 1/3 is stuck in the license bikeshed.
> 
> For 2/3, I have not been able to get Ack from Russell.
> 
> So, I chose a straight-forward fixup.
> 
> 
> Changes in v3:
>  - Resend as a single patch
> 
>  arch/arm/boot/compressed/libfdt_env.h | 4 +++-
>  arch/powerpc/boot/libfdt_env.h        | 2 ++
>  include/linux/libfdt_env.h            | 3 +++
>  3 files changed, 8 insertions(+), 1 deletion(-)

Applied.

Rob

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

end of thread, other threads:[~2019-11-26 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13  7:12 [PATCH v3] libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h Masahiro Yamada
2019-11-25  1:35 ` Masahiro Yamada
2019-11-26 20:34 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).