@@ -267,6 +267,104 @@ extern void __raw_writew(u16 b, volatile void __iomem *addr);
extern void __raw_writel(u32 b, volatile void __iomem *addr);
extern void __raw_writeq(u64 b, volatile void __iomem *addr);
+static inline void readsb(const volatile void __iomem *addr, void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ u8 *buf = buffer;
+
+ do {
+ u8 x = __raw_readb(addr);
+ *buf++ = x;
+ } while (--count);
+ }
+}
+
+static inline void readsw(const volatile void __iomem *addr, void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ u16 *buf = buffer;
+
+ do {
+ u16 x = __raw_readw(addr);
+ *buf++ = x;
+ } while (--count);
+ }
+}
+
+static inline void readsl(const volatile void __iomem *addr, void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ u32 *buf = buffer;
+
+ do {
+ u32 x = __raw_readl(addr);
+ *buf++ = x;
+ } while (--count);
+ }
+}
+
+static inline void readsq(const volatile void __iomem *addr, void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ u64 *buf = buffer;
+
+ do {
+ u64 x = __raw_readq(addr);
+ *buf++ = x;
+ } while (--count);
+ }
+}
+static inline void writesb(volatile void __iomem *addr, const void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ const u8 *buf = buffer;
+
+ do {
+ __raw_writeb(*buf++, addr);
+ } while (--count);
+ }
+}
+
+static inline void writesw(volatile void __iomem *addr, const void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ const u16 *buf = buffer;
+
+ do {
+ __raw_writew(*buf++, addr);
+ } while (--count);
+ }
+}
+static inline void writesl(volatile void __iomem *addr, const void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ const u32 *buf = buffer;
+
+ do {
+ __raw_writel(*buf++, addr);
+ } while (--count);
+ }
+}
+
+static inline void writesq(volatile void __iomem *addr, const void *buffer,
+ unsigned int count)
+{
+ if (count) {
+ const u64 *buf = buffer;
+
+ do {
+ __raw_writeq(*buf++, addr);
+ } while (--count);
+ }
+}
+
/*
* Mapping from port numbers to __iomem space is pretty easy.
*/
Some drivers need these for compile-testing. On most architectures they come from asm-generic/io.h, but not on sparc64, which has its own definitions. Copy the generic implementation here. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> --- Note that I tried to instead include asm-generic/io.h + a bunch a #define xxx xxx to prevent asm-generic/io.h from redefining things already implemented by the driver, but I faced prototypes mismatch between asm-generic/io.h and asm-generic/iomap.h ('void __iomem *' vs 'const volatile void __iomem *') which I didn't expect because asm-generic/io.h includes asm-generic/iomap.h when CONFIG_GENERIC_IOMAP is defined. Making prototypes consistent that should be doable, but it involves checking that the prototype modification is not breaking other users. Since that's not the problem I was initially trying to fix (my goal is to make 2 NAND drivers using readsl to compile correctly on all archs when enabled through COMPILE_TEST=y), I just ended copying the reads{b,w,l,q}/writes{b,w,l,q} definitions in arch/alpha/include/asm/io.h. Let me know if that's a problem. --- arch/alpha/include/asm/io.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)