Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: remove duplicate ioread/iowrite helpers

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>

+21 -208
+5 -25
arch/sh/include/asm/io.h
··· 19 19 #include <asm/machvec.h> 20 20 #include <asm/page.h> 21 21 #include <linux/pgtable.h> 22 - #include <asm-generic/iomap.h> 23 22 24 23 #define __IO_PREFIX generic 25 24 #include <asm/io_generic.h> ··· 99 100 } \ 100 101 } \ 101 102 \ 102 - static inline void pfx##reads##bwlq(volatile void __iomem *mem, \ 103 + static inline void pfx##reads##bwlq(const volatile void __iomem *mem, \ 103 104 void *addr, unsigned int count) \ 104 105 { \ 105 106 volatile type *__addr = addr; \ ··· 113 114 __BUILD_MEMORY_STRING(__raw_, b, u8) 114 115 __BUILD_MEMORY_STRING(__raw_, w, u16) 115 116 116 - void __raw_writesl(void __iomem *addr, const void *data, int longlen); 117 - void __raw_readsl(const void __iomem *addr, void *data, int longlen); 117 + void __raw_writesl(void volatile __iomem *addr, const void *data, int longlen); 118 + void __raw_readsl(const volatile void __iomem *addr, void *data, int longlen); 118 119 119 120 __BUILD_MEMORY_STRING(__raw_, q, u64) 120 121 121 122 #define ioport_map ioport_map 122 - #define ioport_unmap ioport_unmap 123 123 #define pci_iounmap pci_iounmap 124 124 125 - #define ioread8 ioread8 126 - #define ioread16 ioread16 127 - #define ioread16be ioread16be 128 - #define ioread32 ioread32 129 - #define ioread32be ioread32be 130 - 131 - #define iowrite8 iowrite8 132 - #define iowrite16 iowrite16 133 - #define iowrite16be iowrite16be 134 - #define iowrite32 iowrite32 135 - #define iowrite32be iowrite32be 136 - 137 - #define ioread8_rep ioread8_rep 138 - #define ioread16_rep ioread16_rep 139 - #define ioread32_rep ioread32_rep 140 - 141 - #define iowrite8_rep iowrite8_rep 142 - #define iowrite16_rep iowrite16_rep 143 - #define iowrite32_rep iowrite32_rep 144 - 145 125 #ifdef CONFIG_HAS_IOPORT_MAP 126 + 127 + extern void __iomem *ioport_map(unsigned long port, unsigned int nr); 146 128 147 129 /* 148 130 * Slowdown I/O port space accesses for antique hardware.
-3
arch/sh/kernel/Makefile
··· 21 21 syscalls_32.o time.o topology.o traps.o \ 22 22 traps_32.o unwinder.o 23 23 24 - ifndef CONFIG_GENERIC_IOMAP 25 - obj-y += iomap.o 26 24 obj-$(CONFIG_HAS_IOPORT_MAP) += ioport.o 27 - endif 28 25 29 26 obj-y += sys_sh32.o 30 27 obj-y += cpu/
-162
arch/sh/kernel/iomap.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * arch/sh/kernel/iomap.c 4 - * 5 - * Copyright (C) 2000 Niibe Yutaka 6 - * Copyright (C) 2005 - 2007 Paul Mundt 7 - */ 8 - #include <linux/module.h> 9 - #include <linux/io.h> 10 - 11 - unsigned int ioread8(const void __iomem *addr) 12 - { 13 - return readb(addr); 14 - } 15 - EXPORT_SYMBOL(ioread8); 16 - 17 - unsigned int ioread16(const void __iomem *addr) 18 - { 19 - return readw(addr); 20 - } 21 - EXPORT_SYMBOL(ioread16); 22 - 23 - unsigned int ioread16be(const void __iomem *addr) 24 - { 25 - return be16_to_cpu(__raw_readw(addr)); 26 - } 27 - EXPORT_SYMBOL(ioread16be); 28 - 29 - unsigned int ioread32(const void __iomem *addr) 30 - { 31 - return readl(addr); 32 - } 33 - EXPORT_SYMBOL(ioread32); 34 - 35 - unsigned int ioread32be(const void __iomem *addr) 36 - { 37 - return be32_to_cpu(__raw_readl(addr)); 38 - } 39 - EXPORT_SYMBOL(ioread32be); 40 - 41 - void iowrite8(u8 val, void __iomem *addr) 42 - { 43 - writeb(val, addr); 44 - } 45 - EXPORT_SYMBOL(iowrite8); 46 - 47 - void iowrite16(u16 val, void __iomem *addr) 48 - { 49 - writew(val, addr); 50 - } 51 - EXPORT_SYMBOL(iowrite16); 52 - 53 - void iowrite16be(u16 val, void __iomem *addr) 54 - { 55 - __raw_writew(cpu_to_be16(val), addr); 56 - } 57 - EXPORT_SYMBOL(iowrite16be); 58 - 59 - void iowrite32(u32 val, void __iomem *addr) 60 - { 61 - writel(val, addr); 62 - } 63 - EXPORT_SYMBOL(iowrite32); 64 - 65 - void iowrite32be(u32 val, void __iomem *addr) 66 - { 67 - __raw_writel(cpu_to_be32(val), addr); 68 - } 69 - EXPORT_SYMBOL(iowrite32be); 70 - 71 - /* 72 - * These are the "repeat MMIO read/write" functions. 73 - * Note the "__raw" accesses, since we don't want to 74 - * convert to CPU byte order. We write in "IO byte 75 - * order" (we also don't have IO barriers). 76 - */ 77 - static inline void mmio_insb(const void __iomem *addr, u8 *dst, int count) 78 - { 79 - while (--count >= 0) { 80 - u8 data = __raw_readb(addr); 81 - *dst = data; 82 - dst++; 83 - } 84 - } 85 - 86 - static inline void mmio_insw(const void __iomem *addr, u16 *dst, int count) 87 - { 88 - while (--count >= 0) { 89 - u16 data = __raw_readw(addr); 90 - *dst = data; 91 - dst++; 92 - } 93 - } 94 - 95 - static inline void mmio_insl(const void __iomem *addr, u32 *dst, int count) 96 - { 97 - while (--count >= 0) { 98 - u32 data = __raw_readl(addr); 99 - *dst = data; 100 - dst++; 101 - } 102 - } 103 - 104 - static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count) 105 - { 106 - while (--count >= 0) { 107 - __raw_writeb(*src, addr); 108 - src++; 109 - } 110 - } 111 - 112 - static inline void mmio_outsw(void __iomem *addr, const u16 *src, int count) 113 - { 114 - while (--count >= 0) { 115 - __raw_writew(*src, addr); 116 - src++; 117 - } 118 - } 119 - 120 - static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count) 121 - { 122 - while (--count >= 0) { 123 - __raw_writel(*src, addr); 124 - src++; 125 - } 126 - } 127 - 128 - void ioread8_rep(const void __iomem *addr, void *dst, unsigned long count) 129 - { 130 - mmio_insb(addr, dst, count); 131 - } 132 - EXPORT_SYMBOL(ioread8_rep); 133 - 134 - void ioread16_rep(const void __iomem *addr, void *dst, unsigned long count) 135 - { 136 - mmio_insw(addr, dst, count); 137 - } 138 - EXPORT_SYMBOL(ioread16_rep); 139 - 140 - void ioread32_rep(const void __iomem *addr, void *dst, unsigned long count) 141 - { 142 - mmio_insl(addr, dst, count); 143 - } 144 - EXPORT_SYMBOL(ioread32_rep); 145 - 146 - void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count) 147 - { 148 - mmio_outsb(addr, src, count); 149 - } 150 - EXPORT_SYMBOL(iowrite8_rep); 151 - 152 - void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count) 153 - { 154 - mmio_outsw(addr, src, count); 155 - } 156 - EXPORT_SYMBOL(iowrite16_rep); 157 - 158 - void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count) 159 - { 160 - mmio_outsl(addr, src, count); 161 - } 162 - EXPORT_SYMBOL(iowrite32_rep);
-5
arch/sh/kernel/ioport.c
··· 23 23 return (void __iomem *)(port + sh_io_port_base); 24 24 } 25 25 EXPORT_SYMBOL(ioport_map); 26 - 27 - void ioport_unmap(void __iomem *addr) 28 - { 29 - } 30 - EXPORT_SYMBOL(ioport_unmap);
+2 -2
arch/sh/lib/io.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/io.h> 13 13 14 - void __raw_readsl(const void __iomem *addr, void *datap, int len) 14 + void __raw_readsl(const volatile void __iomem *addr, void *datap, int len) 15 15 { 16 16 u32 *data; 17 17 ··· 60 60 } 61 61 EXPORT_SYMBOL(__raw_readsl); 62 62 63 - void __raw_writesl(void __iomem *addr, const void *data, int len) 63 + void __raw_writesl(volatile void __iomem *addr, const void *data, int len) 64 64 { 65 65 if (likely(len != 0)) { 66 66 int tmp1;
+14 -11
drivers/sh/clk/cpg.c
··· 26 26 return ioread32(clk->mapped_reg); 27 27 } 28 28 29 + static unsigned int sh_clk_read_status(struct clk *clk) 30 + { 31 + void __iomem *mapped_status = (phys_addr_t)clk->status_reg - 32 + (phys_addr_t)clk->enable_reg + clk->mapped_reg; 33 + 34 + if (clk->flags & CLK_ENABLE_REG_8BIT) 35 + return ioread8(mapped_status); 36 + else if (clk->flags & CLK_ENABLE_REG_16BIT) 37 + return ioread16(mapped_status); 38 + 39 + return ioread32(mapped_status); 40 + } 41 + 29 42 static void sh_clk_write(int value, struct clk *clk) 30 43 { 31 44 if (clk->flags & CLK_ENABLE_REG_8BIT) ··· 53 40 { 54 41 sh_clk_write(sh_clk_read(clk) & ~(1 << clk->enable_bit), clk); 55 42 if (clk->status_reg) { 56 - unsigned int (*read)(const void __iomem *addr); 57 43 int i; 58 - void __iomem *mapped_status = (phys_addr_t)clk->status_reg - 59 - (phys_addr_t)clk->enable_reg + clk->mapped_reg; 60 - 61 - if (clk->flags & CLK_ENABLE_REG_8BIT) 62 - read = ioread8; 63 - else if (clk->flags & CLK_ENABLE_REG_16BIT) 64 - read = ioread16; 65 - else 66 - read = ioread32; 67 44 68 45 for (i = 1000; 69 - (read(mapped_status) & (1 << clk->enable_bit)) && i; 46 + (sh_clk_read_status(clk) & (1 << clk->enable_bit)) && i; 70 47 i--) 71 48 cpu_relax(); 72 49 if (!i) {