From patchwork Thu Aug 15 22:57: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: 13765263 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 DF344C531DE for ; Thu, 15 Aug 2024 23:01:20 +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=oFI8arKdNkGnCtRjmqMHmug8W/dZT+YtS9MCra9oudk=; b=HNzt2+myYY0dyixhB8Dwl5KRlg XQQbdQ70G36xVaBHhBwLwX8KM2uRgM8BCrU3UO9S4TSnOM8Ai+345zxMff05jJnMKnkm2zW0iFGxT yj2mDSAqmTO46LAQzOt0s3OeUnyaO3bBf46l+azE3NI+BZTiGQmbCyseXP/R6GDQ0gTCWvq9wFHy4 mKhisvcAh6F7oFnSC4FArqzam2H1H9KXkh0PDNKOaFY8Pxt3RNpNFCDxS0OBYb74LUxPfLBHWRjzR sLThEjtKVBjIwR4vzniRLwCi/5/jop0HsZAod8DeG40qDnxA3mFkPt7o8Li7KVfPG32WjgYNc5iem KnCVpNig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sejSv-0000000BF9a-2Sp4; Thu, 15 Aug 2024 23:01:09 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sejPp-0000000BE2g-0gUt for linux-arm-kernel@lists.infradead.org; Thu, 15 Aug 2024 22:57:58 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2d3c098792bso1104230a91.1 for ; Thu, 15 Aug 2024 15:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723762675; x=1724367475; 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=oFI8arKdNkGnCtRjmqMHmug8W/dZT+YtS9MCra9oudk=; b=B+qjiBS92topSOloV1I+BTEe2yC6pZkOBgYbXPbDe/y33y8ZjejX5XgVOcEFQzwRSq tOzttBHpdjtg6jQomnMzubmTC4CjxeZ0d9M/0SrNYL6gWD09e9rACJb2FSwU+Dw/x00d IojpPeOVt7oBfYFcn9+YCvN2d+k6kBZP5iz5M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723762675; x=1724367475; 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=oFI8arKdNkGnCtRjmqMHmug8W/dZT+YtS9MCra9oudk=; b=OFMcNJBpgChbBjQMZWUtV0IXGJf2xxFPPrK82MlHc5kOPOFFpno/MZA/nh5pk9ZWFj RYM0fsD4mJbw338cPMFQwdsl60H02dCzLmTb7pHUJwBpufAJhBHDAdbjZYQVI3qj/6to 6cmNzTsFFomy/fMyLGSwfmoD0rv7TGFs6qaU4vmUQjDtu3Lf2kUSTkL4zT+H91bgsMB7 4P0b07ZRYSkNYfwOJiE5FSwiaONV9o6ZubXi6vuQxs1/jN5BSOa3R05tkbbfDdU3CUHA Tx+j3QqeUYfI8VWzRlDjOe/gXYUQ4FlnKwq83OmlqMkxGylzQKvBFBQMZK7gt6Eg1BTX oDQA== X-Forwarded-Encrypted: i=1; AJvYcCW4iFU5wxY/K7X5Qrkc9NiooqKblRnV1vx/itzDUg9zOPbOJEZRMoxe3xA21z4FuVpnFsdkfhZvzKXn4o7RZnKmAU+D9TQ3/cyIPOa2hzOxkukkOzk= X-Gm-Message-State: AOJu0YwjXHah3oQw7ajj2yNpAng1E5FnwmJQO9p6xDTrkSPtwXKgPa8+ t8CCaTpnXzY4rzbskRfpd2QUKuui8oZkbKBCeG02VLjdjpr9DtCdbmKlNIy3NQ== X-Google-Smtp-Source: AGHT+IEUS/2XIAaK/sG/bTFILt7iLNTiWV/caijt7nP5Wuvf8TQyR8eT31jxKpyY6JZ2oBbAi6rwug== X-Received: by 2002:a17:90a:bc81:b0:2c8:3f5:37d2 with SMTP id 98e67ed59e1d1-2d3dfc75e41mr1338644a91.20.1723762675007; Thu, 15 Aug 2024 15:57:55 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d3e2e6b2d1sm373997a91.18.2024.08.15.15.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 15:57:54 -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 v6 04/13] PCI: brcmstb: Use common error handling code in brcm_pcie_probe() Date: Thu, 15 Aug 2024 18:57:17 -0400 Message-Id: <20240815225731.40276-5-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240815225731.40276-1-james.quinlan@broadcom.com> References: <20240815225731.40276-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240815_155757_229281_43531B75 X-CRM114-Status: GOOD ( 12.97 ) 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 Refactor the error handling in the bottom half of the probe function for readability. The invocation of clk_prepare_enable() is moved lower in the function and this simplifies a couple of return paths. dev_err_probe() is also used when it is apt. Signed-off-by: Jim Quinlan Reviewed-by: Manivannan Sadhasivam Reviewed-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index c08683febdd4..790a149f6581 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1613,25 +1613,23 @@ 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 (ret) { + clk_disable_unprepare(pcie->clk); + return dev_err_probe(&pdev->dev, ret, "failed to deassert 'rescal'\n"); + } ret = brcm_phy_start(pcie); if (ret) { @@ -1678,6 +1676,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) fail: __brcm_pcie_remove(pcie); + return ret; }