io: declare __cpu_is_be in generic code

To use the swap byte transformations in big endian architectures,
we need to declare __cpu_is_be in the generic code.
Let's move it from the ppc code to the generic code.

Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Message-Id: <20211118145406.340503-1-pmorel@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
index 88972f3..dc0f46f 100644
--- a/lib/asm-generic/io.h
+++ b/lib/asm-generic/io.h
@@ -13,6 +13,14 @@
 #include "asm/page.h"
 #include "asm/barrier.h"
 
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define __cpu_is_be() (0)
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define __cpu_is_be() (1)
+#else
+#error Undefined byte order
+#endif
+
 #ifndef __raw_readb
 static inline u8 __raw_readb(const volatile void *addr)
 {
@@ -100,10 +108,6 @@
 }
 #endif
 
-#ifndef __cpu_is_be
-#define __cpu_is_be() (0)
-#endif
-
 #define le16_to_cpu(x) \
 	({ u16 __r = __cpu_is_be() ? __bswap16(x) : ((u16)x); __r; })
 #define cpu_to_le16 le16_to_cpu
diff --git a/lib/ppc64/asm/io.h b/lib/ppc64/asm/io.h
index 2b4dd2b..08d7297 100644
--- a/lib/ppc64/asm/io.h
+++ b/lib/ppc64/asm/io.h
@@ -1,14 +1,6 @@
 #ifndef _ASMPPC64_IO_H_
 #define _ASMPPC64_IO_H_
 
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-#define __cpu_is_be() (0)
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#define __cpu_is_be() (1)
-#else
-#error Undefined byte order
-#endif
-
 #define __iomem
 
 #include <asm-generic/io.h>