git: ae1e336e0517 - main - LinuxKPI: add put_unaligned_le16() and get_unaligned_be64()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sat, 20 May 2023 11:11:09 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=ae1e336e05171b80123bf6db7457f19c174accc4

commit ae1e336e05171b80123bf6db7457f19c174accc4
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-05-20 00:52:27 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-05-20 11:10:31 +0000

    LinuxKPI: add put_unaligned_le16() and get_unaligned_be64()
    
    Add the two new functions needed by wireless drivers by the same
    implementation pattern we did for different sizes.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      10 days
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D40174
---
 sys/compat/linuxkpi/common/include/asm/unaligned.h | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/asm/unaligned.h b/sys/compat/linuxkpi/common/include/asm/unaligned.h
index 8a001ec38c3d..c13089b2c5f4 100644
--- a/sys/compat/linuxkpi/common/include/asm/unaligned.h
+++ b/sys/compat/linuxkpi/common/include/asm/unaligned.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020,2023 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -50,6 +50,15 @@ get_unaligned_le32(const void *p)
 	return (le32_to_cpup((const __le32 *)p));
 }
 
+static __inline void
+put_unaligned_le16(__le16 v, void *p)
+{
+	__le16 x;
+
+	x = cpu_to_le16(v);
+	memcpy(p, &x, sizeof(x));
+}
+
 static __inline void
 put_unaligned_le32(__le32 v, void *p)
 {
@@ -82,4 +91,11 @@ get_unaligned_be32(const void *p)
 	return (be32_to_cpup((const __be32 *)p));
 }
 
+static __inline uint64_t
+get_unaligned_be64(const void *p)
+{
+
+	return (be64_to_cpup((const __be64 *)p));
+}
+
 #endif	/* _LINUXKPI_ASM_UNALIGNED_H */