mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
serial: 8250: use uart_iotype_*() to simplify code
Make use of new functions uart_iotype_mmio() and uart_iotype_legacy_io() to simplify and improve code readability. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Link: https://patch.msgid.link/20260521-tty-upio-v3-5-bf74567994a0@dimonoff.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
86305190f3
commit
548aa0c850
|
|
@ -474,16 +474,10 @@ static void set_io_from_upio(struct uart_port *p)
|
|||
static void
|
||||
serial_port_out_sync(struct uart_port *p, int offset, int value)
|
||||
{
|
||||
switch (p->iotype) {
|
||||
case UPIO_MEM:
|
||||
case UPIO_MEM16:
|
||||
case UPIO_MEM32:
|
||||
case UPIO_MEM32BE:
|
||||
case UPIO_AU:
|
||||
if (uart_iotype_mmio(p->iotype)) {
|
||||
p->serial_out(p, offset, value);
|
||||
p->serial_in(p, UART_LCR); /* safe, no side-effects */
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
p->serial_out(p, offset, value);
|
||||
}
|
||||
}
|
||||
|
|
@ -2885,13 +2879,7 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
|
|||
unsigned int size = serial8250_port_size(up);
|
||||
struct uart_port *port = &up->port;
|
||||
|
||||
switch (port->iotype) {
|
||||
case UPIO_AU:
|
||||
case UPIO_TSI:
|
||||
case UPIO_MEM32:
|
||||
case UPIO_MEM32BE:
|
||||
case UPIO_MEM16:
|
||||
case UPIO_MEM:
|
||||
if (uart_iotype_mmio(port->iotype)) {
|
||||
if (!port->mapbase)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
@ -2905,14 +2893,9 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
|
|||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case UPIO_HUB6:
|
||||
case UPIO_PORT:
|
||||
} else if (uart_iotype_io(port->iotype)) {
|
||||
if (!request_region(port->iobase, size, "serial"))
|
||||
return -EBUSY;
|
||||
return 0;
|
||||
case UPIO_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -2923,15 +2906,9 @@ static void serial8250_release_std_resource(struct uart_8250_port *up)
|
|||
unsigned int size = serial8250_port_size(up);
|
||||
struct uart_port *port = &up->port;
|
||||
|
||||
switch (port->iotype) {
|
||||
case UPIO_AU:
|
||||
case UPIO_TSI:
|
||||
case UPIO_MEM32:
|
||||
case UPIO_MEM32BE:
|
||||
case UPIO_MEM16:
|
||||
case UPIO_MEM:
|
||||
if (uart_iotype_mmio(port->iotype)) {
|
||||
if (!port->mapbase)
|
||||
break;
|
||||
return;
|
||||
|
||||
if (port->flags & UPF_IOREMAP) {
|
||||
iounmap(port->membase);
|
||||
|
|
@ -2939,14 +2916,8 @@ static void serial8250_release_std_resource(struct uart_8250_port *up)
|
|||
}
|
||||
|
||||
release_mem_region(port->mapbase, size);
|
||||
break;
|
||||
|
||||
case UPIO_HUB6:
|
||||
case UPIO_PORT:
|
||||
} else if (uart_iotype_io(port->iotype)) {
|
||||
release_region(port->iobase, size);
|
||||
break;
|
||||
case UPIO_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user