All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-pci@vger.kernel.org, "Arnd Bergmann" <arnd@kernel.org>
Subject: [PATCH v5 44/44] asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n
Date: Mon, 22 May 2023 12:50:49 +0200	[thread overview]
Message-ID: <20230522105049.1467313-45-schnelle@linux.ibm.com> (raw)
In-Reply-To: <20230522105049.1467313-1-schnelle@linux.ibm.com>

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>
---
 include/asm-generic/io.h | 60 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 587e7e9b9a37..6ab2b6dfb6b1 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -539,6 +539,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;
@@ -548,10 +549,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;
@@ -561,10 +567,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;
@@ -574,36 +585,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>
@@ -687,53 +717,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
-- 
2.39.2


  parent reply	other threads:[~2023-05-22 10:55 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 10:50 [PATCH v5 00/44] treewide: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 01/44] kgdb: add HAS_IOPORT dependency Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 02/44] ata: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-22 11:49   ` Damien Le Moal
2023-05-22 10:50 ` [PATCH v5 03/44] char: " Niklas Schnelle
2023-07-04  8:09   ` Geert Uytterhoeven
2023-05-22 10:50 ` [PATCH v5 04/44] char: ipmi: handle " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 05/44] char: tpm: " Niklas Schnelle
2023-05-24  1:09   ` Jarkko Sakkinen
2023-05-24  3:13   ` Jarkko Sakkinen
2023-05-22 10:50 ` [PATCH v5 06/44] comedi: add " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 07/44] counter: add HAS_IOPORT_MAP dependency Niklas Schnelle
2023-06-08 14:59   ` William Breathitt Gray
2023-06-09 14:57     ` Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 08/44] /dev/port: don't compile file operations without CONFIG_DEVPORT Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 09/44] drm: handle HAS_IOPORT dependencies Niklas Schnelle
2023-05-22 10:50   ` Niklas Schnelle
2023-05-22 12:38   ` Thomas Zimmermann
2023-05-22 12:38     ` Thomas Zimmermann
2023-05-22 12:38     ` Thomas Zimmermann
2023-05-22 13:06     ` Arnd Bergmann
2023-05-22 13:06       ` Arnd Bergmann
2023-05-22 13:06       ` Arnd Bergmann
2023-05-22 13:14     ` Gerd Hoffmann
2023-05-22 13:14       ` Gerd Hoffmann
2023-05-22 13:14       ` Gerd Hoffmann
2023-05-22 10:50 ` [PATCH v5 10/44] firmware: dmi-sysfs: handle HAS_IOPORT=n Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 11/44] gpio: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-23  8:15   ` Bartosz Golaszewski
2023-05-22 10:50 ` [PATCH v5 12/44] hwmon: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 13/44] i2c: " Niklas Schnelle
2023-09-24 21:01   ` Wolfram Sang
2023-10-23 15:36     ` Wolfram Sang
2023-05-22 10:50 ` [PATCH v5 14/44] iio: ad7606: Kconfig: " Niklas Schnelle
2023-05-28 18:55   ` Jonathan Cameron
2023-05-30  9:21     ` Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 15/44] Input: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 16/44] Input: gameport: add ISA and " Niklas Schnelle
2023-05-22 22:16   ` Dmitry Torokhov
2023-05-22 10:50 ` [PATCH v5 17/44] leds: add " Niklas Schnelle
2023-05-25 11:21   ` Lee Jones
2023-05-22 10:50 ` [PATCH v5 18/44] media: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 19/44] misc: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 20/44] mISDN: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 21/44] mpt fusion: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 22/44] net: handle " Niklas Schnelle
2023-05-22 10:50   ` [Intel-wired-lan] " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 23/44] parport: PC style parport depends on HAS_IOPORT Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 24/44] PCI: Make quirk using inw() depend " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 25/44] PCI/sysfs: Make I/O resource " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 26/44] pcmcia: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 27/44] platform: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 28/44] pnp: " Niklas Schnelle
2023-05-22 11:54   ` Jaroslav Kysela
2023-05-22 10:50 ` [PATCH v5 29/44] power: " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 30/44] rtc: " Niklas Schnelle
2023-05-22 13:09   ` Maciej W. Rozycki
2023-06-06 21:35   ` (subset) " Alexandre Belloni
2023-07-04  8:06   ` Geert Uytterhoeven
2023-07-04 11:25     ` Arnd Bergmann
2023-07-04 12:46       ` Geert Uytterhoeven
2023-05-22 10:50 ` [PATCH v5 31/44] scsi: " Niklas Schnelle
2023-05-22 22:28   ` Martin K. Petersen
2023-05-23  7:26     ` Niklas Schnelle
2023-06-01  0:00       ` Martin K. Petersen
2023-05-22 10:50 ` [PATCH v5 32/44] sound: " Niklas Schnelle
2023-05-22 11:55   ` Jaroslav Kysela
2023-05-22 11:59   ` Takashi Iwai
2023-05-22 13:54     ` Niklas Schnelle
2023-05-22 14:44       ` Takashi Iwai
2023-05-22 10:50 ` [PATCH v5 33/44] speakup: add HAS_IOPORT dependency for SPEAKUP_SERIALIO Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 34/44] staging: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 35/44] tty: serial: handle " Niklas Schnelle
2023-05-30 14:39   ` Greg Kroah-Hartman
2023-05-22 10:50 ` [PATCH v5 36/44] usb: add " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 37/44] usb: uhci: handle " Niklas Schnelle
2023-05-22 13:57   ` Alan Stern
2023-05-22 10:50 ` [PATCH v5 38/44] usb: pci-quirks: " Niklas Schnelle
2023-05-29 14:34   ` Greg Kroah-Hartman
2023-05-22 10:50 ` [PATCH v5 39/44] vgacon: add " Niklas Schnelle
2023-05-22 10:50   ` Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 40/44] fbdev: " Niklas Schnelle
2023-05-22 10:50   ` Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 41/44] video: Handle " Niklas Schnelle
2023-05-22 10:50   ` Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 42/44] watchdog: add " Niklas Schnelle
2023-05-22 10:50 ` [PATCH v5 43/44] wireless: " Niklas Schnelle
2023-05-24  7:38   ` Kalle Valo
2023-05-25 12:01     ` Niklas Schnelle
2023-05-25 16:08   ` [v5,43/44] wifi: " Kalle Valo
2023-05-22 10:50 ` Niklas Schnelle [this message]
2023-05-22 11:29 ` [PATCH v5 00/44] treewide: Remove I/O port accessors for HAS_IOPORT=n Arnd Bergmann
2023-06-27  9:12   ` Niklas Schnelle
2023-06-27 12:53     ` Arnd Bergmann
2023-06-29 13:26       ` Niklas Schnelle
2023-06-08  1:42 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230522105049.1467313-45-schnelle@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=rafael@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.