Re: [PATCH v5 1/3] riscv: io: avoid null-pointer arithmetic in PIO helpers

From: Arnd Bergmann

Date: Wed Jul 01 2026 - 02:26:45 EST


On Wed, Jul 1, 2026, at 06:20, Yunhui Cui wrote:
> @@ -56,6 +56,8 @@
> #define __io_pbw() RISCV_FENCE(iow, o)
> #define __io_paw() RISCV_FENCE(o, io)
>
> +#define PCI_IO_ADDR(addr) ((void __iomem *)((unsigned long)PCI_IOBASE
> + (addr)))

This does not seem to have any purpose, is this just left over
from the previous version?

>
> +#ifdef CONFIG_HAS_IOPORT
> __io_reads_ins(ins, u8, b, __io_pbr(), __io_par(addr))
> __io_reads_ins(ins, u16, w, __io_pbr(), __io_par(addr))
> __io_reads_ins(ins, u32, l, __io_pbr(), __io_par(addr))
> -#define insb(addr, buffer, count) __insb(PCI_IOBASE + (addr), buffer, count)
> -#define insw(addr, buffer, count) __insw(PCI_IOBASE + (addr), buffer, count)
> -#define insl(addr, buffer, count) __insl(PCI_IOBASE + (addr), buffer, count)
> +#define insb(addr, buffer, count) __insb(PCI_IO_ADDR(addr), buffer, count)
> +#define insw(addr, buffer, count) __insw(PCI_IO_ADDR(addr), buffer, count)
> +#define insl(addr, buffer, count) __insl(PCI_IO_ADDR(addr), buffer, count)
> +#endif

As far as I can tell, just adding the #ifdef here should be sufficient.

Arnd