[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1] xen/drivers: ns16550: Fix the return logic for pci_uart_config()


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Fri, 7 Jul 2023 12:35:18 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+toFDaRSBfCS38slBFO2OskFD6oNPXp01PvW1Wj0lNU=; b=jkzUihk9dvtwyRgF2w4Ue9dMNT7C2tL93qGhokz8C5/Hi9n7EgR4fAehouir0msu23PFfawSCDD6MVHybBLqJyqPS0LOR/NStNBMBRdVCrRryQ7AHDM7WM0yKmXcmZi2cwP+BxdYDrjsDKELxIb8Pla5iZtzcPmwqS60gRC7TTV6Aymf6jjLVCZ5O8pvbpwvykV2QtTIu382fQ0Crg/ZJzLWoPKmMZrcgPZP/shFIkG1pOxxHttqDDJdXhycv/cGjRw42U5o/CBXmRdWq7kMX7CzOJpzc/h7unqMMYm2CcaLDjNdtWRidh9xoT6NcQTTSqJEGs9expDZpfK9Nhcq4Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SxfzvCKG+Zx440jCHSSo0SbU6Xb615XwCPLyQvWDqLMIPGwpDQv2z7IV7TBfwcQHQebULrNSKtGaZuw5JEcTtUtpBMyfKeiYSIebhEiRNlGPYO9vU3MS0xhIiqwJ8CJE2ty7T2ZrSTB8DPLRUStqDHuv3LKOtTyt4e5CxJSirWEPmFmRPs42QF3HfIfX2o3RwaIFf6y4h2n5fDPIamJwFKinIpvD36PQfiIm0TlTqo5yRlLqoHoEzL4XXD28bVFMqAL0u5CJU5UikwWqESsjzMB0HffB4KtOIqTxP+6KmHUDKSPaRLk25mKys8l344l0zfkUoGRUANLgWLHgRvjupQ==
  • Cc: <sstabellini@xxxxxxxxxx>, <stefano.stabellini@xxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <george.dunlap@xxxxxxxxxx>, <jbeulich@xxxxxxxx>, <julien@xxxxxxx>, <wl@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Delivery-date: Fri, 07 Jul 2023 11:35:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

pci_uart_config() should return 0 when it probes the correct uart device and
sets the properties of "struct ns16550". Else, it should return -ENODEV.
Also before returning -ENODEV, it should restore the value of uart->io_base.

The callers should check if pci_uart_config() has returned 0 (for success) or
not.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
This was based on a discussion "[XEN v4 04/11] xen/drivers: ns16550: Use 
paddr_t for io_base/io_size"

https://patchew.org/Xen/20230321140357.24094-1-ayan.kumar.halder@xxxxxxx/20230321140357.24094-5-ayan.kumar.halder@xxxxxxx/

 xen/drivers/char/ns16550.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 212a9c49ae..5a35498a06 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -1342,13 +1342,9 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, 
unsigned int idx)
         }
     }
 
-    if ( !skip_amt )
-        return -1;
-
-    /* No AMT found, fallback to the defaults. */
     uart->io_base = orig_base;
 
-    return 0;
+    return -ENODEV;
 }
 
 static void enable_exar_enhanced_bits(const struct ns16550 *uart)
@@ -1527,13 +1523,13 @@ static bool __init parse_positional(struct ns16550 
*uart, char **str)
 #ifdef CONFIG_HAS_PCI
         if ( strncmp(conf, "pci", 3) == 0 )
         {
-            if ( pci_uart_config(uart, 1/* skip AMT */, uart - ns16550_com) )
+            if ( !pci_uart_config(uart, 1/* skip AMT */, uart - ns16550_com) )
                 return true;
             conf += 3;
         }
         else if ( strncmp(conf, "amt", 3) == 0 )
         {
-            if ( pci_uart_config(uart, 0, uart - ns16550_com) )
+            if ( !pci_uart_config(uart, 0, uart - ns16550_com) )
                 return true;
             conf += 3;
         }
@@ -1642,13 +1638,17 @@ static bool __init parse_namevalue_pairs(char *str, 
struct ns16550 *uart)
         case device:
             if ( strncmp(param_value, "pci", 3) == 0 )
             {
-                pci_uart_config(uart, 1/* skip AMT */, uart - ns16550_com);
-                dev_set = true;
+                if ( !pci_uart_config(uart, 1/* skip AMT */, uart - 
ns16550_com) )
+                    dev_set = true;
+                else
+                    return false;
             }
             else if ( strncmp(param_value, "amt", 3) == 0 )
             {
-                pci_uart_config(uart, 0, uart - ns16550_com);
-                dev_set = true;
+                if ( !pci_uart_config(uart, 0, uart - ns16550_com) )
+                    dev_set = true;
+                else
+                    return false;
             }
             break;
 
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.