]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sh: remove duplicate ioread/iowrite helpers
authorArnd Bergmann <arnd@arndb.de>
Mon, 10 Mar 2025 20:42:23 +0000 (21:42 +0100)
committerArnd Bergmann <arnd@arndb.de>
Tue, 11 Mar 2025 09:41:18 +0000 (10:41 +0100)
The ioread/iowrite functions on sh only do memory mapped I/O like the
generic verion, and never map onto non-MMIO inb/outb variants, so they
just add complexity. In particular, the use of asm-generic/iomap.h
ties the declaration to the x86 implementation.

Remove the custom versions and use the architecture-independent fallback
code instead. Some of the calling conventions on sh are different here,
so fix that by adding 'volatile' keywords where required by the generic
implementation and change the cpg clock driver to no longer depend on
the interesting choice of return types for ioread8/ioread16/ioread32.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
arch/sh/include/asm/io.h
arch/sh/kernel/Makefile
arch/sh/kernel/iomap.c [deleted file]
arch/sh/kernel/ioport.c
arch/sh/lib/io.c
drivers/sh/clk/cpg.c

index cf5eab840d57965db6210bd4b0f8c3e9ef99d4d2..0f663ebec7000c38bf95d79475deb8fe21b90355 100644 (file)
@@ -19,7 +19,6 @@
 #include <asm/machvec.h>
 #include <asm/page.h>
 #include <linux/pgtable.h>
-#include <asm-generic/iomap.h>
 
 #define __IO_PREFIX     generic
 #include <asm/io_generic.h>
@@ -100,7 +99,7 @@ pfx##writes##bwlq(volatile void __iomem *mem, const void *addr,              \
        }                                                               \
 }                                                                      \
                                                                        \
