Re: [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT
From: Atsushi Nemoto
Date: Tue Aug 04 2026 - 10:36:51 EST
On Tue, 4 Aug 2026 10:57:54 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@xxxxxxxxxxxx> wrote:
> After the previous commit it's obvious that .iotype is always UPIO_PORT.
> Simplify some functions accordingly.
No, .iotype can be UPIO_MEM if early_serial_txx9_setup() was called from
arch/mips/txx9/generic/setup.c.
---
Atsushi Nemoto
On Tue, 4 Aug 2026 10:57:54 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@xxxxxxxxxxxx> wrote:
> After the previous commit it's obvious that .iotype is always UPIO_PORT.
> Simplify some functions accordingly.
>
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
> Link: https://lore.kernel.org/linux-serial/01a84877-9cc7-8136-d5a8-e368a36cda93@xxxxxxxxxxxxxxx
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@xxxxxxxxxxxx>
> ---
> drivers/tty/serial/serial_txx9.c | 69 ++++----------------------------
> 1 file changed, 7 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
> index ef56979321b9..bda7f7527b8d 100644
> --- a/drivers/tty/serial/serial_txx9.c
> +++ b/drivers/tty/serial/serial_txx9.c
> @@ -158,25 +158,13 @@
>
> static inline unsigned int sio_in(struct uart_port *up, int offset)
> {
> - switch (up->iotype) {
> - default:
> - return __raw_readl(up->membase + offset);
> - case UPIO_PORT:
> - return inl(up->iobase + offset);
> - }
> + return inl(up->iobase + offset);
> }
>
> static inline void
> sio_out(struct uart_port *up, int offset, int value)
> {
> - switch (up->iotype) {
> - default:
> - __raw_writel(value, up->membase + offset);
> - break;
> - case UPIO_PORT:
> - outl(value, up->iobase + offset);
> - break;
> - }
> + outl(value, up->iobase + offset);
> }
>
> static inline void
> @@ -698,57 +686,15 @@ serial_txx9_pm(struct uart_port *port, unsigned int state,
>
> static int serial_txx9_request_resource(struct uart_port *up)
> {
> - unsigned int size = TXX9_REGION_SIZE;
> - int ret = 0;
> + if (!request_region(up->iobase, TXX9_REGION_SIZE, "serial_txx9"))
> + return -EBUSY;
>
> - switch (up->iotype) {
> - default:
> - if (!up->mapbase)
> - break;
> -
> - if (!request_mem_region(up->mapbase, size, "serial_txx9")) {
> - ret = -EBUSY;
> - break;
> - }
> -
> - if (up->flags & UPF_IOREMAP) {
> - up->membase = ioremap(up->mapbase, size);
> - if (!up->membase) {
> - release_mem_region(up->mapbase, size);
> - ret = -ENOMEM;
> - }
> - }
> - break;
> -
> - case UPIO_PORT:
> - if (!request_region(up->iobase, size, "serial_txx9"))
> - ret = -EBUSY;
> - break;
> - }
> - return ret;
> + return 0;
> }
>
> static void serial_txx9_release_resource(struct uart_port *up)
> {
> - unsigned int size = TXX9_REGION_SIZE;
> -
> - switch (up->iotype) {
> - default:
> - if (!up->mapbase)
> - break;
> -
> - if (up->flags & UPF_IOREMAP) {
> - iounmap(up->membase);
> - up->membase = NULL;
> - }
> -
> - release_mem_region(up->mapbase, size);
> - break;
> -
> - case UPIO_PORT:
> - release_region(up->iobase, size);
> - break;
> - }
> + release_region(up->iobase, TXX9_REGION_SIZE);
> }
>
> static void serial_txx9_release_port(struct uart_port *up)
> @@ -983,7 +929,7 @@ static int serial_txx9_register_port(struct uart_port *port)
> uart->membase = port->membase;
> uart->irq = port->irq;
> uart->uartclk = port->uartclk;
> - uart->iotype = port->iotype;
> + uart->iotype = UPIO_PORT;
> uart->flags = port->flags
> | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT;
> uart->mapbase = port->mapbase;
> @@ -1081,7 +1027,6 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
> port.flags |= UPF_TXX9_HAVE_CTS_LINE;
> port.uartclk = 66670000;
> port.irq = dev->irq;
> - port.iotype = UPIO_PORT;
> port.iobase = pci_resource_start(dev, 1);
> port.dev = &dev->dev;
> line = serial_txx9_register_port(&port);
> --
> 2.55.0.11.g153666a7d9bb
>
>