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

serial: qcom-geni: Remove alias dependency from qcom serial driver

The absence of an alias in the device tree results in an invalid line
number, causing the driver probe to fail for GENI serial.

To prevent probe failures, dynamically assign line numbers if an alias is
not present in the device tree for non-console ports.

Signed-off-by: Viken Dadhaniya <quic_vdadhani@quicinc.com>
Link: https://lore.kernel.org/r/20250327070711.2585887-1-quic_vdadhani@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Viken Dadhaniya and committed by
Greg Kroah-Hartman
a53be694 6bd697b5

+22 -3
+22 -3
drivers/tty/serial/qcom_geni_serial.c
··· 98 98 99 99 #define DMA_RX_BUF_SIZE 2048 100 100 101 + static DEFINE_IDA(port_ida); 102 + 101 103 struct qcom_geni_device_data { 102 104 bool console; 103 105 enum geni_se_xfer_mode mode; ··· 255 253 struct qcom_geni_serial_port *port; 256 254 int nr_ports = console ? GENI_UART_CONS_PORTS : GENI_UART_PORTS; 257 255 258 - if (line < 0 || line >= nr_ports) 259 - return ERR_PTR(-ENXIO); 256 + if (console) { 257 + if (line < 0 || line >= nr_ports) 258 + return ERR_PTR(-ENXIO); 260 259 261 - port = console ? &qcom_geni_console_port : &qcom_geni_uart_ports[line]; 260 + port = &qcom_geni_console_port; 261 + } else { 262 + int max_alias_num = of_alias_get_highest_id("serial"); 263 + 264 + if (line < 0 || line >= nr_ports) 265 + line = ida_alloc_range(&port_ida, max_alias_num + 1, nr_ports, GFP_KERNEL); 266 + else 267 + line = ida_alloc_range(&port_ida, line, nr_ports, GFP_KERNEL); 268 + 269 + if (line < 0) 270 + return ERR_PTR(-ENXIO); 271 + 272 + port = &qcom_geni_uart_ports[line]; 273 + } 262 274 return port; 263 275 } 264 276 ··· 1777 1761 port->wakeup_irq); 1778 1762 if (ret) { 1779 1763 device_init_wakeup(&pdev->dev, false); 1764 + ida_free(&port_ida, uport->line); 1780 1765 uart_remove_one_port(drv, uport); 1781 1766 return ret; 1782 1767 } ··· 1789 1772 static void qcom_geni_serial_remove(struct platform_device *pdev) 1790 1773 { 1791 1774 struct qcom_geni_serial_port *port = platform_get_drvdata(pdev); 1775 + struct uart_port *uport = &port->uport; 1792 1776 struct uart_driver *drv = port->private_data.drv; 1793 1777 1794 1778 dev_pm_clear_wake_irq(&pdev->dev); 1795 1779 device_init_wakeup(&pdev->dev, false); 1780 + ida_free(&port_ida, uport->line); 1796 1781 uart_remove_one_port(drv, &port->uport); 1797 1782 } 1798 1783