@@ -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;
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@quicinc.com> --- drivers/tty/serial/qcom_geni_serial.c | 40 +++++++++------------------ 1 file changed, 13 insertions(+), 27 deletions(-)