Skip to content

Commit 8a55941

Browse files
mpemaddy-kerneldev
authored andcommitted
powerpc/io: Wrap port calculation in a macro
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 <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 41c8992 commit 8a55941

File tree

1 file changed

+14
-12
lines changed
  • arch/powerpc/include/asm

1 file changed

+14
-12
lines changed

arch/powerpc/include/asm/io.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
277277
/* Shortcut to the MMIO argument pointer */
278278
#define PCI_IO_ADDR volatile void __iomem *
279279

280+
#define _IO_PORT(port) ((PCI_IO_ADDR)(_IO_BASE + (port)))
281+
280282
/*
281283
* Non ordered and non-swapping "raw" accessors
282284
*/
@@ -532,12 +534,12 @@ __do_out_asm(_rec_outl, "stwbrx")
532534
#define __do_inw(port) _rec_inw(port)
533535
#define __do_inl(port) _rec_inl(port)
534536
#else /* CONFIG_PPC32 */
535-
#define __do_outb(val, port) writeb(val,(PCI_IO_ADDR)(_IO_BASE+port));
536-
#define __do_outw(val, port) writew(val,(PCI_IO_ADDR)(_IO_BASE+port));
537-
#define __do_outl(val, port) writel(val,(PCI_IO_ADDR)(_IO_BASE+port));
538-
#define __do_inb(port) readb((PCI_IO_ADDR)(_IO_BASE + port));
539-
#define __do_inw(port) readw((PCI_IO_ADDR)(_IO_BASE + port));
540-
#define __do_inl(port) readl((PCI_IO_ADDR)(_IO_BASE + port));
537+
#define __do_outb(val, port) writeb(val,_IO_PORT(port));
538+
#define __do_outw(val, port) writew(val,_IO_PORT(port));
539+
#define __do_outl(val, port) writel(val,_IO_PORT(port));
540+
#define __do_inb(port) readb(_IO_PORT(port));
541+
#define __do_inw(port) readw(_IO_PORT(port));
542+
#define __do_inl(port) readl(_IO_PORT(port));
541543
#endif /* !CONFIG_PPC32 */
542544

543545
#ifdef CONFIG_EEH
@@ -553,12 +555,12 @@ __do_out_asm(_rec_outl, "stwbrx")
553555
#define __do_writesw(a, b, n) _outsw(a, (b), (n))
554556
#define __do_writesl(a, b, n) _outsl(a, (b), (n))
555557

556-
#define __do_insb(p, b, n) readsb((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n))
557-
#define __do_insw(p, b, n) readsw((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n))
558-
#define __do_insl(p, b, n) readsl((PCI_IO_ADDR)(_IO_BASE+(p)), (b), (n))
559-
#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n))
560-
#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n))
561-
#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)(_IO_BASE+(p)),(b),(n))
558+
#define __do_insb(p, b, n) readsb(_IO_PORT(p), (b), (n))
559+
#define __do_insw(p, b, n) readsw(_IO_PORT(p), (b), (n))
560+
#define __do_insl(p, b, n) readsl(_IO_PORT(p), (b), (n))
561+
#define __do_outsb(p, b, n) writesb(_IO_PORT(p),(b),(n))
562+
#define __do_outsw(p, b, n) writesw(_IO_PORT(p),(b),(n))
563+
#define __do_outsl(p, b, n) writesl(_IO_PORT(p),(b),(n))
562564

563565
#ifdef CONFIG_EEH
564566
#define __do_memcpy_fromio(dst, src, n) \

0 commit comments

Comments
 (0)