Skip to contentSkip to conversation

io: declare __cpu_is_be in generic code

PATCH Superseded Pierre Morel 2 participants 3 messages Nov 18, 2021 KVM

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---
 lib/asm-generic/io.h | 8 ++++++++
 lib/ppc64/asm/io.h   | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)
lib/asm-generic/io.h +8 -0
index 88972f3b..9fa76ddb 100644
@@ -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)
 {
lib/ppc64/asm/io.h +0 -8
index 2b4dd2be..08d7297c 100644
@@ -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>
Signature · 1 line
2.25.1
#1 lore raw
Quoted 16 lines · Pierre Morel

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.

---
  lib/asm-generic/io.h | 8 ++++++++
  lib/ppc64/asm/io.h   | 8 --------
  2 files changed, 8 insertions(+), 8 deletions(-)
lib/asm-generic/io.h +0 -0
index 88972f3b..9fa76ddb 100644

lib/asm-generic/io.h line 22

Quoted 10 lines
lib/asm-generic/io.h +7 -0
@@ -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

Please remove these three later lines in that file now:

#ifndef __cpu_is_be
#define __cpu_is_be() (0)
#endif

Thomas

Quoted 23 lines
lib/asm-generic/io.h +0 -0
  #ifndef __raw_readb
  static inline u8 __raw_readb(const volatile void *addr)
  {
lib/ppc64/asm/io.h +0 -8
index 2b4dd2be..08d7297c 100644
@@ -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>
#2 lore raw
Quoted 29 lines · Thomas Huth
Quoted 16 lines · Pierre Morel

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.

---
  lib/asm-generic/io.h | 8 ++++++++
  lib/ppc64/asm/io.h   | 8 --------

  2 files changed, 8 insertions(+), 8 deletions(-)
lib/asm-generic/io.h +0 -0
index 88972f3b..9fa76ddb 100644

lib/asm-generic/io.h line 21

Quoted 9 lines
lib/asm-generic/io.h +7 -0
@@ -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

Please remove these three later lines in that file now:

Quoted 6 lines

#ifndef __cpu_is_be
#define __cpu_is_be() (0)
#endif

 Thomas

grrr, stupid me

Quoted 23 lines
Quoted 22 lines
lib/asm-generic/io.h +0 -0
   #ifndef __raw_readb
   static inline u8 __raw_readb(const volatile void *addr)
   {
lib/ppc64/asm/io.h +0 -8
index 2b4dd2be..08d7297c 100644
@@ -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>
 
Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen