Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Oct 2022 20:41:34 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 97f6fe7f49c7 - stable/13 - LinuxKPI: io.h constify arguments and add more functions
Message-ID:  <202210172041.29HKfYJM096441@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by bz:

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

commit 97f6fe7f49c7c41ecd6c9e413b51d55436b93844
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-09-21 19:55:47 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-10-17 20:37:04 +0000

    LinuxKPI: io.h constify arguments and add more functions
    
    Constify "*from" arguments and add __ioread32_copy() and
    __ioread64_copy() based on the already existing implementations.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    hselasky
    Differential Revision: https://reviews.freebsd.org/D36657
    
    (cherry picked from commit 046b82842c61c2d5d1648b5024958827e0a85725)
---
 sys/compat/linuxkpi/common/include/linux/io.h | 34 +++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/io.h b/sys/compat/linuxkpi/common/include/linux/io.h
index 6ee4753a2df5..7041710fe0c2 100644
--- a/sys/compat/linuxkpi/common/include/linux/io.h
+++ b/sys/compat/linuxkpi/common/include/linux/io.h
@@ -429,9 +429,9 @@ void iounmap(void *addr);
 #define	memcpy_toio(a, b, c)	memcpy((a), (b), (c))
 
 static inline void
-__iowrite32_copy(void *to, void *from, size_t count)
+__iowrite32_copy(void *to, const void *from, size_t count)
 {
-	uint32_t *src;
+	const uint32_t *src;
 	uint32_t *dst;
 	int i;
 
@@ -440,10 +440,10 @@ __iowrite32_copy(void *to, void *from, size_t count)
 }
 
 static inline void
-__iowrite64_copy(void *to, void *from, size_t count)
+__iowrite64_copy(void *to, const void *from, size_t count)
 {
 #ifdef __LP64__
-	uint64_t *src;
+	const uint64_t *src;
 	uint64_t *dst;
 	int i;
 
@@ -454,6 +454,32 @@ __iowrite64_copy(void *to, void *from, size_t count)
 #endif
 }
 
+static inline void
+__ioread32_copy(void *to, const void *from, size_t count)
+{
+	const uint32_t *src;
+	uint32_t *dst;
+	int i;
+
+	for (i = 0, src = from, dst = to; i < count; i++, src++, dst++)
+		*dst = __raw_readl(src);
+}
+
+static inline void
+__ioread64_copy(void *to, const void *from, size_t count)
+{
+#ifdef __LP64__
+	const uint64_t *src;
+	uint64_t *dst;
+	int i;
+
+	for (i = 0, src = from, dst = to; i < count; i++, src++, dst++)
+		*dst = __raw_readq(src);
+#else
+	__ioread32_copy(to, from, count * 2);
+#endif
+}
+
 enum {
 	MEMREMAP_WB = 1 << 0,
 	MEMREMAP_WT = 1 << 1,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202210172041.29HKfYJM096441>