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: 13734958 X-Patchwork-Delegate: kw@linux.com Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6403A143899 for ; Tue, 16 Jul 2024 21:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721165512; cv=none; b=Mrv+ircAGhKpUVumG/XAVFRgJ+4Xdg+tJt7mSMz8CRxsKaQRrMVOIEQtePBEPHzUdYUQ55/qn+QtDekMwtFK25KcMWKYXBSLaRnK+VIbRG2Ib1AiA8RAmrkOUxp21oFhWbPLP3xLWsLxn7fkuckYHrOQaZXnRiSIu1dKUbhnt6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721165512; c=relaxed/simple; bh=0dO0s/V4/6bj7Abxgc0ycBeFBC2aiP9ykYKxFMU3Joc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type; b=Glv6SJyaqcEYLnz/F0Y7b583fKjjtRc8q17qFPHCePm5njewJ8FaHNA+cszO2Yevj5epHgfCVKLYmEWL214TFK5DrAWisvFV/WioMA1FyLl8mnBi+9YldAiFuprJ8juqBGgBeOp19S3jtIa4jZZIXPGBgVa38HPVmVCvHOGPSrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=YZg80Y3X; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="YZg80Y3X" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-70af4868d3dso4625006b3a.3 for ; Tue, 16 Jul 2024 14:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1721165510; x=1721770310; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=hvtMInEmllyEMhRLrGuGnSRjnvC9TD2FUH6hIu5KfQg=; b=YZg80Y3XMhBB9Q2LrY80rLPOeVeTDtQz0v7ZZlyl1TkQ+znqomXUdbd2Dp5jFD4W5q UAtjC9ecBv8vEhuIDUkBFeXg1hnuzg94M+LRps+5XiLRejhMmV8LRyYa+ryJ3zmPeU6b TrLOndbCPd+eEjd9fqrwXahPD4ANEdbwMua00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721165510; x=1721770310; 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=hvtMInEmllyEMhRLrGuGnSRjnvC9TD2FUH6hIu5KfQg=; b=m8mwqL6Q7D/RMlJ0gnYjthWtAzO26CzaMkcZCxFDfgLIIZ+lzzYU5ZjecPpXXXl1CP d4FzjjBlEsOzsk6g88v1q6ClvxCv6kh7dQvradoBCvVMiwJGu3S0+KNGbkOlMuG5s7z6 kB8oc+1OrGFyNue0CqA8p7zLzJicrDEjlsnzrzMXePJhOPy2+PRNy1J5HOn2bk4Oz8sQ rOWj+L6jQiQDQiR3fqroKJCjU4+LJTQVXr5O4vyTnrmqZgK4pThsA4kntu2ADhyHI6v3 yz4msQ3uZviI6w5XoanSIFO9VMY4oR9vZzLxoKFlJMlWC91Ebm+4L4rQJLngb0iU4J11 h44g== X-Gm-Message-State: AOJu0YxWwe8bgF27VuTQqAmY3w4sKKWemDemODLrVNapJwxpD1kRg9Xc SJvtXhLgTZEDgZ4+iT/vDNCbPNI42ZTi2CeOeV/CHISX19ePGra1x9CLEQP0LUqDVEQo5bTPA9E 1GyUogaus0hBjRuHcR2IpUZ9AzaMfcPIKq7gX8/ofE68P/gSZonpFBPjAGUJSUt+pdo7s7WbvmQ rBsPd8IW6d/aXgsZXe2FWk/n2N0RGj2MFRlCeWFZ3CRyrGlA== 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> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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;