From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C89943AC0F0 for ; Wed, 13 May 2026 19:34:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778700865; cv=none; b=q8fHmI4yU18rJj8+O4badtWLrWW4woGb41v0aE5cEGHfkY4SxhBfo0xovQfAosFuSrS5ePfZWWrzoC8Qv4zxjyjLX1IiLbXIaYr9tiWj0lkqHlujs1Ge/9qyejs1rgdxuvxRqxw40A9+uSPceQ2IxOj2Mg80piXc1FzpuSFJHKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778700865; c=relaxed/simple; bh=7BQZJB3qArvvD0BDGlb7xQ+eSCEOi+/KY6OEbPJ++OU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DvQnlxo1Wn3EbMM6wNUkjidvHiTtMFpnQqtkb7grQ5C+CLkTHEsAsiH1fKyq5RerXk1u1oHI5/Ypy7Q2GCWhPzLDbp7kWBR/zDGX4KIyNDTJ9F9iU+tEJQNSB2wQ9WhqgpL3+TOguN/RaFn+ege+GSy19gaIKY5dcDfYKxuY9pM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oTRk1f1a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oTRk1f1a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07AEBC2BCB7; Wed, 13 May 2026 19:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778700865; bh=7BQZJB3qArvvD0BDGlb7xQ+eSCEOi+/KY6OEbPJ++OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oTRk1f1ayrU0JcB/dit/N2DEkjRXi32xVsLKYz1TyFesCA3WS9SEF+Pb1V3+JnQUt zEZicb4Rq9RSERtwHEOzfaPSqz0yZPw0OaCO1F8+OXF+Qz/ZGmptb+0OLKHpBy/HDe O4rvOiCONjR6RvTUuOAbGcY86qmIFmhn9NqtKH9e4MydkHtWYlChQTPr7ZWgIXhKys FjuFpGXfwJCgO1dXpRWkefkQ5bonFFSg4T5G1F4MozQzXhhFcPvodEEud+fsq/k947 Nlp66Noh3TLQ1xYPyK3bxaX6qSKy2wGq2kLuz6Crt4+Y0klglAK7n0faEw9UxVexNG Hjs8kQviW3Owg== From: Sasha Levin To: stable@vger.kernel.org Cc: Pei Xiao , Michal Simek , Mark Brown , Sasha Levin Subject: [PATCH 6.1.y 4/5] spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled() Date: Wed, 13 May 2026 15:34:19 -0400 Message-ID: <20260513193420.3938432-4-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260513193420.3938432-1-sashal@kernel.org> References: <2026051203-regain-crablike-8461@gregkh> <20260513193420.3938432-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Pei Xiao [ Upstream commit 1f8fd9490e3184e9a2394df2e682901a1d57ce71 ] Replace devm_clk_get() followed by clk_prepare_enable() with devm_clk_get_enabled() for both "pclk" and "ref_clk". This removes the need for explicit clock enable and disable calls, as the managed API automatically disables the clocks on device removal or probe failure. Remove the now-unnecessary clk_disable_unprepare() calls from the probe error paths and the remove callback. Simplify error handling by jumping directly to the remove_ctlr label. Signed-off-by: Pei Xiao Acked-by: Michal Simek Link: https://patch.msgid.link/24043625f89376da36feca2408f990a85be7ab36.1775555500.git.xiaopei01@kylinos.cn Signed-off-by: Mark Brown Stable-dep-of: c9c012706c9f ("spi: zynq-qspi: fix controller deregistration") Signed-off-by: Sasha Levin --- drivers/spi/spi-zynq-qspi.c | 42 ++++++------------------------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c index c933254e6d319..695ded977b911 100644 --- a/drivers/spi/spi-zynq-qspi.c +++ b/drivers/spi/spi-zynq-qspi.c @@ -379,21 +379,10 @@ static int zynq_qspi_setup_op(struct spi_device *spi) { struct spi_controller *ctlr = spi->controller; struct zynq_qspi *qspi = spi_controller_get_devdata(ctlr); - int ret; if (ctlr->busy) return -EBUSY; - ret = clk_enable(qspi->refclk); - if (ret) - return ret; - - ret = clk_enable(qspi->pclk); - if (ret) { - clk_disable(qspi->refclk); - return ret; - } - zynq_qspi_write(qspi, ZYNQ_QSPI_ENABLE_OFFSET, ZYNQ_QSPI_ENABLE_ENABLE_MASK); @@ -659,7 +648,7 @@ static int zynq_qspi_probe(struct platform_device *pdev) goto remove_ctlr; } - xqspi->pclk = devm_clk_get(&pdev->dev, "pclk"); + xqspi->pclk = devm_clk_get_enabled(&pdev->dev, "pclk"); if (IS_ERR(xqspi->pclk)) { dev_err(&pdev->dev, "pclk clock not found.\n"); ret = PTR_ERR(xqspi->pclk); @@ -668,36 +657,24 @@ static int zynq_qspi_probe(struct platform_device *pdev) init_completion(&xqspi->data_completion); - xqspi->refclk = devm_clk_get(&pdev->dev, "ref_clk"); + xqspi->refclk = devm_clk_get_enabled(&pdev->dev, "ref_clk"); if (IS_ERR(xqspi->refclk)) { dev_err(&pdev->dev, "ref_clk clock not found.\n"); ret = PTR_ERR(xqspi->refclk); goto remove_ctlr; } - ret = clk_prepare_enable(xqspi->pclk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable APB clock.\n"); - goto remove_ctlr; - } - - ret = clk_prepare_enable(xqspi->refclk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable device clock.\n"); - goto clk_dis_pclk; - } - xqspi->irq = platform_get_irq(pdev, 0); if (xqspi->irq < 0) { ret = xqspi->irq; - goto clk_dis_all; + goto remove_ctlr; } ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq, 0, pdev->name, xqspi); if (ret != 0) { ret = -ENXIO; dev_err(&pdev->dev, "request_irq failed\n"); - goto clk_dis_all; + goto remove_ctlr; } ret = of_property_read_u32(np, "num-cs", @@ -707,7 +684,7 @@ static int zynq_qspi_probe(struct platform_device *pdev) } else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) { ret = -EINVAL; dev_err(&pdev->dev, "only 2 chip selects are available\n"); - goto clk_dis_all; + goto remove_ctlr; } else { ctlr->num_chipselect = num_cs; } @@ -725,15 +702,11 @@ static int zynq_qspi_probe(struct platform_device *pdev) ret = devm_spi_register_controller(&pdev->dev, ctlr); if (ret) { dev_err(&pdev->dev, "devm_spi_register_controller failed\n"); - goto clk_dis_all; + goto remove_ctlr; } return ret; -clk_dis_all: - clk_disable_unprepare(xqspi->refclk); -clk_dis_pclk: - clk_disable_unprepare(xqspi->pclk); remove_ctlr: spi_controller_put(ctlr); @@ -755,9 +728,6 @@ static void zynq_qspi_remove(struct platform_device *pdev) struct zynq_qspi *xqspi = platform_get_drvdata(pdev); zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET, 0); - - clk_disable_unprepare(xqspi->refclk); - clk_disable_unprepare(xqspi->pclk); } static const struct of_device_id zynq_qspi_of_match[] = { -- 2.53.0