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

tty: serial: meson: if no alias specified use an available id

At probe, the uart driver tries to get an id from a device tree alias.
When no alias was specified, the driver would return an error and probing
would fail.

Providing an alias for registering a serial device should not be mandatory.
If the device tree does not specify an alias, provide an id from a reserved
range so that the probing can continue.

Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Loys Ollivier and committed by
Greg Kroah-Hartman
a26988e8 896efccf

+12 -1
+12 -1
drivers/tty/serial/meson_uart.c
··· 72 72 #define AML_UART_BAUD_USE BIT(23) 73 73 #define AML_UART_BAUD_XTAL BIT(24) 74 74 75 - #define AML_UART_PORT_NUM 6 75 + #define AML_UART_PORT_NUM 12 76 + #define AML_UART_PORT_OFFSET 6 76 77 #define AML_UART_DEV_NAME "ttyAML" 77 78 78 79 ··· 655 654 struct resource *res_mem, *res_irq; 656 655 struct uart_port *port; 657 656 int ret = 0; 657 + int id = -1; 658 658 659 659 if (pdev->dev.of_node) 660 660 pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); 661 + 662 + if (pdev->id < 0) { 663 + for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) { 664 + if (!meson_ports[id]) { 665 + pdev->id = id; 666 + break; 667 + } 668 + } 669 + } 661 670 662 671 if (pdev->id < 0 || pdev->id >= AML_UART_PORT_NUM) 663 672 return -EINVAL;