diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2025-03-10 21:42:23 +0100 |
|---|---|---|
| committer | Arnd Bergmann <arnd@arndb.de> | 2025-03-11 10:41:18 +0100 |
| commit | 2494fce26e434071a7ce994f3e4e89a310249f3b (patch) | |
| tree | afa5f205511de22692dffec71d381a620814f809 /drivers/sh | |
| parent | 5c35018a54d8a45ea910210a0fcc0ab1af8d770c (diff) | |
| download | lwn-2494fce26e434071a7ce994f3e4e89a310249f3b.tar.gz lwn-2494fce26e434071a7ce994f3e4e89a310249f3b.zip | |
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>
Diffstat (limited to 'drivers/sh')
| -rw-r--r-- | drivers/sh/clk/cpg.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c index fd72d9088bdc..64ed7d64458a 100644 --- a/drivers/sh/clk/cpg.c +++ b/drivers/sh/clk/cpg.c @@ -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) { |
