powerpc/io: Wrap port calculation in a macro
authorMichael Ellerman <mpe@ellerman.id.au>
Wed, 18 Dec 2024 10:55:02 +0000 (21:55 +1100)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Wed, 26 Feb 2025 15:45:08 +0000 (21:15 +0530)
The calculation of the IO port is repeated several times, wrap it in
a macro, in particular to avoid spelling out the cast multiple times.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20241218105523.416573-14-mpe@ellerman.id.au
arch/powerpc/include/asm/io.h

index 7731f2364275e8d21ba422b00f05dc13ac27f213..c21796354f87e5a95b7f7b13b67f887188304f55 100644 (file)
@@ -277,6 +277,8 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
 /* Shortcut to the MMIO argument pointer */
 #define PCI_IO_ADDR    volatile void __iomem *
 
+#define _IO_PORT(port) ((PCI_IO_ADDR)(_IO_BASE + (port)))
+
 /*
  * Non ordered and non-swapping "raw" accessors
  */
@@ -532,12 +534,12 @@ __do_out_asm(_rec_outl, "stwbrx")
 #define __do_inw(port)         _rec_inw(port)
 #define __do_inl(port)         _rec_inl(port)
 #else /* CONFIG_PPC32 */
-#define __do_outb(val, port)   writeb(val,(PCI_IO_ADDR)(_IO_BASE+port));
-#define __do_outw(val, port)   writew(val,(PCI_IO_ADDR)(_IO_BASE+port));
-#define __do_outl(val, port)   writel(val,(PCI_IO_ADDR)(_IO_BASE+port));
-#define __do_inb(port)         readb((PCI_IO_ADDR)(_IO_BASE + port));
-#define __do_inw(port)         readw((PCI_IO_ADDR)(_IO_BASE + port));
-#define __do_inl(port)         readl((PCI_IO_ADDR)(_IO_BASE + port));
+#define __do_outb(val, port)   writeb(val,_IO_PORT(port));
+#define __do_outw(val, port)   writew(val,_IO_PORT(port));
+#define __do_outl(val, port)   writel(val,_IO_PORT(port));
+#define __do_inb(port)         readb(_IO_PORT(port));
+#define __do_inw(port)         readw(_IO_PORT(port));
+#define __do_inl(port)         readl(_IO_PORT(port));
 #endif /* !CONFIG_PPC32 */
 
 #ifdef CONFIG_EEH
@@ -553,12 +555,12 @@ __do_out_asm(_rec_outl, "stwbrx")
 #define __do_writesw(a, b, n)  _outsw(a, (b), (n))
 #define __do_writesl(a, b, n)  _outsl(a, (b), (n))
 
-#define __do_insb(p, b, n)     readsb((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n))
-#define __do_insw(p, b, n)     readsw((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n))
-#define __do_insl(p, b, n)     readsl((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n))
-#define __do_outsb(p, b, n)    writesb((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n))
-#define __do_outsw(p, b, n)    writesw((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n))
-#define __do_outsl(p, b, n)    writesl((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n))
+#define __do_insb(p, b, n)     readsb(_IO_PORT(p), (b), (n))
+#define __do_insw(p, b, n)     readsw(_IO_PORT(p), (b), (n))
+#define __do_insl(p, b, n)     readsl(_IO_PORT(p), (b), (n))
+#define __do_outsb(p, b, n)    writesb(_IO_PORT(p),(b),(n))
+#define __do_outsw(p, b, n)    writesw(_IO_PORT(p),(b),(n))
+#define __do_outsl(p, b, n)    writesl(_IO_PORT(p),(b),(n))
 
 #ifdef CONFIG_EEH
 #define __do_memcpy_fromio(dst, src, n)        \