Unverified Commit 6f043e75 authored by Niklas Schnelle's avatar Niklas Schnelle Committed by Arnd Bergmann
Browse files

asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n

With all subsystems and drivers either declaring their dependence on
HAS_IOPORT or fencing I/O port specific code sections we can finally
make inb()/outb() and friends compile-time dependent on HAS_IOPORT as
suggested by Linus in the linked mail. The main benefit of this is that
on platforms such as s390 which have no meaningful way of implementing
inb()/outb() their use without the proper HAS_IOPORT dependency will
result in easy to catch and fix compile-time errors instead of compiling
code that can never work.

Link: https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/


Co-developed-by: default avatarArnd Bergmann <arnd@kernel.org>
Signed-off-by: default avatarArnd Bergmann <arnd@kernel.org>
Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Acked-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Acked-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
Acked-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net> # for ARCH=um
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarKalle Valo <kvalo@kernel.org>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Acked-by: default avatarCorey Minyard <cminyard@mvista.com>
Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
Acked-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 7c7e6c89
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
@@ -540,6 +540,7 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,

#if !defined(inb) && !defined(_inb)
#define _inb _inb
#ifdef CONFIG_HAS_IOPORT
static inline u8 _inb(unsigned long addr)
{
	u8 val;
@@ -549,10 +550,15 @@ static inline u8 _inb(unsigned long addr)
	__io_par(val);
	return val;
}
#else
u8 _inb(unsigned long addr)
	__compiletime_error("inb()) requires CONFIG_HAS_IOPORT");
#endif
#endif

#if !defined(inw) && !defined(_inw)
#define _inw _inw
#ifdef CONFIG_HAS_IOPORT
static inline u16 _inw(unsigned long addr)
{
	u16 val;
@@ -562,10 +568,15 @@ static inline u16 _inw(unsigned long addr)
	__io_par(val);
	return val;
}
#else
u16 _inw(unsigned long addr)
	__compiletime_error("inw() requires CONFIG_HAS_IOPORT");
#endif
#endif

#if !defined(inl) && !defined(_inl)
#define _inl _inl
#ifdef CONFIG_HAS_IOPORT
static inline u32 _inl(unsigned long addr)
{
	u32 val;
@@ -575,36 +586,55 @@ static inline u32 _inl(unsigned long addr)
	__io_par(val);
	return val;
}
#else
u32 _inl(unsigned long addr)
	__compiletime_error("inl() requires CONFIG_HAS_IOPORT");
#endif
#endif

#if !defined(outb) && !defined(_outb)
#define _outb _outb
#ifdef CONFIG_HAS_IOPORT
static inline void _outb(u8 value, unsigned long addr)
{
	__io_pbw();
	__raw_writeb(value, PCI_IOBASE + addr);
	__io_paw();
}
#else
void _outb(u8 value, unsigned long addr)
	__compiletime_error("outb() requires CONFIG_HAS_IOPORT");
#endif
#endif

#if !defined(outw) && !defined(_outw)
#define _outw _outw
#ifdef CONFIG_HAS_IOPORT
static inline void _outw(u16 value, unsigned long addr)
{
	__io_pbw();
	__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
	__io_paw();
}
#else
void _outw(u16 value, unsigned long addr)
	__compiletime_error("outw() requires CONFIG_HAS_IOPORT");
#endif
#endif

#if !defined(outl) && !defined(_outl)
#define _outl _outl
#ifdef CONFIG_HAS_IOPORT
static inline void _outl(u32 value, unsigned long addr)
{
	__io_pbw();
	__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
	__io_paw();
}
#else
void _outl(u32 value, unsigned long addr)
	__compiletime_error("outl() requires CONFIG_HAS_IOPORT");
#endif
#endif

#include <linux/logic_pio.h>
@@ -688,53 +718,83 @@ static inline void outl_p(u32 value, unsigned long addr)

#ifndef insb
#define insb insb
#ifdef CONFIG_HAS_IOPORT
static inline void insb(unsigned long addr, void *buffer, unsigned int count)
{
	readsb(PCI_IOBASE + addr, buffer, count);
}
#else
void insb(unsigned long addr, void *buffer, unsigned int count)
	__compiletime_error("insb() requires HAS_IOPORT");
#endif
#endif

#ifndef insw
#define insw insw
#ifdef CONFIG_HAS_IOPORT
static inline void insw(unsigned long addr, void *buffer, unsigned int count)
{
	readsw(PCI_IOBASE + addr, buffer, count);
}
#else
void insw(unsigned long addr, void *buffer, unsigned int count)
	__compiletime_error("insw() requires HAS_IOPORT");
#endif
#endif

#ifndef insl
#define insl insl
#ifdef CONFIG_HAS_IOPORT
static inline void insl(unsigned long addr, void *buffer, unsigned int count)
{
	readsl(PCI_IOBASE + addr, buffer, count);
}
#else
void insl(unsigned long addr, void *buffer, unsigned int count)
	__compiletime_error("insl() requires HAS_IOPORT");
#endif
#endif

#ifndef outsb
#define outsb outsb
#ifdef CONFIG_HAS_IOPORT
static inline void outsb(unsigned long addr, const void *buffer,
			 unsigned int count)
{
	writesb(PCI_IOBASE + addr, buffer, count);
}
#else
void outsb(unsigned long addr, const void *buffer, unsigned int count)
	__compiletime_error("outsb() requires HAS_IOPORT");
#endif
#endif

#ifndef outsw
#define outsw outsw
#ifdef CONFIG_HAS_IOPORT
static inline void outsw(unsigned long addr, const void *buffer,
			 unsigned int count)
{
	writesw(PCI_IOBASE + addr, buffer, count);
}
#else
void outsw(unsigned long addr, const void *buffer, unsigned int count)
	__compiletime_error("outsw() requires HAS_IOPORT");
#endif
#endif

#ifndef outsl
#define outsl outsl
#ifdef CONFIG_HAS_IOPORT
static inline void outsl(unsigned long addr, const void *buffer,
			 unsigned int count)
{
	writesl(PCI_IOBASE + addr, buffer, count);
}
#else
void outsl(unsigned long addr, const void *buffer, unsigned int count)
	__compiletime_error("outsl() requires HAS_IOPORT");
#endif
#endif

#ifndef insb_p