-static inline void pfx##reads##bwlq(volatile void __iomem *mem,                \
+static inline void pfx##reads##bwlq(const volatile void __iomem *mem,  \
                                    void *addr, unsigned int count)     \
 {                                                                      \
        volatile type *__addr = addr;                                   \
@@ -114,37 +113,18 @@ static inline void pfx##reads##bwlq(volatile void __iomem *mem,           \
 __BUILD_MEMORY_STRING(__raw_, b, u8)
 __BUILD_MEMORY_STRING(__raw_, w, u16)
 
-void __raw_writesl(void __iomem *addr, const void *data, int longlen);
-void __raw_readsl(const void __iomem *addr, void *data, int longlen);
+void __raw_writesl(void volatile __iomem *addr, const void *data, int longlen);
+void __raw_readsl(const volatile void __iomem *addr, void *data, int longlen);
 
 __BUILD_MEMORY_STRING(__raw_, q, u64)
 
 #define ioport_map ioport_map
-#define ioport_unmap ioport_unmap
 #define pci_iounmap pci_iounmap
 
-#define ioread8 ioread8
-#define ioread16 ioread16
-#define ioread16be ioread16be
-#define ioread32 ioread32
-#define ioread32be ioread32be
-
-#define iowrite8 iowrite8
-#define iowrite16 iowrite16
-#define iowrite16be iowrite16be
-#define iowrite32 iowrite32
-#define iowrite32be iowrite32be
-
-#define ioread8_rep ioread8_rep
-#define ioread16_rep ioread16_rep
-#define ioread32_rep ioread32_rep
-
-#define iowrite8_rep iowrite8_rep
-#define iowrite16_rep iowrite16_rep
-#define iowrite32_rep iowrite32_rep
-
 #ifdef CONFIG_HAS_IOPORT_MAP
 
+extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
+
 /*
  * Slowdown I/O port space accesses for antique hardware.
  */
index ba917008d63ed9808badc2d24db886e10dd32d4d..7b453592adafb002b87c7e2eceb908ca7a70b1f1 100644 (file)
@@ -21,10 +21,7 @@ obj-y        := head_32.o debugtraps.o dumpstack.o                           \
           syscalls_32.o time.o topology.o traps.o                      \
           traps_32.o unwinder.o
 
-ifndef CONFIG_GENERIC_IOMAP
-obj-y                          += iomap.o
 obj-$(CONFIG_HAS_IOPORT_MAP)   += ioport.o
-endif
 
 obj-y                          += sys_sh32.o
 obj-y                          += cpu/
diff --git a/arch/sh/kernel/iomap.c b/arch/sh/kernel/iomap.c
deleted file mode 100644 (file)
index 0a0dff4..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * arch/sh/kernel/iomap.c
- *
- * Copyright (C) 2000  Niibe Yutaka
- * Copyright (C) 2005 - 2007 Paul Mundt
- */
-#include <linux/module.h>
-#include <linux/io.h>
-
-unsigned int ioread8(const void __iomem *addr)
-{
-       return readb(addr);
-}
-EXPORT_SYMBOL(ioread8);
-
-unsigned int ioread16(const void __iomem *addr)
-{
-       return readw(addr);
-}
-EXPORT_SYMBOL(ioread16);
-
-unsigned int ioread16be(const void __iomem *addr)
-{
-       return be16_to_cpu(__raw_readw(addr));
-}
-EXPORT_SYMBOL(ioread16be);
-
-unsigned int ioread32(const void __iomem *addr)
-{
-       return readl(addr);
-}
-EXPORT_SYMBOL(ioread32);
-
-unsigned int ioread32be(const void __iomem *addr)
-{
-       return be32_to_cpu(__raw_readl(addr));
-}
-EXPORT_SYMBOL(ioread32be);
-
-void iowrite8(u8 val, void __iomem *addr)
-{
-       writeb(val, addr);
-}
-EXPORT_SYMBOL(iowrite8);
-
-void iowrite16(u16 val, void __iomem *addr)
-{
-       writew(val, addr);
-}
-EXPORT_SYMBOL(iowrite16);
-
-void iowrite16be(u16 val, void __iomem *addr)
-{
-       __raw_writew(cpu_to_be16(val), addr);
-}
-EXPORT_SYMBOL(iowrite16be);
-
-void iowrite32(u32 val, void __iomem *addr)
-{
-       writel(val, addr);
-}
-EXPORT_SYMBOL(iowrite32);
-
-void iowrite32be(u32 val, void __iomem *addr)
-{
-       __raw_writel(cpu_to_be32(val), addr);
-}
-EXPORT_SYMBOL(iowrite32be);
-
-/*
- * These are the "repeat MMIO read/write" functions.
- * Note the "__raw" accesses, since we don't want to
- * convert to CPU byte order. We write in "IO byte
- * order" (we also don't have IO barriers).
- */
-static inline void mmio_insb(const void __iomem *addr, u8 *dst, int count)
-{
-       while (--count >= 0) {
-               u8 data = __raw_readb(addr);
-               *dst = data;
-               dst++;
-       }
-}
-
-static inline void mmio_insw(const void __iomem *addr, u16 *dst, int count)
-{
-       while (--count >= 0) {
-               u16 data = __raw_readw(addr);
-               *dst = data;
-               dst++;
-       }
-}
-
-static inline void mmio_insl(const void __iomem *addr, u32 *dst, int count)
-{
-       while (--count >= 0) {
-               u32 data = __raw_readl(addr);
-               *dst = data;
-               dst++;
-       }
-}
-
-static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count)
-{
-       while (--count >= 0) {
-               __raw_writeb(*src, addr);
-               src++;
-       }
-}
-
-static inline void mmio_outsw(void __iomem *addr, const u16 *src, int count)
-{
-       while (--count >= 0) {
-               __raw_writew(*src, addr);
-               src++;
-       }
-}
-
-static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count)
-{
-       while (--count >= 0) {
-               __raw_writel(*src, addr);
-               src++;
-       }
-}
-
-void ioread8_rep(const void __iomem *addr, void *dst, unsigned long count)
-{
-       mmio_insb(addr, dst, count);
-}
-EXPORT_SYMBOL(ioread8_rep);
-
-void ioread16_rep(const void __iomem *addr, void *dst, unsigned long count)
-{
-       mmio_insw(addr, dst, count);
-}
-EXPORT_SYMBOL(ioread16_rep);
-
-void ioread32_rep(const void __iomem *addr, void *dst, unsigned long count)
-{
-       mmio_insl(addr, dst, count);
-}
-EXPORT_SYMBOL(ioread32_rep);
-
-void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
-{
-       mmio_outsb(addr, src, count);
-}
-EXPORT_SYMBOL(iowrite8_rep);
-
-void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
-{
-       mmio_outsw(addr, src, count);
-}
-EXPORT_SYMBOL(iowrite16_rep);
-
-void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
-{
-       mmio_outsl(addr, src, count);
-}
-EXPORT_SYMBOL(iowrite32_rep);
index c8aff8a20164d3c9837b9e9ba41453d294e82f5f..915a3dfd9f02034bbac977dc8430427160a84f0d 100644 (file)
@@ -23,8 +23,3 @@ void __iomem *ioport_map(unsigned long port, unsigned int nr)
        return (void __iomem *)(port + sh_io_port_base);
 }
 EXPORT_SYMBOL(ioport_map);
