serial: port: Assign ->iotype correctly when ->iobase is set

Currently the ->iotype is always assigned to the UPIO_MEM when
the respective property is not found. However, this will not
support the cases when user wants to have UPIO_PORT to be set
or preserved. Support this scenario by checking ->iobase value
and default the ->iotype respectively.

Fixes: 1117a6fdc7c1 ("serial: 8250_of: Switch to use uart_read_port_properties()")
Fixes: e894b6005dce ("serial: port: Introduce a common helper to read properties")
Cc: stable <stable@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250124161530.398361-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by Andy Shevchenko and committed by Greg Kroah-Hartman 166ac2bb e8ed246d

+2 -1
+2 -1
drivers/tty/serial/serial_port.c
··· 173 * The caller is responsible to initialize the following fields of the @port 174 * ->dev (must be valid) 175 * ->flags 176 * ->mapbase 177 * ->mapsize 178 * ->regshift (if @use_defaults is false) ··· 215 /* Read the registers I/O access type (default: MMIO 8-bit) */ 216 ret = device_property_read_u32(dev, "reg-io-width", &value); 217 if (ret) { 218 - port->iotype = UPIO_MEM; 219 } else { 220 switch (value) { 221 case 1:
··· 173 * The caller is responsible to initialize the following fields of the @port 174 * ->dev (must be valid) 175 * ->flags 176 + * ->iobase 177 * ->mapbase 178 * ->mapsize 179 * ->regshift (if @use_defaults is false) ··· 214 /* Read the registers I/O access type (default: MMIO 8-bit) */ 215 ret = device_property_read_u32(dev, "reg-io-width", &value); 216 if (ret) { 217 + port->iotype = port->iobase ? UPIO_PORT : UPIO_MEM; 218 } else { 219 switch (value) { 220 case 1: