From patchwork Wed Jul 10 22:16: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: 13729771 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 D195CC3DA41 for ; Wed, 10 Jul 2024 22:18:08 +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=i31BPpHnLaJ/rNDJ66yrZ8cgLwdnKqIGDV88VSFmL9M=; b=Ya7scIGD2dXHekUI4+Eiy4svvB +ITNcg8jM63fm+jNa0ZTK+mzPhJZOSfZg1TiA+5D49LfSNvw8PmWZoai1VfuEZErL30N3U8TP2sna JhYpFhubpGYZKZAitMgdfOrug19wd6mId8q2q/S6Ohh9G2zg3jVK+/O2qUYlebOc12z3q84lnlPoD OkZ+LPQurRGPOi00r0pL+xzMW/sHHCM3ovP7jJBg959IjraSZKikWXJvcPfityFPkUdPFe7iEl+SL lVHDYVM9eInYaSaQeO+rDnTzwMpuCYnXk7e0hmaHk2QGCaEH/6Q+qjh4z9JQYc41HlGY4N5FN1i+H PYix7UCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRfdL-0000000BuTg-2d0g; Wed, 10 Jul 2024 22:17:55 +0000 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRfc8-0000000BtrU-0RvL for linux-arm-kernel@lists.infradead.org; Wed, 10 Jul 2024 22:16:42 +0000 Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-6b73f7b855bso1608506d6.3 for ; Wed, 10 Jul 2024 15:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720649799; x=1721254599; 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=i31BPpHnLaJ/rNDJ66yrZ8cgLwdnKqIGDV88VSFmL9M=; b=Cfx4YaQMPV9gAglCT70WHicqm5J4H4V3Um6IMHnEL9hUeDu3bBTX3N9e5pthdkDAo5 cE+AyXpvNN4Xp4lgS3vbkc9+D0P+hIfIf7rA+xfF334AJW8iU9+BEp7xs2i2rAiZHV/i qAz8TQCRHGmDgf7CFhWOgztMfP60Owfcvt7wU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720649799; x=1721254599; 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=i31BPpHnLaJ/rNDJ66yrZ8cgLwdnKqIGDV88VSFmL9M=; b=ZSH36lWXdiwNpskzG+WTG7T98wGOJWTjgcCqYDK77nXRMp2Q6mweNU3hJsZ4divbo2 dPH1pMUsvir5kcRB+FlOqyKtYA7Dz6TRC3/n2XdaE80qaxYnaFEZwJ5Q81ukSoqgrKGT OgSqEkLE4vR642wsA2uKv0virGVSxPARvLPQBQHF18ujY68124DB3zR4IfaSvh434CV2 vQ8H01uEpGPDhG7hDnlEr1m2hCYj4YPbHl51r/Bw1XOQ0/J/FfUdDuegXox1D8XUFs2H yhapjlrdCvtLdPvOudJmIQHYUZuhfbYGdFyTVsKTkvPHdgsAacjZctfXAFjisDAbvxny WE7g== X-Forwarded-Encrypted: i=1; AJvYcCXpITdTRgrKmwVc69GZaQjHXNVKzO4CZzH6OMcyQEvVuFm/7BkXLhF11PUHz5QH3HQRFL3YZBAl6Ub61cl9U7gB4WaDp1qjK/HZ7dKA1LcLKVhHxR4= X-Gm-Message-State: AOJu0YxzhmFeWRWicM9m2vGdSdmNaO9iAQEA5XlcfxZgu2vuR8XZb4dw C/YADUZ/dq1vd/iY2IbS1UBB5X+Y1XDRAN57vyut9x5uUzCNPj6Rvf9k4mx7CA== X-Google-Smtp-Source: AGHT+IGbfaXkPyk4MDsNSx6d35fq97HqilT9H1mudUwc/uOzVRR+c/sXn3tlIfapfqJG9SCcL0HVUQ== X-Received: by 2002:a05:6214:246d:b0:6b2:c034:6aa3 with SMTP id 6a1803df08f44-6b61bf35eb5mr63873476d6.35.1720649798807; Wed, 10 Jul 2024 15:16:38 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b61ba04c16sm20182326d6.60.2024.07.10.15.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 15:16:38 -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 v3 03/12] PCI: brcmstb: Use common error handling code in brcm_pcie_probe() Date: Wed, 10 Jul 2024 18:16:17 -0400 Message-Id: <20240710221630.29561-4-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240710221630.29561-1-james.quinlan@broadcom.com> References: <20240710221630.29561-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240710_151640_190036_00313DE9 X-CRM114-Status: GOOD ( 13.17 ) 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 Fixes: bb610757fcd7 ("PCI: brcmstb: Use reset/rearm instead of deassert/assert") 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;