serial: 8250: Use C99 array initializer & define UART_REG_UNMAPPED

Use C99 array initializer insteads of comments and make unmapped checks
more obvious.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220624205424.12686-5-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ilpo Järvinen 2022-06-24 23:54:22 +03:00 committed by Greg Kroah-Hartman
parent e23ee9d2c4
commit 27a1c39215

View File

@ -336,27 +336,29 @@ static void default_serial_dl_write(struct uart_8250_port *up, int value)
#ifdef CONFIG_SERIAL_8250_RT288X #ifdef CONFIG_SERIAL_8250_RT288X
#define UART_REG_UNMAPPED -1
/* Au1x00/RT288x UART hardware has a weird register layout */ /* Au1x00/RT288x UART hardware has a weird register layout */
static const s8 au_io_in_map[8] = { static const s8 au_io_in_map[8] = {
0, /* UART_RX */ [UART_RX] = 0,
2, /* UART_IER */ [UART_IER] = 2,
3, /* UART_IIR */ [UART_IIR] = 3,
5, /* UART_LCR */ [UART_LCR] = 5,
6, /* UART_MCR */ [UART_MCR] = 6,
7, /* UART_LSR */ [UART_LSR] = 7,
8, /* UART_MSR */ [UART_MSR] = 8,
-1, /* UART_SCR (unmapped) */ [UART_SCR] = UART_REG_UNMAPPED,
}; };
static const s8 au_io_out_map[8] = { static const s8 au_io_out_map[8] = {
1, /* UART_TX */ [UART_TX] = 1,
2, /* UART_IER */ [UART_IER] = 2,
4, /* UART_FCR */ [UART_FCR] = 4,
5, /* UART_LCR */ [UART_LCR] = 5,
6, /* UART_MCR */ [UART_MCR] = 6,
-1, /* UART_LSR (unmapped) */ [UART_LSR] = UART_REG_UNMAPPED,
-1, /* UART_MSR (unmapped) */ [UART_MSR] = UART_REG_UNMAPPED,
-1, /* UART_SCR (unmapped) */ [UART_SCR] = UART_REG_UNMAPPED,
}; };
unsigned int au_serial_in(struct uart_port *p, int offset) unsigned int au_serial_in(struct uart_port *p, int offset)
@ -364,7 +366,7 @@ unsigned int au_serial_in(struct uart_port *p, int offset)
if (offset >= ARRAY_SIZE(au_io_in_map)) if (offset >= ARRAY_SIZE(au_io_in_map))
return UINT_MAX; return UINT_MAX;
offset = au_io_in_map[offset]; offset = au_io_in_map[offset];
if (offset < 0) if (offset == UART_REG_UNMAPPED)
return UINT_MAX; return UINT_MAX;
return __raw_readl(p->membase + (offset << p->regshift)); return __raw_readl(p->membase + (offset << p->regshift));
} }
@ -374,7 +376,7 @@ void au_serial_out(struct uart_port *p, int offset, int value)
if (offset >= ARRAY_SIZE(au_io_out_map)) if (offset >= ARRAY_SIZE(au_io_out_map))
return; return;
offset = au_io_out_map[offset]; offset = au_io_out_map[offset];
if (offset < 0) if (offset == UART_REG_UNMAPPED)
return; return;
__raw_writel(value, p->membase + (offset << p->regshift)); __raw_writel(value, p->membase + (offset << p->regshift));
} }