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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Sat, 2 Dec 2023 01:27:04 +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=SFwYHxU24LM47Wx7eKT7t91aTd5L+oJ//Tk/2jLWySA=; b=euaBkwaH4JkwfYUsiOJbB8lyo2DSGT3Pp19b0KD/ttzezvKzta83irEPVvdLDNDqfmUqZfeSeQGo3E7DBkHmoxmBltOtBuSU/IyDVpg/qVtFmCRC7Pj4vT70ri/7IX63PB/igZNrdU6zvg3Ig7deQBDy4r2WG/gWa99y0KJROavN2EbR6ToHKjUhlYs32DQD72egn8nCurnj4V5Kx0Raho1mkVKsHqMP/ciUuHWYlYeI0j9qnOSwpQxUKPZookA1a33aeiH6KRgjDMDXlil74II88BfSVyI7vI+4upXZ5qbMs24aMMFIHE+c/fpYEelPdtCpTWfZ84ItW8+XeXVHCA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hP60KBmfNMFnjfgi1NsdMQEhxrg1U9g4M9jo8A6E9qNb9kDA9lmalLgcqOL77+sm4L1FyYepuJiiMlqbGh8oGPY7NHfTpDpbmGmdKxXgPM9pZ503bdwRHi4ntmmhfSHrqDlCVFS9mRKXag7RmMqHShJavjjDb6MSdNOJsk8NKs3iW36He4ugQLtEjcT9U1SUfAJ11sl2xAvvxC6U/4nHaCFn/vsphczfKc1KB0VjM1aINSuoqZxYoFlufUBedqC9k/mZxAf2W5GQm6HUDl6pKTMF3EQok/G/3Q+f4mYAfWQfnTgClnJAdRUPkrKDUzfUjzi3PDfsf4PZ0zjAuiqjbg==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Sat, 02 Dec 2023 01:27:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHaJL6n1kPp1+DEXkyG3DA4rY4zlA==
  • Thread-topic: [PATCH v11 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 v11:
- Do not remove empty line between "goto fail;" and "continue;"
In v10:
- Added Roger's A-b tag.
In v9:
- New in v9
---
 xen/drivers/vpci/header.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index ec6c93eef6..e6a1d58c42 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -581,10 +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 +601,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 +616,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 +638,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®.