Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3479351rwb; Mon, 5 Sep 2022 12:26:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR7i99APyX1tsSoxiMlnBzVeplM+D+/oY5pgDum6pZ9TuoFCNsyHlc7E1kQxcZG3Kj0Co6Nm X-Received: by 2002:a17:902:dac8:b0:174:cf17:6e87 with SMTP id q8-20020a170902dac800b00174cf176e87mr39626772plx.129.1662405999357; Mon, 05 Sep 2022 12:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662405999; cv=none; d=google.com; s=arc-20160816; b=fjid4J/MnBiQnRWlA+j0c+ywiJUyBeH9wzti6ZHubSme6tkUQQha8Q3nj1hvPH0xds G7AmAnLgML6I6j/6e3XPd0xjOGFq161xdXCGSjgPuQFeC28ukpl7n3Te/d2NV2CR/EYY weCmbTupK95AW27LWuJiTOIFEj1hykjMTWNNbKXyD3aSHfAaYubrloecbwHqvLe1ZL+6 zQJ4Kfiui4SjvXqyjiD/6+QMqVD75ijIRmQswQkvuFMKkFDT1Rcbuu8vnwVoqsBfY6PF 0RNoqptVfbeXLrQsy3g80cmKgxYSh2QIp52gyTmRS7c8vGloDZPEKsd56XYe0IXpkYgf riTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d4QIFOBdBI4V7sEpNFXZ7kKkp7Etx1Tx692D09Tj02A=; b=MpvXJ5UHCGvuAXH83M1FqG5YHLpwuLR4kLImiwxwsI25MdMo0ZR7uAH7Qq3UkfqB2M 549Zv8zdPqAsAY4YavYcrMGFTT996hI00qBDICGXtL9HNUlhg6Bh6sFhDRYCgexlu9s3 ZV42k7QenmNlKl3AbSzHQVY+2p8iaWbCJ+ykH5DzVrtxeqi6LkHZMemqrBwm5Zttrvu5 op+gfB+kSLTzZWxStqDRhPXFGn28psIX5KJ6mzw82FzEp8QgPdpHel8kmCXLvdGwBZfZ pDjIdmCCEYGd1woV6yjzLe4S6IWjP90L6Sn/SS3Qs6awZ8ebpB1qzvXfY/phhYj3H42m biFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rUxGWg3e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a636901000000b0043496fe5d82si408489pgc.657.2022.09.05.12.26.27; Mon, 05 Sep 2022 12:26:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rUxGWg3e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbiIETZb (ORCPT + 99 others); Mon, 5 Sep 2022 15:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbiIETZS (ORCPT ); Mon, 5 Sep 2022 15:25:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 376981D31A; Mon, 5 Sep 2022 12:25:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C4AD561469; Mon, 5 Sep 2022 19:25:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4594CC433D6; Mon, 5 Sep 2022 19:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662405916; bh=57jshmal4TifwCJhJwupFxar74e24FF1+DL9zAhrS5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUxGWg3ezE9iIUy2FENdwgwYONsygNkGTOVZlZVZL9ItoHzrQxHwefODWbouAZEl7 iE+prkF6c1Yp+K1xtYMUrVD1WMye+SPoAHhrBA6ZXSH89Z23gl2FW1GRLwo0mAh8x+ qfqNLXdHffKLS7qJah25bhHYQ6IprtWBF6JVVzJg5/DrZz+juUlYXlJlFGRp7EF6FH coPfjOyhN0BXcu9Cq8SIT5z45szPlyXp2c5hOT9qNabz4mjqOlmI1Z+hB6NLeuPzhY LXBVTTghhB3muVM7vpKs8mAsf2gCV66I0apOGleltS22hrXBlzSgd4uhPfsATkuZRT 4wANWTGTWapyg== Received: by pali.im (Postfix) id F2CBD7D7; Mon, 5 Sep 2022 21:25:15 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Russell King , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Thomas Petazzoni , Mauri Sandberg Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 5/7] PCI: mvebu: Cleanup error handling in mvebu_pcie_probe() Date: Mon, 5 Sep 2022 21:23:08 +0200 Message-Id: <20220905192310.22786-6-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220905192310.22786-1-pali@kernel.org> References: <20220718202843.6766-1-maukka@ext.kapsi.fi> <20220905192310.22786-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move cleanup calls to error labels. This simplify error handling when registering of some port fails. Signed-off-by: Pali Rohár --- Changes in v3: * New patch --- drivers/pci/controller/pci-mvebu.c | 59 ++++++++++++++---------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index d9e46bd7a4ec..9986dd486680 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -1856,18 +1856,14 @@ static int mvebu_pcie_probe(struct platform_device *pdev) if (IS_ERR(port->base)) { dev_err(dev, "%s: cannot map registers\n", port->name); port->base = NULL; - mvebu_pcie_powerdown(port); - continue; + goto err_port_down; } ret = mvebu_pci_bridge_emul_init(port); if (ret < 0) { dev_err(dev, "%s: cannot init emulated bridge\n", port->name); - devm_iounmap(dev, port->base); - port->base = NULL; - mvebu_pcie_powerdown(port); - continue; + goto err_base_unmap; } if (port->error_irq > 0 || port->intx_irq > 0) { @@ -1875,11 +1871,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) if (ret) { dev_err(dev, "%s: cannot init irq domain\n", port->name); - pci_bridge_emul_cleanup(&port->bridge); - devm_iounmap(dev, port->base); - port->base = NULL; - mvebu_pcie_powerdown(port); - continue; + goto err_bridge_cleanup; } } @@ -1891,15 +1883,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) if (ret) { dev_err(dev, "%s: cannot register error interrupt handler: %d\n", port->name, ret); - if (port->intx_irq_domain) - irq_domain_remove(port->intx_irq_domain); - if (port->rp_irq_domain) - irq_domain_remove(port->rp_irq_domain); - pci_bridge_emul_cleanup(&port->bridge); - devm_iounmap(dev, port->base); - port->base = NULL; - mvebu_pcie_powerdown(port); - continue; + goto err_domain_remove; } } @@ -1911,17 +1895,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) if (ret) { dev_err(dev, "%s: cannot register intx interrupt handler: %d\n", port->name, ret); - if (port->error_irq > 0) - devm_free_irq(dev, port->error_irq, port); - if (port->intx_irq_domain) - irq_domain_remove(port->intx_irq_domain); - if (port->rp_irq_domain) - irq_domain_remove(port->rp_irq_domain); - pci_bridge_emul_cleanup(&port->bridge); - devm_iounmap(dev, port->base); - port->base = NULL; - mvebu_pcie_powerdown(port); - continue; + goto err_free_error_irq; } } @@ -2015,6 +1989,29 @@ static int mvebu_pcie_probe(struct platform_device *pdev) mvebu_pcie_setup_hw(port); mvebu_pcie_set_local_dev_nr(port, 1); mvebu_pcie_set_local_bus_nr(port, 0); + + continue; + +err_free_error_irq: + if (port->error_irq > 0) + devm_free_irq(dev, port->error_irq, port); + +err_domain_remove: + if (port->intx_irq_domain) + irq_domain_remove(port->intx_irq_domain); + + if (port->rp_irq_domain) + irq_domain_remove(port->rp_irq_domain); + +err_bridge_cleanup: + pci_bridge_emul_cleanup(&port->bridge); + +err_base_unmap: + devm_iounmap(dev, port->base); + port->base = NULL; + +err_port_down: + mvebu_pcie_powerdown(port); } bridge->sysdata = pcie; -- 2.20.1