-
-void ioport_unmap(void __iomem *addr)
-{
-}
-EXPORT_SYMBOL(ioport_unmap);
index ebcf7c0a7335adf158e5d1ed679adf12fb069787..dc6345e4c53b5c1665628b6f2eb47200ced77d3c 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/module.h>
 #include <linux/io.h>
 
-void __raw_readsl(const void __iomem *addr, void *datap, int len)
+void __raw_readsl(const volatile void __iomem *addr, void *datap, int len)
 {
        u32 *data;
 
@@ -60,7 +60,7 @@ void __raw_readsl(const void __iomem *addr, void *datap, int len)
 }
 EXPORT_SYMBOL(__raw_readsl);
 
-void __raw_writesl(void __iomem *addr, const void *data, int len)
+void __raw_writesl(volatile void __iomem *addr, const void *data, int len)
 {
        if (likely(len != 0)) {
                int tmp1;
index fd72d9088bdcbc1309eb1b1a6e85a500ba8fe814..64ed7d64458a25c603f1eb95ee9a82c2851b7740 100644 (file)
@@ -26,6 +26,19 @@ static unsigned int sh_clk_read(struct clk *clk)
        return ioread32(clk->mapped_reg);
 }
 
+static unsigned int sh_clk_read_status(struct clk *clk)
+{
+       void __iomem *mapped_status = (phys_addr_t)clk->status_reg -
+               (phys_addr_t)clk->enable_reg + clk->mapped_reg;
+
+       if (clk->flags & CLK_ENABLE_REG_8BIT)
+               return ioread8(mapped_status);
+       else if (clk->flags & CLK_ENABLE_REG_16BIT)
+               return ioread16(mapped_status);
+
+       return ioread32(mapped_status);
+}
+
 static void sh_clk_write(int value, struct clk *clk)
 {
        if (clk->flags & CLK_ENABLE_REG_8BIT)
@@ -40,20 +53,10 @@ static int sh_clk_mstp_enable(struct clk *clk)
 {
        sh_clk_write(sh_clk_read(clk) & ~(1 << clk->enable_bit), clk);
        if (clk->status_reg) {
-               unsigned int (*read)(const void __iomem *addr);
                int i;
-               void __iomem *mapped_status = (phys_addr_t)clk->status_reg -
-                       (phys_addr_t)clk->enable_reg + clk->mapped_reg;
-
-               if (clk->flags & CLK_ENABLE_REG_8BIT)
-                       read = ioread8;
-               else if (clk->flags & CLK_ENABLE_REG_16BIT)
-                       read = ioread16;
-               else
-                       read = ioread32;
 
                for (i = 1000;
-                    (read(mapped_status) & (1 << clk->enable_bit)) && i;
+                    (sh_clk_read_status(clk) & (1 << clk->enable_bit)) && i;
                     i--)
                        cpu_relax();
                if (!i) {