Hi Arnd,
On Sat, 2025-03-15 at 11:59 +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann
>
> 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
> ---
> arch/sh/include/asm/io.h | 30 ++--
> arch/sh/kernel/Makefile | 3 -
> arch/sh/kernel/iomap.c | 162 ---
> arch/sh/kernel/ioport.c | 5 --
> arch/sh/lib/io.c | 4 +-
> drivers/sh/clk/cpg.c | 25 +++---
> 6 files changed, 21 insertions(+), 208 deletions(-)
> delete mode 100644 arch/sh/kernel/iomap.c
>
> diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
> index cf5eab840d57..0f663ebec700 100644
> --- a/arch/sh/include/asm/io.h
> +++ b/arch/sh/include/asm/io.h
> @@ -19,7 +19,6 @@
> #include
> #include
> #include
> -#include
>
> #define __IO_PREFIX generic
> #include
> @@ -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.
> */
> diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
> index ba917008d63e..7b453592adaf 100644
> --- a/arch/sh/kernel/Makefile
> +++ b/arch/sh/kernel/Makefile
> @@ -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
> index 0a0dff4e66de..
> --- a/arch/sh/kernel/iomap.c
> +++ /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
> -#include
> -
> -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 *ad