Skip to content

Commit 2494fce

Browse files
committed
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>
1 parent 5c35018 commit 2494fce

6 files changed

Lines changed: 21 additions & 208 deletions

File tree

arch/sh/include/asm/io.h

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <asm/machvec.h>
2020
#include <asm/page.h>
2121
#include <linux/pgtable.h>
22-
#include <asm-generic/iomap.h>
2322

2423
#define __IO_PREFIX generic
2524
#include <asm/io_generic.h>
@@ -100,7 +99,7 @@ pfx##writes##bwlq(volatile void __iomem *mem, const void *addr, \
10099
} \
101100
} \
102101
\
103-
static inline void pfx##reads##bwlq(volatile void __iomem *mem, \
102+
static inline void pfx##reads##bwlq(const volatile void __iomem *mem, \
104103
void *addr, unsigned int count) \
105104
{ \
106105
volatile type *__addr = addr; \
@@ -114,37 +113,18 @@ static inline void pfx##reads##bwlq(volatile void __iomem *mem, \
114113
__BUILD_MEMORY_STRING(__raw_, b, u8)
115114
__BUILD_MEMORY_STRING(__raw_, w, u16)
116115

117-
void __raw_writesl(void __iomem *addr, const void *data, int longlen);
118-
void __raw_readsl(const void __iomem *addr, void *data, int longlen);
116+
void __raw_writesl(void volatile __iomem *addr, const void *data, int longlen);
117+
void __raw_readsl(const volatile void __iomem *addr, void *data, int longlen);
119118

120119
__BUILD_MEMORY_STRING(__raw_, q, u64)
121120

122121
#define ioport_map ioport_map
123-
#define ioport_unmap ioport_unmap
124122
#define pci_iounmap pci_iounmap
125123

126-
#define ioread8 ioread8
127-
#define ioread16 ioread16
128-
#define ioread16be ioread16be
129-
#define ioread32 ioread32
130-
#define ioread32be ioread32be
131-
132-
#define iowrite8 iowrite8
133-
#define iowrite16 iowrite16
134-
#define iowrite16be iowrite16be
135-
#define iowrite32 iowrite32
136-
#define iowrite32be iowrite32be
137-
138-
#define ioread8_rep ioread8_rep
139-
#define ioread16_rep ioread16_rep
140-
#define ioread32_rep ioread32_rep
141-
142-
#define iowrite8_rep iowrite8_rep
143-
#define iowrite16_rep iowrite16_rep
144-
#define iowrite32_rep iowrite32_rep
145-
146124
#ifdef CONFIG_HAS_IOPORT_MAP
147125

126+
extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
127+
148128
/*
149129
* Slowdown I/O port space accesses for antique hardware.
150130
*/

arch/sh/kernel/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ obj-y := head_32.o debugtraps.o dumpstack.o \
2121
syscalls_32.o time.o topology.o traps.o \
2222
traps_32.o unwinder.o
2323

24-
ifndef CONFIG_GENERIC_IOMAP
25-
obj-y += iomap.o
2624
obj-$(CONFIG_HAS_IOPORT_MAP) += ioport.o
27-
endif
2825

2926
obj-y += sys_sh32.o
3027
obj-y += cpu/

arch/sh/kernel/iomap.c

Lines changed: 0 additions & 162 deletions
This file was deleted.

arch/sh/kernel/ioport.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,3 @@ void __iomem *ioport_map(unsigned long port, unsigned int nr)
2323
return (void __iomem *)(port + sh_io_port_base);
2424
}
2525
EXPORT_SYMBOL(ioport_map);
26-
27-
void ioport_unmap(void __iomem *addr)
28-
{
29-
}
30-
EXPORT_SYMBOL(ioport_unmap);

arch/sh/lib/io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/module.h>
1212
#include <linux/io.h>
1313

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)
1515
{
1616
u32 *data;
1717

@@ -60,7 +60,7 @@ void __raw_readsl(const void __iomem *addr, void *datap, int len)
6060
}
6161
EXPORT_SYMBOL(__raw_readsl);
6262

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)
6464
{
6565
if (likely(len != 0)) {
6666
int tmp1;

drivers/sh/clk/cpg.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ static unsigned int sh_clk_read(struct clk *clk)
2626
return ioread32(clk->mapped_reg);
2727
}
2828

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+
2942
static void sh_clk_write(int value, struct clk *clk)
3043
{
3144
if (clk->flags & CLK_ENABLE_REG_8BIT)
@@ -40,20 +53,10 @@ static int sh_clk_mstp_enable(struct clk *clk)
4053
{
4154
sh_clk_write(sh_clk_read(clk) & ~(1 << clk->enable_bit), clk);
4255
if (clk->status_reg) {
43-
unsigned int (*read)(const void __iomem *addr);
4456
int i;
45-
void __iomem *mapped_status = (phys_addr_t)clk->status_reg -
46-
(phys_addr_t)clk->enable_reg + clk->mapped_reg;
47-
48-
if (clk->flags & CLK_ENABLE_REG_8BIT)
49-
read = ioread8;
50-
else if (clk->flags & CLK_ENABLE_REG_16BIT)
51-
read = ioread16;
52-
else
53-
read = ioread32;
5457

5558
for (i = 1000;
56-
(read(mapped_status) & (1 << clk->enable_bit)) && i;
59+
(sh_clk_read_status(clk) & (1 << clk->enable_bit)) && i;
5760
i--)
5861
cpu_relax();
5962
if (!i) {

0 commit comments

Comments
 (0)