From patchwork Tue Jul 16 21:31:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13734973 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 7B9B8C3DA59 for ; Tue, 16 Jul 2024 21:33:24 +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:Content-Type:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Reply-To:MIME-Version: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8uvqDu2yfCIfsC/szHd8VLSTht0LJn4T/cgWnh+3KBc=; b=DkSt200JvjA3gnoSUc2jxzPEAe 4NlsSFYvDtKcXY9Sw4TwpRlREz+ITyeJtKm7GiuMwxGPX15crJyXeEOwtZi7eEDX0/ERkUIfYN2Ng DGqnvEsvtQgtgw+z9/LzXK8wQmgV8OQ5euI3th3XQ/XBR+bD7DNIHKBb1PjwFIzr20kTmr/eMss6X 6E6m5UXab/uCbnQr0SF8wwxG0bL8UDqHMH5it8FSxJsrMMj0eOMWMRSlXUnrH3wCHf83mfXyuHrc5 ECWQ0yGWHcC+q7YptXxIswz9PLVzt1gk0MVnLRXCPBXoY+FIHtvYv4oAxSmmHqJfBGHGM/Lg5JNDg HMGkIm1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTpnM-0000000BpqT-1jF2; Tue, 16 Jul 2024 21:33:12 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTpm2-0000000BpAQ-0lmO for linux-arm-kernel@lists.infradead.org; Tue, 16 Jul 2024 21:31:52 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-70af8128081so4108154b3a.1 for ; Tue, 16 Jul 2024 14:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1721165509; x=1721770309; 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=8uvqDu2yfCIfsC/szHd8VLSTht0LJn4T/cgWnh+3KBc=; b=IRMf2yfAmH6OO96cb3uXY+MentbEd3qIQs3zXYmDBPXV1wg/ImqUkxSWQmrmJKVJCo ydL3Oa1ctYlwah/KZUrvFktw2/fL806JznYlwnvWGShL4+gpcfB32DcCDjeEwWfVqlcE Vd4OE7AIjQevj8rZZ9DaFF2/zvqPaNSY/7f/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721165509; x=1721770309; 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=8uvqDu2yfCIfsC/szHd8VLSTht0LJn4T/cgWnh+3KBc=; b=LRzQ3lHzNkBaSqtZq6WMdHEo6xzzpXIjpRFwcNVcRJZIpvLdMQCbrb6nQzg9kh1lqP UpWUNFoMndpjbySujM3lutAr2YqghvEf1YKXP8DEZbcN6zM5K3wxzM6RUZ+A65UK9O+Y w9/484C5v7hlJjFAwkUXDspKB4jtFmV3BbLs30Q+3gqnKSsCIk2paiHGcPPa2sqmmK9z 45XWSKN3/On0ZZbrjyM3/rYDODh6nDMB80TpCCsC6tARRPQ+P8npnG+vEzY9L8Ev93N0 UaVR8iMY2o/Q4JKLblkfJTseEU3vCAfZv3DUWp2GVGXXwXTkl+zkn29vCYo5gHarfDY6 3pUw== X-Forwarded-Encrypted: i=1; AJvYcCUKqxwPj/lbVquse8xOJsUaTQOGobULCQT7ieOugLIYxYRAZpovhbWUs1vDHInvXAgBeeUGgLC9n70YG60Qna1KgorEAJGLpNORDo03qsXbUmgC2wA= X-Gm-Message-State: AOJu0YyQfn56xaLxaYt2/hDTvFZFgws3EhHkkfZAIlNxU8OgsjFBJWqN 1oqakS4tncDy/0GxHd8SzYvIIBjbAEZYEzBWwe3RpspzoNIEINt6aKAM/yMxMw== X-Google-Smtp-Source: AGHT+IHrThhlnzd8LBxiCzySjP0CZq2MynpmgH95NB6gd2UaS1mI0VKjiYx4eqSInRNbvNUaupsgWg== X-Received: by 2002:a05:6a00:1992:b0:70a:efd7:ada1 with SMTP id d2e1a72fcca58-70c1fbdd47amr3995520b3a.17.1721165509480; Tue, 16 Jul 2024 14:31:49 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b7eb9e20fsm6812828b3a.31.2024.07.16.14.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 14:31:48 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , 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 , 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 v4 03/12] PCI: brcmstb: Use common error handling code in brcm_pcie_probe() Date: Tue, 16 Jul 2024 17:31:18 -0400 Message-Id: <20240716213131.6036-4-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240716213131.6036-1-james.quinlan@broadcom.com> References: <20240716213131.6036-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240716_143150_272997_E3E9ABC7 X-CRM114-Status: GOOD ( 14.40 ) 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 Add a jump target (clk_out) so that a bit of exception handling can be better reused at the end of this function implementation. Signed-off-by: Jim Quinlan Reviewed-by: Stanimir Varbanov Reviewed-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index c08683febdd4..c257434edc08 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1613,31 +1613,30 @@ 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 = clk_prepare_enable(pcie->clk); + if (ret) { + dev_err(&pdev->dev, "could not enable clock\n"); + return ret; } ret = reset_control_reset(pcie->rescal); - if (ret) + if (ret) { dev_err(&pdev->dev, "failed to deassert 'rescal'\n"); + goto clk_out; + } ret = brcm_phy_start(pcie); if (ret) { reset_control_rearm(pcie->rescal); - clk_disable_unprepare(pcie->clk); - return ret; + goto clk_out; } ret = brcm_pcie_setup(pcie); @@ -1676,6 +1675,10 @@ static int brcm_pcie_probe(struct platform_device *pdev) return 0; +clk_out: + clk_disable_unprepare(pcie->clk); + return ret; + fail: __brcm_pcie_remove(pcie); return ret;