]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tty: serial: meson: if no alias specified use an available id
authorLoys Ollivier <lollivier@baylibre.com>
Mon, 14 Jan 2019 16:54:26 +0000 (17:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Jan 2019 10:22:22 +0000 (11:22 +0100)
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>
drivers/tty/serial/meson_uart.c

index 8a842591b37c714f976ab23f39663ced5528508f..fbc5bc022a39281b5ca0b09e2085d8f4848b652a 100644 (file)
@@ -72,7 +72,8 @@
 #define AML_UART_BAUD_USE              BIT(23)
 #define AML_UART_BAUD_XTAL             BIT(24)
 
-#define AML_UART_PORT_NUM              6
+#define AML_UART_PORT_NUM              12
+#define AML_UART_PORT_OFFSET           6
 #define AML_UART_DEV_NAME              "ttyAML"
 
 
@@ -654,10 +655,20 @@ static int meson_uart_probe(struct platform_device *pdev)
        struct resource *res_mem, *res_irq;
        struct uart_port *port;
        int ret = 0;
+       int id = -1;
 
        if (pdev->dev.of_node)
                pdev->id = of_alias_get_id(pdev->dev.of_node, "serial");
 
+       if (pdev->id < 0) {
+               for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) {
+                       if (!meson_ports[id]) {
+                               pdev->id = id;
+                               break;
+                       }
+               }
+       }
+
        if (pdev->id < 0 || pdev->id >= AML_UART_PORT_NUM)
                return -EINVAL;