From patchwork Mon Mar 18 09:57:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10857157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E92D1575 for ; Mon, 18 Mar 2019 09:57:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DA8929316 for ; Mon, 18 Mar 2019 09:57:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 614A92931A; Mon, 18 Mar 2019 09:57:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF95B29316 for ; Mon, 18 Mar 2019 09:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FJCgbHaqZdndz8ErL70569xGzXWTv6MPeuK4XdDmvpY=; b=a/keuwhGcbjM76 0MMoZqkb8b70e75MgYOtbXE6QgZfhcaluYZY9WDyXfjASEHRw0teyAIC853GnGHu3iQ8sWW7Sv9hA RC/5I5FdmNbn+gKrXZifn518HBSIz+/1v8/BmmiAdLrarvP4G4EB77qawaLwvRH6RpRgl2TAKzj4I REsoGEw9zwUBDx+Kkof3yt5NOgSJ/ZRLlGduk3aJ81DC456ExHvLygfk0VfvifNT+CNuHU6Z+ipEY oTMj+UIuMnHTEI7M4r25miVEjA2oDisjUr719Iy4ZjrL1qw3NukLPuhaX1wa/8j4LizfYoWrZhbSC KtN6fADNsEcFeiXLr8sQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5p1V-0002ga-48; Mon, 18 Mar 2019 09:57:37 +0000 Received: from mail-cys01nam02on0628.outbound.protection.outlook.com ([2a01:111:f400:fe45::628] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5p1R-0002dT-Pa for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 09:57:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MfZNa/BIRYhv/l35s63hd8lYRfM5oD9vfKkc+5UeD4k=; b=JiIs3T9Kj+ApW1ZflERY+FI5N7VOHYfDGsMzP3M7J0fZhnpGAd7Nxw4BLWFB21G8PKeJN3kaQxZdo+ZAjBJTIeWFkHyLnjQIKhuay9Z6Y2Cr2n1fFN1vfMozHAi72uXHVDW3LIvDVLAcy/QJuN8A1st2TpyRjFDRI4L75cuOaIw= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB3512.namprd03.prod.outlook.com (52.135.213.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Mon, 18 Mar 2019 09:57:29 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1a8:1bc4:174b:472b]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1a8:1bc4:174b:472b%2]) with mapi id 15.20.1709.015; Mon, 18 Mar 2019 09:57:29 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas Subject: [PATCH v3 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code Thread-Topic: [PATCH v3 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code Thread-Index: AQHU3XD/ghaIsUq3jEigJqiYRMMPzA== Date: Mon, 18 Mar 2019 09:57:28 +0000 Message-ID: <20190318175005.7bfaec27@xhacker.debian> References: <20190318174415.74fd25a5@xhacker.debian> In-Reply-To: <20190318174415.74fd25a5@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [199.33.119.15] x-clientproxiedby: TYAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:404:15::13) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e7655bff-c393-486c-096a-08d6ab882197 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:BYAPR03MB3512; x-ms-traffictypediagnostic: BYAPR03MB3512: x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(366004)(396003)(376002)(39850400004)(199004)(189003)(6506007)(386003)(102836004)(6346003)(26005)(76176011)(54906003)(52116002)(99286004)(86362001)(316002)(53936002)(6436002)(9686003)(6512007)(110136005)(5660300002)(66066001)(14444005)(256004)(1076003)(71200400001)(71190400001)(81156014)(6486002)(105586002)(106356001)(8676002)(81166006)(3846002)(6116002)(446003)(97736004)(11346002)(2906002)(4326008)(186003)(25786009)(7736002)(305945005)(72206003)(478600001)(68736007)(8936002)(14454004)(486006)(476003)(50226002)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB3512; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:0; MX:1; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: u7Ca3+VTu+mxCuRkfcl5eT7HwmQ8ocjzxelESWSufor4akKaKswSQ8IXHd00zUqtm/HYX98BzRUo15HfqBB0GXvU1lryXghJnDLxNTy4USbdQ04FJPT9W1SkwIEpiN/xQ7jWzUjGVvh7dY4c25DXLhGGyAbYFaoCyuwW/4C+dsocC8wP+x5nDqQdTbHGPSAlnrPgmx/dujCy3Hkx1WiAKOdx8LcNvhNAvrbbmXChBR+ZQiUsf1HPMCaqcrwjI0sy8yZqByCfkYYEwCfBVMiJOmuR8H/uOKHBvy+E/+88rRFL4Ss0XePSUbZhwr6I0Y/MS3/oAMMxCzKrdCOLZdV5Jjhe4Z49fZIqQuR4X0H23t0KXHFo1OXPsxORafUwy81E0anMKAYg5L7vFnOQhYoDDBGBBkULVx41heVhXuo0sEU= Content-ID: <029917FE50189E4AA5B5516964D21C93@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7655bff-c393-486c-096a-08d6ab882197 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 09:57:28.8583 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB3512 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_025733_842974_FAF02383 X-CRM114-Status: GOOD ( 12.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_pci_alloc_host_bridge() to simplify the error code path. Signed-off-by: Jisheng Zhang Acked-by: Gustavo Pimentel --- .../pci/controller/dwc/pcie-designware-host.c | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 585080699675..68a9dac23b1b 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -358,7 +358,7 @@ int dw_pcie_host_init(struct pcie_port *pp) dev_err(dev, "Missing *config* reg space\n"); } - bridge = pci_alloc_host_bridge(0); + bridge = devm_pci_alloc_host_bridge(dev, 0); if (!bridge) return -ENOMEM; @@ -369,7 +369,7 @@ int dw_pcie_host_init(struct pcie_port *pp) ret = devm_request_pci_bus_resources(dev, &bridge->windows); if (ret) - goto error; + return ret; /* Get the I/O and memory ranges from DT */ resource_list_for_each_entry_safe(win, tmp, &bridge->windows) { @@ -413,8 +413,7 @@ int dw_pcie_host_init(struct pcie_port *pp) resource_size(pp->cfg)); if (!pci->dbi_base) { dev_err(dev, "Error with ioremap\n"); - ret = -ENOMEM; - goto error; + return -ENOMEM; } } @@ -425,8 +424,7 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg0_base, pp->cfg0_size); if (!pp->va_cfg0_base) { dev_err(dev, "Error with ioremap in function\n"); - ret = -ENOMEM; - goto error; + return -ENOMEM; } } @@ -436,8 +434,7 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg1_size); if (!pp->va_cfg1_base) { dev_err(dev, "Error with ioremap\n"); - ret = -ENOMEM; - goto error; + return -ENOMEM; } } @@ -460,14 +457,14 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->num_vectors == 0) { dev_err(dev, "Invalid number of vectors\n"); - goto error; + return -EINVAL; } } if (!pp->ops->msi_host_init) { ret = dw_pcie_allocate_domains(pp); if (ret) - goto error; + return ret; if (pp->msi_irq) irq_set_chained_handler_and_data(pp->msi_irq, @@ -476,7 +473,7 @@ int dw_pcie_host_init(struct pcie_port *pp) } else { ret = pp->ops->msi_host_init(pp); if (ret < 0) - goto error; + return ret; } } @@ -517,8 +514,6 @@ int dw_pcie_host_init(struct pcie_port *pp) if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled() && !pp->ops->msi_host_init) dw_pcie_free_msi(pp); -error: - pci_free_host_bridge(bridge); return ret; }