From patchwork Mon May 6 16:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13655721 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 C2D09C25B4F for ; Mon, 6 May 2024 16:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UwFUpwViV5FI6LiRhiUkKdgFPh6JVZjWitgZFjaY7Bc=; b=UU5Yn80jCEfpfB kNptl/miTVDag3f4ODuNttzeYOGO9I3fDqOWtHZM/JKyqGUumwRF0FRYW2m3XUXh4SBB16CWLf7DF yf9gj9aUXny09hMTFYAzOGwTXXfg5Alblp02zLlh8DcK2mbWBOGmvrUi6nvYaAUIR8ZwURdLTjWBQ bY36FSHF26Eoo2ThdKQbJTizcw2fASJvSfUF5zWp0+az0kt2xAOdKd9XONKsYjRUpATVNd/8zcXfP N8HWyEIjkgKYI8asB7WMlJdwUx4x7Q2VyofkapyiPl9OGYYIDGlo98spsvONT45kl02qvqrqBwP/j aKFc6H+b+Is4TnrCQWMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s410H-000000081Dc-3cVo; Mon, 06 May 2024 16:15:49 +0000 Received: from out-171.mta0.migadu.com ([91.218.175.171]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4106-0000000814q-1dyU for linux-arm-kernel@lists.infradead.org; Mon, 06 May 2024 16:15:40 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715012136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vtlPUzut99fgqzwIOlVSGdtokjNewldmjFQ9baMdh6A=; b=beKg6+up+zeyc8oCa+O2DfND2aDcOLe9OAGt/ipw2zvOqryyv9MZuXQ1PWKJEshAbUcNQk 9mz4D8Rl9/1ZBN38EBGquhMW0CZ9uI579Lcj1QEc1QGjp9bNJMgigGh3ZUUZTIVugu0ivX fQI57+BYBLoTFKdl82MjJYMmUk8lKkY= From: Sean Anderson To: Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , linux-pci@vger.kernel.org Cc: Michal Simek , Bjorn Helgaas , Thippeswamy Havalige , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sean Anderson , Bharat Kumar Gogada , Lorenzo Pieralisi , Michal Simek Subject: [PATCH v2 5/7] PCI: xilinx-nwl: Clean up clock on probe failure/removal Date: Mon, 6 May 2024 12:15:08 -0400 Message-Id: <20240506161510.2841755-6-sean.anderson@linux.dev> In-Reply-To: <20240506161510.2841755-1-sean.anderson@linux.dev> References: <20240506161510.2841755-1-sean.anderson@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240506_091538_802468_B8437F42 X-CRM114-Status: GOOD ( 12.99 ) 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 Make sure we turn off the clock on probe failure and device removal. Fixes: de0a01f52966 ("PCI: xilinx-nwl: Enable the clock through CCF") Signed-off-by: Sean Anderson --- (no changes since v1) drivers/pci/controller/pcie-xilinx-nwl.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c index c0a60cebdb2e..424cc5a1b4d1 100644 --- a/drivers/pci/controller/pcie-xilinx-nwl.c +++ b/drivers/pci/controller/pcie-xilinx-nwl.c @@ -779,6 +779,7 @@ static int nwl_pcie_probe(struct platform_device *pdev) return -ENODEV; pcie = pci_host_bridge_priv(bridge); + platform_set_drvdata(pdev, pcie); pcie->dev = dev; @@ -801,13 +802,13 @@ static int nwl_pcie_probe(struct platform_device *pdev) err = nwl_pcie_bridge_init(pcie); if (err) { dev_err(dev, "HW Initialization failed\n"); - return err; + goto err_clk; } err = nwl_pcie_init_irq_domain(pcie); if (err) { dev_err(dev, "Failed creating IRQ Domain\n"); - return err; + goto err_clk; } bridge->sysdata = pcie; @@ -817,11 +818,23 @@ static int nwl_pcie_probe(struct platform_device *pdev) err = nwl_pcie_enable_msi(pcie); if (err < 0) { dev_err(dev, "failed to enable MSI support: %d\n", err); - return err; + goto err_clk; } } - return pci_host_probe(bridge); + err = pci_host_probe(bridge); + +err_clk: + if (err) + clk_disable_unprepare(pcie->clk); + return err; +} + +static void nwl_pcie_remove(struct platform_device *pdev) +{ + struct nwl_pcie *pcie = platform_get_drvdata(pdev); + + clk_disable_unprepare(pcie->clk); } static struct platform_driver nwl_pcie_driver = { @@ -831,5 +844,6 @@ static struct platform_driver nwl_pcie_driver = { .of_match_table = nwl_pcie_of_match, }, .probe = nwl_pcie_probe, + .remove_new = nwl_pcie_remove, }; builtin_platform_driver(nwl_pcie_driver);