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>
117 lines
4.0 KiB
C
117 lines
4.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __GENERIC_IO_H
|
|
#define __GENERIC_IO_H
|
|
|
|
#include <linux/linkage.h>
|
|
#include <asm/byteorder.h>
|
|
|
|
/*
|
|
* These are the "generic" interfaces for doing new-style
|
|
* memory-mapped or PIO accesses. Architectures may do
|
|
* their own arch-optimized versions, these just act as
|
|
* wrappers around the old-style IO register access functions:
|
|
* read[bwl]/write[bwl]/in[bwl]/out[bwl]
|
|
*
|
|
* Don't include this directly, include it from <asm/io.h>.
|
|
*/
|
|
|
|
/*
|
|
* Read/write from/to an (offsettable) iomem cookie. It might be a PIO
|
|
* access or a MMIO access, these functions don't care. The info is
|
|
* encoded in the hardware mapping set up by the mapping functions
|
|
* (or the cookie itself, depending on implementation and hw).
|
|
*
|
|
* The generic routines just encode the PIO/MMIO as part of the
|
|
* cookie, and coldly assume that the MMIO IO mappings are not
|
|
* in the low address range. Architectures for which this is not
|
|
* true can't use this generic implementation.
|
|
*/
|
|
extern unsigned int ioread8(const void __iomem *);
|
|
extern unsigned int ioread16(const void __iomem *);
|
|
extern unsigned int ioread16be(const void __iomem *);
|
|
extern unsigned int ioread32(const void __iomem *);
|
|
extern unsigned int ioread32be(const void __iomem *);
|
|
#ifdef CONFIG_64BIT
|
|
extern u64 ioread64(const void __iomem *);
|
|
extern u64 ioread64be(const void __iomem *);
|
|
#endif
|
|
|
|
#ifdef readq
|
|
#define ioread64_lo_hi ioread64_lo_hi
|
|
#define ioread64_hi_lo ioread64_hi_lo
|
|
#define ioread64be_lo_hi ioread64be_lo_hi
|
|
#define ioread64be_hi_lo ioread64be_hi_lo
|
|
extern u64 ioread64_lo_hi(const void __iomem *addr);
|
|
extern u64 ioread64_hi_lo(const void __iomem *addr);
|
|
extern u64 ioread64be_lo_hi(const void __iomem *addr);
|
|
extern u64 ioread64be_hi_lo(const void __iomem *addr);
|
|
#endif
|
|
|
|
extern void iowrite8(u8, void __iomem *);
|
|
extern void iowrite16(u16, void __iomem *);
|
|
extern void iowrite16be(u16, void __iomem *);
|
|
extern void iowrite32(u32, void __iomem *);
|
|
extern void iowrite32be(u32, void __iomem *);
|
|
#ifdef CONFIG_64BIT
|
|
extern void iowrite64(u64, void __iomem *);
|
|
extern void iowrite64be(u64, void __iomem *);
|
|
#endif
|
|
|
|
#ifdef writeq
|
|
#define iowrite64_lo_hi iowrite64_lo_hi
|
|
#define iowrite64_hi_lo iowrite64_hi_lo
|
|
#define iowrite64be_lo_hi iowrite64be_lo_hi
|
|
#define iowrite64be_hi_lo iowrite64be_hi_lo
|
|
extern void iowrite64_lo_hi(u64 val, void __iomem *addr);
|
|
extern void iowrite64_hi_lo(u64 val, void __iomem *addr);
|
|
extern void iowrite64be_lo_hi(u64 val, void __iomem *addr);
|
|
extern void iowrite64be_hi_lo(u64 val, void __iomem *addr);
|
|
#endif
|
|
|
|
/*
|
|
* "string" versions of the above. Note that they
|
|
* use native byte ordering for the accesses (on
|
|
* the assumption that IO and memory agree on a
|
|
* byte order, and CPU byteorder is irrelevant).
|
|
*
|
|
* They do _not_ update the port address. If you
|
|
* want MMIO that copies stuff laid out in MMIO
|
|
* memory across multiple ports, use "memcpy_toio()"
|
|
* and friends.
|
|
*/
|
|
extern void ioread8_rep(const void __iomem *port, void *buf, unsigned long count);
|
|
extern void ioread16_rep(const void __iomem *port, void *buf, unsigned long count);
|
|
extern void ioread32_rep(const void __iomem *port, void *buf, unsigned long count);
|
|
|
|
extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
|
|
extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
|
|
extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
|
|
|
|
#ifdef CONFIG_HAS_IOPORT_MAP
|
|
/* Create a virtual mapping cookie for an IO port range */
|
|
extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
|
|
extern void ioport_unmap(void __iomem *);
|
|
#endif
|
|
|
|
#ifndef ARCH_HAS_IOREMAP_WC
|
|
#define ioremap_wc ioremap
|
|
#endif
|
|
|
|
#ifndef ARCH_HAS_IOREMAP_WT
|
|
#define ioremap_wt ioremap
|
|
#endif
|
|
|
|
#ifdef CONFIG_PCI
|
|
/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */
|
|
struct pci_dev;
|
|
extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
|
|
#elif defined(CONFIG_GENERIC_IOMAP)
|
|
struct pci_dev;
|
|
static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
|
|
{ }
|
|
#endif
|
|
|
|
#include <asm-generic/pci_iomap.h>
|
|
|
|
#endif
|