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

[PATCH v10 06/17] vpci/header: rework exit path in init_bars


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Thu, 12 Oct 2023 22:09:16 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; 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=zMLvoJ8oLwDDcIwwFQCmO1G6TxLtjEG3z/3WmRJCPC8=; b=cj6d/YyEeNdAMACZm8lGafBreEklzgsBPYRNlhhdENjWWgpx4wj53dSSWYNk3efWF6sIiAjZPKZE8dDFbSULrzrHssSSm1oUydkEmRV2+eO4rvrO5QRRAwaZ1Uq8TlQPRm/itiYsZyUhj3r/f0MssnQz0dC9dBNiAR0fFYXnAZ5aPx5JsmdoQoBEtZt4C8r8xcbP7b9otzt9uU2kq95qmprcY3imipkKtJxyhkRmypEstuHD96NdijnTcIUS4EKvuwYIQ7Rmzc5zUbGaf3I6gOdbThuVSnngm1lw4iv7F8qgylAMC7NcsS5aoWez6jY2DRXHf4Gj4oUqiu54fLxdvg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h63PPNZt3JfrvOJ4ZdEAarqk8/nnxRj5O2mdCGhqm5fqHBavlVR/wmtDTUMLKcH/LHJtk1u3ok2LZXo3daIt8H83FULAEec96x/1X56riIRTBQdMazCjDT+lg2UFXyksgYFngsJkDJ77XzxUHRlOsBFv/RNfwuo4Ti53Z93g3QR0w+E7fNwY49GcQXzcb4RuHH4O36KohAZZG4KygfO7WdLLVELCVC4hTb5IzSw9D5tK4CchBCC2wLIUmxlGxP2PztHM8hlq93HV8i0Q2fHofuad2eQZ6B+lN0L+9N4+nUAbC8EpQn8cmQP7GgkWeUIbfbAjcVTmtoesco6yBjHNrA==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 12 Oct 2023 22:09:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZ/Vi9WQzEUKFClEWKXSReXuWjGg==
  • Thread-topic: [PATCH v10 06/17] vpci/header: rework exit path in init_bars

Introduce "fail" label in init_bars() function to have the centralized
error return path. This is the pre-requirement for the future changes
in this function.

This patch does not introduce functional changes.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
Suggested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
--
In v10:
- Added Roger's A-b tag.
In v9:
- New in v9
---
 xen/drivers/vpci/header.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 176fe16b9f..33db58580c 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -581,11 +581,7 @@ static int cf_check init_bars(struct pci_dev *pdev)
             rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg,
                                    4, &bars[i]);
             if ( rc )
-            {
-                pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-                return rc;
-            }
-
+                goto fail;
             continue;
         }
 
@@ -604,10 +600,7 @@ static int cf_check init_bars(struct pci_dev *pdev)
         rc = pci_size_mem_bar(pdev->sbdf, reg, &addr, &size,
                               (i == num_bars - 1) ? PCI_BAR_LAST : 0);
         if ( rc < 0 )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
 
         if ( size == 0 )
         {
@@ -622,10 +615,7 @@ static int cf_check init_bars(struct pci_dev *pdev)
         rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg, 4,
                                &bars[i]);
         if ( rc )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
     }
 
     /* Check expansion ROM. */
@@ -647,6 +637,10 @@ static int cf_check init_bars(struct pci_dev *pdev)
     }
 
     return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
+
+ fail:
+    pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
+    return rc;
 }
 REGISTER_VPCI_INIT(init_bars, VPCI_PRIORITY_MIDDLE);
 
-- 
2.42.0

 


Rackspace

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