[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250529090325.1479702-1-quic_zongjian@quicinc.com>
Date: Thu, 29 May 2025 17:03:25 +0800
From: zongjian <quic_zongjian@...cinc.com>
To: <quic_zongjian@...cinc.com>, <linux-serial@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: <quic_ztu@...cinc.com>, <quic_haixcui@...cinc.com>,
<quic_anupkulk@...cinc.com>, <quic_msavaliy@...cinc.com>,
<quic_vdadhani@...cinc.com>
Subject: [PATCH v1] serial: qcom-geni: Add support to increase UART ports efficiently
Populate members of qcom_geni_uart_ports through a loop for
better maintainability.
Increase the UART ports to 5, as a few use cases require more than 3 UART ports.
Signed-off-by: zongjian <quic_zongjian@...cinc.com>
---
drivers/tty/serial/qcom_geni_serial.c | 40 +++++++++------------------
1 file changed, 13 insertions(+), 27 deletions(-)
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 140c3ae5ead2..d969c96b9690 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -77,7 +77,7 @@
#define STALE_TIMEOUT 16
#define DEFAULT_BITS_PER_CHAR 10
#define GENI_UART_CONS_PORTS 1
-#define GENI_UART_PORTS 3
+#define GENI_UART_PORTS 5
#define DEF_FIFO_DEPTH_WORDS 16
#define DEF_TX_WM 2
#define DEF_FIFO_WIDTH_BITS 32
@@ -153,6 +153,7 @@ static const struct uart_ops qcom_geni_console_pops;
static const struct uart_ops qcom_geni_uart_pops;
static struct uart_driver qcom_geni_console_driver;
static struct uart_driver qcom_geni_uart_driver;
+static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS];
static void __qcom_geni_serial_cancel_tx_cmd(struct uart_port *uport);
static void qcom_geni_serial_cancel_tx_cmd(struct uart_port *uport);
@@ -163,32 +164,15 @@ static inline struct qcom_geni_serial_port *to_dev_port(struct uart_port *uport)
return container_of(uport, struct qcom_geni_serial_port, uport);
}
-static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS] = {
- [0] = {
- .uport = {
- .iotype = UPIO_MEM,
- .ops = &qcom_geni_uart_pops,
- .flags = UPF_BOOT_AUTOCONF,
- .line = 0,
- },
- },
- [1] = {
- .uport = {
- .iotype = UPIO_MEM,
- .ops = &qcom_geni_uart_pops,
- .flags = UPF_BOOT_AUTOCONF,
- .line = 1,
- },
- },
- [2] = {
- .uport = {
- .iotype = UPIO_MEM,
- .ops = &qcom_geni_uart_pops,
- .flags = UPF_BOOT_AUTOCONF,
- .line = 2,
- },
- },
-};
+static void qcom_geni_serial_port_init(void)
+{
+ for (int i = 0; i < GENI_UART_PORTS; i++) {
+ qcom_geni_uart_ports[i].uport.iotype = UPIO_MEM;
+ qcom_geni_uart_ports[i].uport.ops = &qcom_geni_uart_pops;
+ qcom_geni_uart_ports[i].uport.flags = UPF_BOOT_AUTOCONF;
+ qcom_geni_uart_ports[i].uport.line = i;
+ }
+}
static struct qcom_geni_serial_port qcom_geni_console_port = {
.uport = {
@@ -2048,6 +2032,8 @@ static int __init qcom_geni_serial_init(void)
{
int ret;
+ qcom_geni_serial_port_init();
+
ret = console_register(&qcom_geni_console_driver);
if (ret)
return ret;
--
2.34.1
Powered by blists - more mailing lists