[PATCH] include: <io.h>: define (read|write)[bwlq]_relaxed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For Linux, It's always correct to substitute any of the read or
write _relaxed functions with their non relaxed counterpart.
Define functions that do this.

Unlike with Linux, they doesn't per se affect performance: barebox
writel doesn't imply memory barriers, instead it depends on
the architecture support to map IO memory regions as non-bufferable.

Signed-off-by: Ahmad Fatoum <ahmad@xxxxxx>
---
 drivers/clk/rockchip/clk.h        |  3 ---
 drivers/gpio/gpio-davinci.c       |  3 ---
 drivers/regulator/stm32-vrefbuf.c |  4 +---
 drivers/spi/atmel-quadspi.c       |  3 ---
 include/io.h                      | 32 +++++++++++++++++++++++++++++++
 5 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index 5b5bc8c23137..a3db88dfc890 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -21,9 +21,6 @@
 #include <linux/clk.h>
 #include <restart.h>
 
-#define writel_relaxed	writel
-#define readl_relaxed	readl
-
 #define HIWORD_UPDATE(val, mask, shift) \
 		((val) << (shift) | (mask) << ((shift) + 16))
 
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 20311d968b82..b4f217660691 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -13,9 +13,6 @@
 #include <io.h>
 #include <linux/err.h>
 
-#define readl_relaxed	readl
-#define writel_relaxed	writel
-
 struct davinci_gpio_regs {
 	u32	dir;
 	u32	out_data;
diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c
index 3956b1f64f6e..77287c2b0e82 100644
--- a/drivers/regulator/stm32-vrefbuf.c
+++ b/drivers/regulator/stm32-vrefbuf.c
@@ -10,6 +10,7 @@
 #include <linux/clk.h>
 #include <linux/iopoll.h>
 #include <of.h>
+#include <io.h>
 #include <regulator.h>
 
 /* STM32 VREFBUF registers */
@@ -23,9 +24,6 @@
 
 #define STM32_VREFBUF_AUTO_SUSPEND_DELAY_MS	10
 
-#define readl_relaxed readl
-#define writel_relaxed writel
-
 struct stm32_vrefbuf {
 	void __iomem *base;
 	struct clk *clk;
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 6799f95ea33e..af2191726fe9 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -34,9 +34,6 @@
 #include <of_device.h>
 #include <linux/iopoll.h>
 
-#define writel_relaxed   writel
-#define readl_relaxed   readl
-
 /* QSPI register offsets */
 #define QSPI_CR      0x0000  /* Control Register */
 #define QSPI_MR      0x0004  /* Mode Register */
diff --git a/include/io.h b/include/io.h
index 79d8b56c4e3f..6a74246ea777 100644
--- a/include/io.h
+++ b/include/io.h
@@ -6,4 +6,36 @@
 
 #define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
 
+#ifndef readq_relaxed
+#define readq_relaxed(addr) readq(addr)
+#endif
+
+#ifndef readl_relaxed
+#define readl_relaxed(addr) readl(addr)
+#endif
+
+#ifndef readw_relaxed
+#define readw_relaxed(addr) readw(addr)
+#endif
+
+#ifndef readb_relaxed
+#define readb_relaxed(addr) readb(addr)
+#endif
+
+#ifndef writeq_relaxed
+#define writeq_relaxed(val, addr) writeq((val), (addr))
+#endif
+
+#ifndef writel_relaxed
+#define writel_relaxed(val, addr) writel((val), (addr))
+#endif
+
+#ifndef writew_relaxed
+#define writew_relaxed(val, addr) writew((val), (addr))
+#endif
+
+#ifndef writeb_relaxed
+#define writeb_relaxed(val, addr) writeb((val), (addr))
+#endif
+
 #endif /* __IO_H */
-- 
2.32.0.rc0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux