From patchwork Tue Feb 26 11:58:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10830027 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 8E31515AC for ; Tue, 26 Feb 2019 11:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 768152B08D for ; Tue, 26 Feb 2019 11:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 697EF2B606; Tue, 26 Feb 2019 11:58:38 +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=BAD_ENC_HEADER,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 095AD2B08D for ; Tue, 26 Feb 2019 11:58:38 +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: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:Cc:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hchVaLN55yfml9sJYohZGVIBoHS9FYCIu5f8HzV2y3Y=; b=kcGI8qDOFlHfhy ZsgEivGEWhlSqPb7AsPZDtoWj6rzuU7ESUHIsnCaH5ruQp3Z49Ld3qwtUgyXDECYHuAGknLC2exze QOIgVPy1Ph5zXa2tNCyDSsjuPRPHNj0RcvLX35RVKbCf34fBMMb9NbIqaDfyTjURJDsHHDqG6g0HR mfc+PzsXxcBKryOa+KsgVZ0Ef7MlTNXf1YaYlH9caOxv9gt4Y8OQsTjs2HBQzMZmm8Q2mkPu73sRk jN5W/GI66vFNfNW8MYx+PFBlHGUv67HSb4gG6hYmiMr5WKLJEbo/wWDNxXq2/f9NE+XtEhzjDf8Rw tOMn2WeqzeAnBNakNGlQ==; 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 1gybNY-0003OE-Ov; Tue, 26 Feb 2019 11:58:32 +0000 Received: from mail-eopbgr710073.outbound.protection.outlook.com ([40.107.71.73] helo=NAM05-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gybNV-0003Ng-4Q for linux-arm-kernel@lists.infradead.org; Tue, 26 Feb 2019 11:58:30 +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=kCIAgyc0dyZXGWnEL+YP+rbIulW9e2ZVM0504mRNcjk=; b=jwo5PdbcESNEStlwO4OnsaqD8HkF5xP9VzLBYtSQkfrcHKow0fomIT/HUdYpC2rB37H8iLd3ph/VL9aTU88aGjkhB4PiaoRreLHYGr5MDGmLENkjkMxN4NR6U3ZOMSa0zwwcDg1JP3ANliyHzw2f2tprEu+NLGi7P3pA59yX2ac= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB3989.namprd03.prod.outlook.com (20.177.126.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.14; Tue, 26 Feb 2019 11:58:26 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1cca:e5f5:d31d:1e5c]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1cca:e5f5:d31d:1e5c%5]) with mapi id 15.20.1643.019; Tue, 26 Feb 2019 11:58:26 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: [PATCH 4/5] PCI: dwc: use devm_pci_alloc_host_bridge() to simplify the code Thread-Topic: [PATCH 4/5] PCI: dwc: use devm_pci_alloc_host_bridge() to simplify the code Thread-Index: AQHUzcqUjIgD4+38S0qkh/9pYJbfpg== Date: Tue, 26 Feb 2019 11:58:26 +0000 Message-ID: <20190226195127.72dd45e0@xhacker.debian> References: <20190226194806.34fc23b5@xhacker.debian> In-Reply-To: <20190226194806.34fc23b5@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: TY2PR02CA0024.apcprd02.prod.outlook.com (2603:1096:404:56::36) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; 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: 6d1780f7-b5fe-43e5-5e9a-08d69be1b730 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:BYAPR03MB3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BeOkeRFDa5SYALcNu7Yni7i2FrwJ40xDssTctuqWb2kixORyODh0CxsLLNcCYJt4ot0qnCMrORJj6WRFVA8jdkOaxwk77igI0/FLUy9F9EqIZrn00ZO/pma7j0Bay7IXetOssG+4zjHYJ0NDHMftMVJ+15fNjwyftBgv5KWDoWiBE2mhM9m1zaJNDhIu45ZteM29oWNynuaAXW/gwAhFEOFHnwypZgVXBAH9OhYPxVWJWqoZNRar2ubdA3D/vJqrDu8w= x-microsoft-antispam-prvs: x-forefront-prvs: 096029FF66 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(366004)(396003)(39860400002)(199004)(189003)(1076003)(72206003)(26005)(6436002)(6486002)(316002)(2501003)(52116002)(6116002)(3846002)(486006)(25786009)(102836004)(76176011)(186003)(476003)(2906002)(11346002)(5660300002)(105586002)(446003)(256004)(14444005)(106356001)(6512007)(9686003)(68736007)(71200400001)(71190400001)(7736002)(305945005)(86362001)(8936002)(2201001)(478600001)(81156014)(81166006)(50226002)(8676002)(99286004)(6506007)(66066001)(110136005)(386003)(53936002)(14454004)(97736004)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB3989; 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) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: CDF2Eb3t5XEfjMfBj38gDfJwblxdU6dA3ZynGw+181JZ/92Y1+lAGJULyrN2IrceuYfAeRdVr0aabkdsTWk9KezZF3susuMA8AqU5fKkxNdJ6Ik/+FRT+jJalTzvPRaHwC6AYYoRPoU4G9Pc5N5DbthEePR6SG+uLjRp0fdi8vffIZZNcEau8Tx47tIuTSQoZh2FpzB5R2ro0L8hL+VE6xOMK3+v53RR98w7Iw/nnGxVUY9rlmtirTixhRXE4xe/kJ5OlPoaF9NeghgwGpirShl5nS0k1Q0pZhOcOUxR3TIbb1QDscyqN8QAUNnwnOY7Kj34nAbntM5d6qaT9SwBYrcw1WOw0yvuzFaX2qiiH/K/do96LJcWJheG1MmCc7tVU4oVShyV4MZENAQtnTyl6vIa1qhrpJbBAOwarpzXHqo= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d1780f7-b5fe-43e5-5e9a-08d69be1b730 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Feb 2019 11:58:23.8473 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB3989 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190226_035829_178373_90C6370F X-CRM114-Status: GOOD ( 12.14 ) 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: , 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 --- .../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 66569d0f3ab9..4831c12fee93 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -357,7 +357,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; @@ -368,7 +368,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) { @@ -412,8 +412,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; } } @@ -424,8 +423,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; } } @@ -435,8 +433,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; } } @@ -459,14 +456,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, @@ -475,7 +472,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; } } @@ -515,8 +512,6 @@ int dw_pcie_host_init(struct pcie_port *pp) err_free_msi: if (IS_ENABLED(CONFIG_PCI_MSI) && !pp->ops->msi_host_init) dw_pcie_free_msi(pp); -error: - pci_free_host_bridge(bridge); return ret; }