summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2019-09-27 23:47:39 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2019-10-09 23:03:34 +0200
commitf0676dd5a38c03e6334db8f153e43575552118b7 (patch)
treefc636d0badd78d7ef58ca3283947eb094c927e6d
parent9264f6f7d7f0ac21346d111b5ce0df13f5358edf (diff)
backports: io.h: Add __ioread32_copy()
Add __ioread32_copy() from usptream Linux commit a9aec5881b9d ("lib/iomap_copy.c: add __ioread32_copy()") which is used by mt76 driver. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--backport/backport-include/linux/io.h5
-rw-r--r--backport/compat/backport-4.5.c22
2 files changed, 27 insertions, 0 deletions
diff --git a/backport/backport-include/linux/io.h b/backport/backport-include/linux/io.h
index 78ae4650..f91085be 100644
--- a/backport/backport-include/linux/io.h
+++ b/backport/backport-include/linux/io.h
@@ -6,4 +6,9 @@
#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
#endif
+#if LINUX_VERSION_IS_LESS(4,5,0)
+#define __ioread32_copy LINUX_BACKPORT(__ioread32_copy)
+void __ioread32_copy(void *to, const void __iomem *from, size_t count);
+#endif
+
#endif /* __BP_LINUX_IO_H */
diff --git a/backport/compat/backport-4.5.c b/backport/compat/backport-4.5.c
index 13764dc7..b4aae624 100644
--- a/backport/compat/backport-4.5.c
+++ b/backport/compat/backport-4.5.c
@@ -18,6 +18,7 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <asm/uaccess.h>
+#include <linux/io.h>
#if LINUX_VERSION_IS_GEQ(3,19,0)
int led_set_brightness_sync(struct led_classdev *led_cdev,
@@ -150,3 +151,24 @@ int devm_led_trigger_register(struct device *dev,
return rc;
}
EXPORT_SYMBOL_GPL(devm_led_trigger_register);
+
+/**
+ * __ioread32_copy - copy data from MMIO space, in 32-bit units
+ * @to: destination (must be 32-bit aligned)
+ * @from: source, in MMIO space (must be 32-bit aligned)
+ * @count: number of 32-bit quantities to copy
+ *
+ * Copy data from MMIO space to kernel space, in units of 32 bits at a
+ * time. Order of access is not guaranteed, nor is a memory barrier
+ * performed afterwards.
+ */
+void __ioread32_copy(void *to, const void __iomem *from, size_t count)
+{
+ u32 *dst = to;
+ const u32 __iomem *src = from;
+ const u32 __iomem *end = src + count;
+
+ while (src < end)
+ *dst++ = __raw_readl(src++);
+}
+EXPORT_SYMBOL_GPL(__ioread32_copy);