All of lore.kernel.org
 help / color / mirror / Atom feed
From: mtkaczyk@kernel.org
To: linux-raid@vger.kernel.org
Cc: Mariusz Tkaczyk <mtkaczyk@kernel.org>, Xiao Ni <xni@redhat.com>,
	Nigel Croxon <ncroxon@redhat.com>, Song Liu <song@kernel.org>,
	Yu Kuai <yukuai@kernel.org>
Subject: [PATCH v0 2/3] mdadm: include asm/byteorder.h
Date: Wed, 19 Mar 2025 18:10:57 +0100	[thread overview]
Message-ID: <20250319171058.20052-3-mtkaczyk@kernel.org> (raw)
In-Reply-To: <20250319171058.20052-1-mtkaczyk@kernel.org>

From: Mariusz Tkaczyk <mtkaczyk@kernel.org>

It will be included by raid/md_p.h anyway. Include it directly and
remove custom functions. It is not a problem now.

Signed-off-by: Mariusz Tkaczyk <mtkaczyk@kernel.org>
---
 mdadm.h | 55 +------------------------------------------------------
 1 file changed, 1 insertion(+), 54 deletions(-)

diff --git a/mdadm.h b/mdadm.h
index 0b86e4849d33..d2c2a4dac11b 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -34,6 +34,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #endif
 
 #include	<assert.h>
+#include	<asm/byteorder.h>
 #include	<sys/types.h>
 #include	<sys/stat.h>
 #include	<stdarg.h>
@@ -85,7 +86,6 @@ struct dlm_lksb {
 #endif
 
 #include	<linux/kdev_t.h>
-/*#include	<linux/fs.h> */
 #include	<sys/mount.h>
 #include	<asm/types.h>
 #include	<sys/ioctl.h>
@@ -169,59 +169,6 @@ struct dlm_lksb {
 #include	"msg.h"
 #include	"mdadm_status.h"
 
-#include <endian.h>
-/* Redhat don't like to #include <asm/byteorder.h>, and
- * some time include <linux/byteorder/xxx_endian.h> isn't enough,
- * and there is no standard conversion function so... */
-/* And dietlibc doesn't think byteswap is ok, so.. */
-/*  #include <byteswap.h> */
-#define __mdadm_bswap_16(x) (((x) & 0x00ffU) << 8 | \
-			     ((x) & 0xff00U) >> 8)
-#define __mdadm_bswap_32(x) (((x) & 0x000000ffU) << 24 | \
-			     ((x) & 0xff000000U) >> 24 | \
-			     ((x) & 0x0000ff00U) << 8  | \
-			     ((x) & 0x00ff0000U) >> 8)
-#define __mdadm_bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
-			     ((x) & 0xff00000000000000ULL) >> 56 | \
-			     ((x) & 0x000000000000ff00ULL) << 40 | \
-			     ((x) & 0x00ff000000000000ULL) >> 40 | \
-			     ((x) & 0x0000000000ff0000ULL) << 24 | \
-			     ((x) & 0x0000ff0000000000ULL) >> 24 | \
-			     ((x) & 0x00000000ff000000ULL) << 8 |  \
-			     ((x) & 0x000000ff00000000ULL) >> 8)
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define	__cpu_to_le16(_x) (unsigned int)(_x)
-#define __cpu_to_le32(_x) (unsigned int)(_x)
-#define __cpu_to_le64(_x) (unsigned long long)(_x)
-#define	__le16_to_cpu(_x) (unsigned int)(_x)
-#define __le32_to_cpu(_x) (unsigned int)(_x)
-#define __le64_to_cpu(_x) (unsigned long long)(_x)
-
-#define	__cpu_to_be16(_x) __mdadm_bswap_16(_x)
-#define __cpu_to_be32(_x) __mdadm_bswap_32(_x)
-#define __cpu_to_be64(_x) __mdadm_bswap_64(_x)
-#define	__be16_to_cpu(_x) __mdadm_bswap_16(_x)
-#define __be32_to_cpu(_x) __mdadm_bswap_32(_x)
-#define __be64_to_cpu(_x) __mdadm_bswap_64(_x)
-#elif BYTE_ORDER == BIG_ENDIAN
-#define	__cpu_to_le16(_x) __mdadm_bswap_16(_x)
-#define __cpu_to_le32(_x) __mdadm_bswap_32(_x)
-#define __cpu_to_le64(_x) __mdadm_bswap_64(_x)
-#define	__le16_to_cpu(_x) __mdadm_bswap_16(_x)
-#define __le32_to_cpu(_x) __mdadm_bswap_32(_x)
-#define __le64_to_cpu(_x) __mdadm_bswap_64(_x)
-
-#define	__cpu_to_be16(_x) (unsigned int)(_x)
-#define __cpu_to_be32(_x) (unsigned int)(_x)
-#define __cpu_to_be64(_x) (unsigned long long)(_x)
-#define	__be16_to_cpu(_x) (unsigned int)(_x)
-#define __be32_to_cpu(_x) (unsigned int)(_x)
-#define __be64_to_cpu(_x) (unsigned long long)(_x)
-#else
-#  error "unknown endianness."
-#endif
-
 /*
  * Partially stolen from include/linux/unaligned/packed_struct.h
  */
-- 
2.43.0


  parent reply	other threads:[~2025-03-19 17:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19 17:10 [PATCH v0 0/3] mdadm: Use kernel raid headers mtkaczyk
2025-03-19 17:10 ` [PATCH v0 1/3] mdadm: Remove klibc and uclibc support mtkaczyk
2025-03-19 17:10 ` mtkaczyk [this message]
2025-03-19 17:10 ` [PATCH v0 3/3] mdadm: use kernel raid headers mtkaczyk
2025-03-20  5:45 ` [PATCH v0 0/3] mdadm: Use " Xiao Ni

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=20250319171058.20052-3-mtkaczyk@kernel.org \
    --to=mtkaczyk@kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=ncroxon@redhat.com \
    --cc=song@kernel.org \
    --cc=xni@redhat.com \
    --cc=yukuai@kernel.org \
    /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.