aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2022-09-21 19:55:47 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2022-10-17 20:37:04 +0000
commit97f6fe7f49c7c41ecd6c9e413b51d55436b93844 (patch)
tree92dd63ae67ccc42cb136aebf483a7c82db700df9
parent990d3105c4d63c2c2382244c744e6ccd41e3c685 (diff)
downloadsrc-97f6fe7f49c7c41ecd6c9e413b51d55436b93844.tar.gz
src-97f6fe7f49c7c41ecd6c9e413b51d55436b93844.zip
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)
-rw-r--r--sys/compat/linuxkpi/common/include/linux/io.h34
1 files 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,