mirror of
https://github.com/torvalds/linux.git
synced 2024-11-14 16:12:02 +00:00
8f28ca6bd8
Patch series "iomap: Constify ioreadX() iomem argument", v3. The ioread8/16/32() and others have inconsistent interface among the architectures: some taking address as const, some not. It seems there is nothing really stopping all of them to take pointer to const. This patch (of 4): The ioreadX() and ioreadX_rep() helpers have inconsistent interface. On some architectures void *__iomem address argument is a pointer to const, on some not. Implementations of ioreadX() do not modify the memory under the address so they can be converted to a "const" version for const-safety and consistency among architectures. [krzk@kernel.org: sh: clk: fix assignment from incompatible pointer type for ioreadX()] Link: http://lkml.kernel.org/r/20200723082017.24053-1-krzk@kernel.org [akpm@linux-foundation.org: fix drivers/mailbox/bcm-pdc-mailbox.c] Link: http://lkml.kernel.org/r/202007132209.Rxmv4QyS%25lkp@intel.com Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Cc: Helge Deller <deller@gmx.de> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Rich Felker <dalias@libc.org> Cc: Kalle Valo <kvalo@codeaurora.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Dave Jiang <dave.jiang@intel.com> Cc: Jon Mason <jdmason@kudzu.us> Cc: Allen Hubbe <allenbh@gmail.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Jason Wang <jasowang@redhat.com> Link: http://lkml.kernel.org/r/20200709072837.5869-1-krzk@kernel.org Link: http://lkml.kernel.org/r/20200709072837.5869-2-krzk@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
163 lines
3.2 KiB
C
163 lines
3.2 KiB
C
// 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);
|