This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 1dfc39432d120735651658d23bd33815140ea889
Author: Brijesh Thakkar <[email protected]>
AuthorDate: Thu Oct 22 18:02:23 2026 +0530

    drivers/serial/uart_pci_16550: Don't abort probe at the first unconfigured 
port
    
    pci_u16550_probe() walks the ports of the card starting at port 0 and
    returns -ENODEV as soon as no UARTn instance is configured for the
    current port.  A configuration that only uses a later port of a
    multi-port card (e.g. only UART1 as port 1 of a two-port card) therefore
    never reaches the configured port.
    
    Skip unconfigured ports with continue instead, and return -ENODEV only
    if no port of the device was registered, which keeps the behavior for a
    card none of whose ports is configured.
    
    Assisted-by: Claude:claude-sonnet-5-5
    Signed-off-by: Brijesh Thakkar <[email protected]>
---
 drivers/serial/uart_pci_16550.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/uart_pci_16550.c b/drivers/serial/uart_pci_16550.c
index 598440888f4..8f493d65a98 100644
--- a/drivers/serial/uart_pci_16550.c
+++ b/drivers/serial/uart_pci_16550.c
@@ -669,6 +669,7 @@ static int pci_u16550_probe(FAR struct pci_device_s *dev)
   size_t                              i;
   uint8_t                             port;
   uint8_t                             ports;
+  unsigned int                        registered = 0;
   bool                                mmio = false;
   int                                 ret;
 
@@ -736,11 +737,11 @@ static int pci_u16550_probe(FAR struct pci_device_s *dev)
           priv = NULL;
         }
 
-      /* Not found */
+      /* Not configured: skip this port, others may still be configured */
 
       if (udev == NULL)
         {
-          return -ENODEV;
+          continue;
         }
 
       /* Device already registered */
@@ -765,9 +766,13 @@ static int pci_u16550_probe(FAR struct pci_device_s *dev)
         {
           return ret;
         }
+
+      registered++;
     }
 
-  return OK;
+  /* Fail only if no port of this device is configured */
+
+  return registered > 0 ? OK : -ENODEV;
 }
 
 /*****************************************************************************

Reply via email to