Skip to content

Commit 11f1ad3

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
serial/efm32-uart: don't use pdev->id to determine the port's line
pdev->id is not a valid choice for device-tree probed devices. So use the (properly determined) line from efm32_uart_probe consistenly Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 574de55 commit 11f1ad3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/tty/serial/efm32-uart.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ static int efm32_uart_probe(struct platform_device *pdev)
698698
{
699699
struct efm32_uart_port *efm_port;
700700
struct resource *res;
701+
unsigned int line;
701702
int ret;
702703

703704
efm_port = kzalloc(sizeof(*efm_port), GFP_KERNEL);
@@ -752,16 +753,17 @@ static int efm32_uart_probe(struct platform_device *pdev)
752753
efm_port->pdata = *pdata;
753754
}
754755

755-
if (efm_port->port.line >= 0 &&
756-
efm_port->port.line < ARRAY_SIZE(efm32_uart_ports))
757-
efm32_uart_ports[efm_port->port.line] = efm_port;
756+
line = efm_port->port.line;
757+
758+
if (line >= 0 && line < ARRAY_SIZE(efm32_uart_ports))
759+
efm32_uart_ports[line] = efm_port;
758760

759761
ret = uart_add_one_port(&efm32_uart_reg, &efm_port->port);
760762
if (ret) {
761763
dev_dbg(&pdev->dev, "failed to add port: %d\n", ret);
762764

763-
if (pdev->id >= 0 && pdev->id < ARRAY_SIZE(efm32_uart_ports))
764-
efm32_uart_ports[pdev->id] = NULL;
765+
if (line >= 0 && line < ARRAY_SIZE(efm32_uart_ports))
766+
efm32_uart_ports[line] = NULL;
765767
err_get_rxirq:
766768
err_too_small:
767769
err_get_base:
@@ -777,11 +779,12 @@ static int efm32_uart_probe(struct platform_device *pdev)
777779
static int efm32_uart_remove(struct platform_device *pdev)
778780
{
779781
struct efm32_uart_port *efm_port = platform_get_drvdata(pdev);
782+
unsigned int line = efm_port->port.line;
780783

781784
uart_remove_one_port(&efm32_uart_reg, &efm_port->port);
782785

783-
if (pdev->id >= 0 && pdev->id < ARRAY_SIZE(efm32_uart_ports))
784-
efm32_uart_ports[pdev->id] = NULL;
786+
if (line >= 0 && line < ARRAY_SIZE(efm32_uart_ports))
787+
efm32_uart_ports[line] = NULL;
785788

786789
kfree(efm_port);
787790

0 commit comments

Comments
 (0)