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: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net> # for ARCH=um
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Kalle Valo <kvalo@kernel.org>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Niklas Schnelle 2024-10-24 19:54:44 +02:00 committed by Arnd Bergmann
parent 7c7e6c8924
commit 6f043e7574
No known key found for this signature in database
GPG Key ID: 60AB47FFC9095227

View File

@ -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