All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre Morel <pmorel@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com,
	cohuck@redhat.com, imbrenda@linux.ibm.com
Subject: [kvm-unit-tests PATCH v3] io: declare __cpu_is_be in generic code
Date: Thu, 18 Nov 2021 15:54:06 +0100	[thread overview]
Message-ID: <20211118145406.340503-1-pmorel@linux.ibm.com> (raw)

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.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Suggested-by: Thomas Huth <thuth@redhat.com>
---
 lib/asm-generic/io.h | 12 ++++++++----
 lib/ppc64/asm/io.h   |  8 --------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
index 88972f3b..dc0f46f5 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 @@ static inline u64 __bswap64(u64 x)
 }
 #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 2b4dd2be..08d7297c 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>
-- 
2.25.1


                 reply	other threads:[~2021-11-18 14:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211118145406.340503-1-pmorel@linux.ibm.com \
    --to=pmorel@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.