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: 13729757 X-Patchwork-Delegate: kw@linux.com Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (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 CF22F14AD3D for ; Wed, 10 Jul 2024 22:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720649802; cv=none; b=OG/KpimAKT/0TJP5lyUZGKubVjls51v2c6HZ51pmgmsXHq65ZDt8mTxKICwTkq2i3kETQEYiPS9fBzAQfMhkLw6vx3jpZSdj0a/puGBr0uKsJRVyIW6Yt0evqjOvaWT6XM3dwIk1vHUbI7ntDZh/zQ1yENwoM9z9VSbpHuyZpdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720649802; c=relaxed/simple; bh=XRgOzU2i9BV5tzE98YS0C6JD0NAIF8knb0DgdXZiuJk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type; b=ELgk+qlYJ0qfZzHOi0qC3FPJ24kSdmkHFa/4TpzgSEjKldaPmK1w0SNIhpBXRd7ruWIg9odJvWX+R4ONWQZPrbk6M+XAk2188FGkgvaLXs3qkuHyui0cO583pc8dFqfsPMr9RrBJgj0IOyyOLWx0xlkWLYWzA6oSp8CpwEhnn7E= 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=Qgof5Toe; arc=none smtp.client-ip=209.85.160.180 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="Qgof5Toe" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-447f0d20592so1129911cf.3 for ; Wed, 10 Jul 2024 15:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720649799; x=1721254599; 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=rrarskAw+WnHjsS4ZZNv0mTWR2kstqDB/9dLQ4kdPs4=; b=Qgof5Toe1AJGxGw9q1xvW1LlKWRFBRc+ndWhjBtpCgOl1MlBYQl2axPa3Y+UTTkOYC hA6dt4Jw5uloT6Mh5+cRX4MzfnbfquNrHa6DMJRoYC+wNylZ+uya9l8XhnDrp/qYTAOa kl4rIc5DZZ6FdGbKqUmFQYZORIDAFJyQJK8FA= 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=rrarskAw+WnHjsS4ZZNv0mTWR2kstqDB/9dLQ4kdPs4=; b=PknjXf7M+VXbDy8nwHk3/N1PiEeBY3xrAA5QT28D4CZCFTp6354fPAJmnPQksAcDKe q9s7iAAaR25e7cY7JozOE9RRucjuYSym1K33BYtppQeW/rTi+/eh6D/+6q8UuKKCuUAp CuhxV67wAf8IP15twpJyrHSKYq94Vudpn40dr59yzBSRDEUIQyHtTOAFI/5ScQG5RMC9 jFbphvll7GAjSiy343c9VcXRHWoQMHd3i3g9PMH3/k/upcGJke1nKaXIg9LC2d/cZ7rc LBVYEFxQUbcsOtDaaAOFuKoIHV6t4k5q7E1DzyLMwWbjxN8/DLXZMpTTqbrhy3wsdWLB oOTQ== X-Gm-Message-State: AOJu0Yz+hSeFjGhouI+6np5r0EzunRZv6U2BR/lcWaZhuIGeABScAxBG lCN/Or6dVQ2Fq/zP8HYMMqA519kUqcsBscfef46ghSDD+r2w+RnSv7TviIgz63qArBPD8HSX37y xO5Kjtr4bhVu74ALYXT44udEwlDJ1oSuw9r+8sTo7MgJWT1S+uHr7YCkXfpo04SOCiCs01JCv7E Wj+KTDlU6IsHPdcUbkfglxLAPE2IUjvG9kaKQFmDv4KRfTFkEy 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> 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 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;