Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb9d94bd authored by Loys Ollivier's avatar Loys Ollivier Committed by Greg Kroah-Hartman
Browse files

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



[ Upstream commit a26988e8fef4b258d1b771e0f4b2e3b67cb2e044 ]

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: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarLoys Ollivier <lollivier@baylibre.com>
Reviewed-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 2a1d728f20ed ("tty: serial: meson: fix hard LOCKUP on crtscts mode")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 65312da2
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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"


@@ -667,10 +668,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;