forked from luck/tmp_suning_uos_patched
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>
123 lines
2.4 KiB
C
123 lines
2.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_IO_64_NONATOMIC_LO_HI_H_
|
|
#define _LINUX_IO_64_NONATOMIC_LO_HI_H_
|
|
|
|
#include <linux/io.h>
|
|
#include <asm-generic/int-ll64.h>
|
|
|
|
static inline __u64 lo_hi_readq(const volatile void __iomem *addr)
|
|
{
|
|
const volatile u32 __iomem *p = addr;
|
|
u32 low, high;
|
|
|
|
low = readl(p);
|
|
high = readl(p + 1);
|
|
|
|
return low + ((u64)high << 32);
|
|
}
|
|
|
|
static inline void lo_hi_writeq(__u64 val, volatile void __iomem *addr)
|
|
{
|
|
writel(val, addr);
|
|
writel(val >> 32, addr + 4);
|
|
}
|
|
|
|
static inline __u64 lo_hi_readq_relaxed(const volatile void __iomem *addr)
|
|
{
|
|
const volatile u32 __iomem *p = addr;
|
|
u32 low, high;
|
|
|
|
low = readl_relaxed(p);
|
|
high = readl_relaxed(p + 1);
|
|
|
|
return low + ((u64)high << 32);
|
|
}
|
|
|
|
static inline void lo_hi_writeq_relaxed(__u64 val, volatile void __iomem *addr)
|
|
{
|
|
writel_relaxed(val, addr);
|
|
writel_relaxed(val >> 32, addr + 4);
|
|
}
|
|
|
|
#ifndef readq
|
|
#define readq lo_hi_readq
|
|
#endif
|
|
|
|
#ifndef writeq
|
|
#define writeq lo_hi_writeq
|
|
#endif
|
|
|
|
#ifndef readq_relaxed
|
|
#define readq_relaxed lo_hi_readq_relaxed
|
|
#endif
|
|
|
|
#ifndef writeq_relaxed
|
|
#define writeq_relaxed lo_hi_writeq_relaxed
|
|
#endif
|
|
|
|
#ifndef ioread64_lo_hi
|
|
#define ioread64_lo_hi ioread64_lo_hi
|
|
static inline u64 ioread64_lo_hi(const void __iomem *addr)
|
|
{
|
|
u32 low, high;
|
|
|
|
low = ioread32(addr);
|
|
high = ioread32(addr + sizeof(u32));
|
|
|
|
return low + ((u64)high << 32);
|
|
}
|
|
#endif
|
|
|
|
#ifndef iowrite64_lo_hi
|
|
#define iowrite64_lo_hi iowrite64_lo_hi
|
|
static inline void iowrite64_lo_hi(u64 val, void __iomem *addr)
|
|
{
|
|
iowrite32(val, addr);
|
|
iowrite32(val >> 32, addr + sizeof(u32));
|
|
}
|
|
#endif
|
|
|
|
#ifndef ioread64be_lo_hi
|
|
#define ioread64be_lo_hi ioread64be_lo_hi
|
|
static inline u64 ioread64be_lo_hi(const void __iomem *addr)
|
|
{
|
|
u32 low, high;
|
|
|
|
low = ioread32be(addr + sizeof(u32));
|
|
high = ioread32be(addr);
|
|
|
|
return low + ((u64)high << 32);
|
|
}
|
|
#endif
|
|
|
|
#ifndef iowrite64be_lo_hi
|
|
#define iowrite64be_lo_hi iowrite64be_lo_hi
|
|
static inline void iowrite64be_lo_hi(u64 val, void __iomem *addr)
|
|
{
|
|
iowrite32be(val, addr + sizeof(u32));
|
|
iowrite32be(val >> 32, addr);
|
|
}
|
|
#endif
|
|
|
|
#ifndef ioread64
|
|
#define ioread64_is_nonatomic
|
|
#define ioread64 ioread64_lo_hi
|
|
#endif
|
|
|
|
#ifndef iowrite64
|
|
#define iowrite64_is_nonatomic
|
|
#define iowrite64 iowrite64_lo_hi
|
|
#endif
|
|
|
|
#ifndef ioread64be
|
|
#define ioread64be_is_nonatomic
|
|
#define ioread64be ioread64be_lo_hi
|
|
#endif
|
|
|
|
#ifndef iowrite64be
|
|
#define iowrite64be_is_nonatomic
|
|
#define iowrite64be iowrite64be_lo_hi
|
|
#endif
|
|
|
|
#endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */
|