Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ilpo Järvinen and committed by
Greg Kroah-Hartman
27a1c392 e23ee9d2

+20 -18
+20 -18
drivers/tty/serial/8250/8250_port.c
··· 336 336 337 337 #ifdef CONFIG_SERIAL_8250_RT288X 338 338 339 + #define UART_REG_UNMAPPED -1 340 + 339 341 /* Au1x00/RT288x UART hardware has a weird register layout */ 340 342 static const s8 au_io_in_map[8] = { 341 - 0, /* UART_RX */ 342 - 2, /* UART_IER */ 343 - 3, /* UART_IIR */ 344 - 5, /* UART_LCR */ 345 - 6, /* UART_MCR */ 346 - 7, /* UART_LSR */ 347 - 8, /* UART_MSR */ 348 - -1, /* UART_SCR (unmapped) */ 343 + [UART_RX] = 0, 344 + [UART_IER] = 2, 345 + [UART_IIR] = 3, 346 + [UART_LCR] = 5, 347 + [UART_MCR] = 6, 348 + [UART_LSR] = 7, 349 + [UART_MSR] = 8, 350 + [UART_SCR] = UART_REG_UNMAPPED, 349 351 }; 350 352 351 353 static const s8 au_io_out_map[8] = { 352 - 1, /* UART_TX */ 353 - 2, /* UART_IER */ 354 - 4, /* UART_FCR */ 355 - 5, /* UART_LCR */ 356 - 6, /* UART_MCR */ 357 - -1, /* UART_LSR (unmapped) */ 358 - -1, /* UART_MSR (unmapped) */ 359 - -1, /* UART_SCR (unmapped) */ 354 + [UART_TX] = 1, 355 + [UART_IER] = 2, 356 + [UART_FCR] = 4, 357 + [UART_LCR] = 5, 358 + [UART_MCR] = 6, 359 + [UART_LSR] = UART_REG_UNMAPPED, 360 + [UART_MSR] = UART_REG_UNMAPPED, 361 + [UART_SCR] = UART_REG_UNMAPPED, 360 362 }; 361 363 362 364 unsigned int au_serial_in(struct uart_port *p, int offset) ··· 366 364 if (offset >= ARRAY_SIZE(au_io_in_map)) 367 365 return UINT_MAX; 368 366 offset = au_io_in_map[offset]; 369 - if (offset < 0) 367 + if (offset == UART_REG_UNMAPPED) 370 368 return UINT_MAX; 371 369 return __raw_readl(p->membase + (offset << p->regshift)); 372 370 } ··· 376 374 if (offset >= ARRAY_SIZE(au_io_out_map)) 377 375 return; 378 376 offset = au_io_out_map[offset]; 379 - if (offset < 0) 377 + if (offset == UART_REG_UNMAPPED) 380 378 return; 381 379 __raw_writel(value, p->membase + (offset << p->regshift)); 382 380 }