From patchwork Wed Jul 31 22:28:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1B97C3DA7F for ; Wed, 31 Jul 2024 22:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=J83Zv5BEREvIAUqofWicGKSSTCWUlV2zoywp7ximAEQ=; b=Tjc1K7ijXZY84HFPPkEN6XSYo9 cLlZG+Z+tv7jPAEjLb9GKrZowU6iH5mjs8Kgo95+tRcE8BdT9GlIwgE6HYPGolruA27sjDQbS6YMk RfVBTY0JNQVJtv8ZVQ+uU80/FybnsmPb1qxYQBPofQq2IMKjhoiK1YLmULwGOG3QNjmWaNBI8imMU cN3ipZXSES2Y7WJgKcDZVb1/SgFtKqIVEHwMoYzvfMjRr7TZFOfKzfo+HLyQ2/+SciXxMaro0bWDZ YaUpz+nJ96Ayv2SczOdyiWl4KoPf73QT22INtOuB4WsI4qBlfmITnrWGOdww0ifOS4rOhAwjDtMCX LD3XfE9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZHtN-00000002j7L-1cbo; Wed, 31 Jul 2024 22:33:57 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZHoG-00000002hQO-1Hjd for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 22:28:41 +0000 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-709428a9469so3354212a34.3 for ; Wed, 31 Jul 2024 15:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464919; x=1723069719; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=J83Zv5BEREvIAUqofWicGKSSTCWUlV2zoywp7ximAEQ=; b=acL1ovu95yrdT0/xDtMR/aUPdw3UQFRqTD7x0TLhZTreYhHF1f0i9p5gz/6g2Oe5Ie Y/jy2vdxq+OvuL0A9R2TMcDpPqSbP/YpYzy5ttYqXZg7t3M4AgOjt6VQBvvzCy8+gM8p lmfISBI+c8JvP45USZjAeCV5PQ4kBffYKM/Ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464919; x=1723069719; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J83Zv5BEREvIAUqofWicGKSSTCWUlV2zoywp7ximAEQ=; b=kFh618CNnL7KzumZoNi2I81BfoEIMrsrdA7edRvVym25Ay2efgN6pwZPWZtmBC5R4A rRqdzIt4kclKiw/3svR3Q2XkPJ+it4h9rdRxEqo1vRZxoOapurRzgfGL53ifFjT8WuK+ ysxCQ7CC29IjFg9f6dpb3PVdf0IwJujdxOEJ7SzFRv6FQY5staSpgxDRpUIoigbMfbDL 5+JbXPrpMpzsV/7cQLefioWHXCUxHR8sIJG6hDvTyk6tq8H9N3TfYUL1Q353Yap+vO7N CkXT2fDzlnMtrBC1RR9eSUcCcPrSXIVwco+f2XJPyba6Vap4GLPqYci2uE7zhr6r3Bnc i1gA== X-Forwarded-Encrypted: i=1; AJvYcCWAyDFX9Z3Wnf/ZUTjFBQGameruaDIXniZdBJ4pFx2DQvOJVI08QQf0c1da4oSlFxCcoVZ5SmAhWZcCSFudhkxl340jUGEB7txYvgNTMSB9j9L/ndA= X-Gm-Message-State: AOJu0YwuPLyXSr1ru/8k7hVgwhjxbGrB3AF2pJirwWzllDxUYXByYdax 3LLB1azk3OwtjHqu/REfLG97D+0+ifjmWi6051k8GPds3bfng9lm8CaDSvZTWQ== X-Google-Smtp-Source: AGHT+IHIP5WdHy/ihYegTa0DgMvLcOxm3pAjIV58KNh8m6EZyfzcAcqiHesM2kvbR33Jn8f0UeLyNA== X-Received: by 2002:a05:6830:6c0e:b0:709:44dc:dde7 with SMTP id 46e09a7af769-7096b8054afmr717661a34.9.1722464918795; Wed, 31 Jul 2024 15:28:38 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:38 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 03/12] PCI: brcmstb: Use common error handling code in brcm_pcie_probe() Date: Wed, 31 Jul 2024 18:28:17 -0400 Message-Id: <20240731222831.14895-4-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_152840_489843_6D4B2140 X-CRM114-Status: GOOD ( 15.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org o Move the clk_prepare_enable() below the resource allocations. o Move the clk_prepare_enable() out of __brcm_pcie_remove() but add it to the end of brcm_pcie_remove(). o Add a jump target (clk_disable_unprepare) so that a bit of exception handling can be better reused at the end of this function implementation. o Use dev_err_probe() where it makes sense. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index c08683febdd4..7595e7009192 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1473,7 +1473,6 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) dev_err(pcie->dev, "Could not stop phy\n"); if (reset_control_rearm(pcie->rescal)) dev_err(pcie->dev, "Could not rearm rescal reset\n"); - clk_disable_unprepare(pcie->clk); } static void brcm_pcie_remove(struct platform_device *pdev) @@ -1484,6 +1483,7 @@ static void brcm_pcie_remove(struct platform_device *pdev) pci_stop_root_bus(bridge->bus); pci_remove_root_bus(bridge->bus); __brcm_pcie_remove(pcie); + clk_disable_unprepare(pcie->clk); } static const int pcie_offsets[] = { @@ -1613,31 +1613,26 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->ssc = of_property_read_bool(np, "brcm,enable-ssc"); - ret = clk_prepare_enable(pcie->clk); - if (ret) { - dev_err(&pdev->dev, "could not enable clock\n"); - return ret; - } pcie->rescal = devm_reset_control_get_optional_shared(&pdev->dev, "rescal"); - if (IS_ERR(pcie->rescal)) { - clk_disable_unprepare(pcie->clk); + if (IS_ERR(pcie->rescal)) return PTR_ERR(pcie->rescal); - } + pcie->perst_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "perst"); - if (IS_ERR(pcie->perst_reset)) { - clk_disable_unprepare(pcie->clk); + if (IS_ERR(pcie->perst_reset)) return PTR_ERR(pcie->perst_reset); - } - ret = reset_control_reset(pcie->rescal); + ret = clk_prepare_enable(pcie->clk); if (ret) - dev_err(&pdev->dev, "failed to deassert 'rescal'\n"); + return dev_err_probe(&pdev->dev, ret, "could not enable clock\n"); + + ret = reset_control_reset(pcie->rescal); + if (dev_err_probe(&pdev->dev, ret, "failed to deassert 'rescal'\n")) + goto clk_disable_unprepare; ret = brcm_phy_start(pcie); if (ret) { reset_control_rearm(pcie->rescal); - clk_disable_unprepare(pcie->clk); - return ret; + goto clk_disable_unprepare; } ret = brcm_pcie_setup(pcie); @@ -1654,10 +1649,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) msi_np = of_parse_phandle(pcie->np, "msi-parent", 0); if (pci_msi_enabled() && msi_np == pcie->np) { ret = brcm_pcie_enable_msi(pcie); - if (ret) { - dev_err(pcie->dev, "probe of internal MSI failed"); + if (dev_err_probe(pcie->dev, ret, "probe of internal MSI failed")) goto fail; - } } bridge->ops = pcie->type == BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops; @@ -1678,6 +1671,9 @@ static int brcm_pcie_probe(struct platform_device *pdev) fail: __brcm_pcie_remove(pcie); +clk_disable_unprepare: + clk_disable_unprepare(pcie->clk); + return ret; }