From nobody Mon Apr 6 17:29:05 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 177D938AC83; Thu, 19 Mar 2026 02:04:33 +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=1773885877; cv=none; b=MGxoiV+SGFby9rNpNv0XPGz9al8caCSO2C/WLRS2lu5yShAMgchWw98T71tkzVNxV5t+caE2o4suxIBFMMCQSdxIyxL8CTl9dm6NwisdF4dtyg0HIYRdzAg4YQZmgFTvDBlAvGq1xh132Wz2nP468nIj8E/gwRUymIeZd3zkzQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773885877; c=relaxed/simple; bh=AA5x6JwA2opi1vXKCakUkc9F3VeKLsoO5cl71XDGl9U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RgfsD+v9+8KWzDxbDt17Gu62hFPUxpPDa1/a6A/xmbrOqJWShfPKu10yMKse8jkpb7Mg2hzMMoYfbcNpI2fc50RFhGjm1tWOWPyG3PvbntwNj8v0zROxsF/+yLLDi18KPA9ATNWVKPcwabD/C0OhxgBtcONm4C9+xd/kVhNRFwM= 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: f53d6042233711f1a21c59e7364eecb8-20260319 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:323db549-b3c6-4d11-b239-5a1ba307fd89,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:eca3d75a252039a9697e1dd9214aca52,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: f53d6042233711f1a21c59e7364eecb8-20260319 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 785175677; Thu, 19 Mar 2026 10:04:26 +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, broonie@kernel.org, Frank.Li@nxp.com, amelie.delaunay@foss.st.com Cc: Pei Xiao Subject: [PATCH v5 16/17] spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled() Date: Thu, 19 Mar 2026 10:04:12 +0800 Message-Id: <880f8c2a66ab027cfe4ed57092036d9819b9285b.1773885292.git.xiaopei01@kylinos.cn> 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