From nobody Mon Apr 6 21:57:12 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 73C272C0F69; Wed, 18 Mar 2026 02:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773801629; cv=none; b=NXFv0j5t3LgUtwniHWocCYabUxMpNysgJW9hAhWYxs1t8JRU1iYncy9c+uU3xAIMUq/oqdIWZW5cCAVPrBk73ckPIh8Qit1xgxU5HPt3TqIPHbih+RVhNPhmCEwi+d21Z6J7Z0mGGcp86DPpufXL8U4Dqnrs1hlFZr2u7ELo9C0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773801629; c=relaxed/simple; bh=AA5x6JwA2opi1vXKCakUkc9F3VeKLsoO5cl71XDGl9U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hTy9nV1uSxdB7d36nxCD8eHfyjFVgBX8Mq+JBkNZ7HbD6idZnrm2jEQ2zslB+NWZxVma79AjHOoMkJnpbmiTSA3E/0LL+sS2TkIGsxVrRMc/JRyZjL+JK/p69xEZM7QDuzGEEEdT58ds85FWtvVSfy1nnO4E5Z4yOngmhQdPsDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: cc9aa704227311f1a21c59e7364eecb8-20260318 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:0cfe2427-3d59-4ad2-bf8a-2e540f18b346,IP:0,U RL:0,TC:0,Content:-25,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:89c9d04,CLOUDID:5d417bfb0956acf9f04223ba2d7b9988,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850|898,TC:nil,Content:0|15|50 ,EDM:5,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OS A:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: cc9aa704227311f1a21c59e7364eecb8-20260318 X-User: xiaopei01@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 288843384; Wed, 18 Mar 2026 10:40:17 +0800 From: Pei Xiao To: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, openbmc@lists.ozlabs.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Cc: Pei Xiao Subject: [PATCH v4 16/17] spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled() Date: Wed, 18 Mar 2026 10:40:06 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- drivers/spi/spi-zynq-qspi.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c index 5232483c4a3a..8c3975030d0a 100644 --- a/drivers/spi/spi-zynq-qspi.c +++ b/drivers/spi/spi-zynq-qspi.c @@ -661,7 +661,7 @@ static int zynq_qspi_probe(struct platform_device *pdev) goto remove_ctlr; } =20 - xqspi->pclk =3D devm_clk_get(&pdev->dev, "pclk"); + xqspi->pclk =3D devm_clk_get_enabled(&pdev->dev, "pclk"); if (IS_ERR(xqspi->pclk)) { dev_err(&pdev->dev, "pclk clock not found.\n"); ret =3D PTR_ERR(xqspi->pclk); @@ -670,36 +670,24 @@ static int zynq_qspi_probe(struct platform_device *pd= ev) =20 init_completion(&xqspi->data_completion); =20 - xqspi->refclk =3D devm_clk_get(&pdev->dev, "ref_clk"); + xqspi->refclk =3D devm_clk_get_enabled(&pdev->dev, "ref_clk"); if (IS_ERR(xqspi->refclk)) { dev_err(&pdev->dev, "ref_clk clock not found.\n"); ret =3D PTR_ERR(xqspi->refclk); goto remove_ctlr; } =20 - ret =3D clk_prepare_enable(xqspi->pclk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable APB clock.\n"); - goto remove_ctlr; - } - - ret =3D clk_prepare_enable(xqspi->refclk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable device clock.\n"); - goto clk_dis_pclk; - } - xqspi->irq =3D platform_get_irq(pdev, 0); if (xqspi->irq < 0) { ret =3D xqspi->irq; - goto clk_dis_all; + goto remove_ctlr; } ret =3D devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq, 0, pdev->name, xqspi); if (ret !=3D 0) { ret =3D -ENXIO; dev_err(&pdev->dev, "request_irq failed\n"); - goto clk_dis_all; + goto remove_ctlr; } =20 ret =3D of_property_read_u32(np, "num-cs", @@ -709,7 +697,7 @@ static int zynq_qspi_probe(struct platform_device *pdev) } else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) { ret =3D -EINVAL; dev_err(&pdev->dev, "only 2 chip selects are available\n"); - goto clk_dis_all; + goto remove_ctlr; } else { ctlr->num_chipselect =3D num_cs; } @@ -728,15 +716,11 @@ static int zynq_qspi_probe(struct platform_device *pd= ev) ret =3D 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; } =20 return ret; =20 -clk_dis_all: - clk_disable_unprepare(xqspi->refclk); -clk_dis_pclk: - clk_disable_unprepare(xqspi->pclk); remove_ctlr: spi_controller_put(ctlr); =20 @@ -758,9 +742,6 @@ static void zynq_qspi_remove(struct platform_device *pd= ev) struct zynq_qspi *xqspi =3D platform_get_drvdata(pdev); =20 zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET, 0); - - clk_disable_unprepare(xqspi->refclk); - clk_disable_unprepare(xqspi->pclk); } =20 static const struct of_device_id zynq_qspi_of_match[] =3D { --=20 2.25.1