mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH] include: <io.h>: define (read|write)[bwlq]_relaxed
Date: Fri, 11 Jun 2021 10:01:55 +0200	[thread overview]
Message-ID: <20210611080155.3555976-1-ahmad@a3f.at> (raw)

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@a3f.at>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2021-06-11  8:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11  8:01 Ahmad Fatoum [this message]
2021-06-11 11:30 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210611080155.3555976-1-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox