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

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 <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Uwe Kleine-König and committed by
Greg Kroah-Hartman
11f1ad3a 574de559

+10 -7
+10 -7
drivers/tty/serial/efm32-uart.c
··· 698 698 { 699 699 struct efm32_uart_port *efm_port; 700 700 struct resource *res; 701 + unsigned int line; 701 702 int ret; 702 703 703 704 efm_port = kzalloc(sizeof(*efm_port), GFP_KERNEL); ··· 753 752 efm_port->pdata = *pdata; 754 753 } 755 754 756 - if (efm_port->port.line >= 0 && 757 - efm_port->port.line < ARRAY_SIZE(efm32_uart_ports)) 758 - efm32_uart_ports[efm_port->port.line] = efm_port; 755 + line = efm_port->port.line; 756 + 757 + if (line >= 0 && line < ARRAY_SIZE(efm32_uart_ports)) 758 + efm32_uart_ports[line] = efm_port; 759 759 760 760 ret = uart_add_one_port(&efm32_uart_reg, &efm_port->port); 761 761 if (ret) { 762 762 dev_dbg(&pdev->dev, "failed to add port: %d\n", ret); 763 763 764 - if (pdev->id >= 0 && pdev->id < ARRAY_SIZE(efm32_uart_ports)) 765 - efm32_uart_ports[pdev->id] = NULL; 764 + if (line >= 0 && line < ARRAY_SIZE(efm32_uart_ports)) 765 + efm32_uart_ports[line] = NULL; 766 766 err_get_rxirq: 767 767 err_too_small: 768 768 err_get_base: ··· 779 777 static int efm32_uart_remove(struct platform_device *pdev) 780 778 { 781 779 struct efm32_uart_port *efm_port = platform_get_drvdata(pdev); 780 + unsigned int line = efm_port->port.line; 782 781 783 782 uart_remove_one_port(&efm32_uart_reg, &efm_port->port); 784 783 785 - if (pdev->id >= 0 && pdev->id < ARRAY_SIZE(efm32_uart_ports)) 786 - efm32_uart_ports[pdev->id] = NULL; 784 + if (line >= 0 && line < ARRAY_SIZE(efm32_uart_ports)) 785 + efm32_uart_ports[line] = NULL; 787 786 788 787 kfree(efm_port); 789 788