From nobody Mon Apr 6 17:27:47 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 2CA142773EC; Thu, 19 Mar 2026 02:04: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=1773885869; cv=none; b=aIHNjSjEuU+7MF5+yWJjlOTuInQSMrLt7NCL8S2YvJ2ORvL3sz+kIWCXKhBiEZnqlwqV9yz/B5OR/oI0BHQXTksjqAvJNWKdkR85vO/3AGxn3yXZLIUE3TSibV7SLNhnnbFIxAd9ZS+GC/cppbrXSXNe4qSU1tXCcU/rTBb5F6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773885869; c=relaxed/simple; bh=UGr/UfDp7PAXPnFKP89p5YXVHfZge/nu6LmGJiscxxc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MCuvHzTiGku4IV/NkDdj1pl1EDYZe8rY41n3KztBxEOBXGz3cM/UNJkixwMKuWmM7wblH3Cm25nH0uOKHhWr7dskqQAZ+Ijf3Q/MD/YU/7LPNvAoYil9evzUauWTY2FVERloFWqx2GthAEMW6LrvR+baGtwaimK6wr15hKTu+Po= 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: f099bdba233711f1a21c59e7364eecb8-20260319 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:4fff16d3-b475-434c-9921-59ad19d480ae,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:9603014fec71fbf5de70695698f811d6,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: f099bdba233711f1a21c59e7364eecb8-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 1832127847; Thu, 19 Mar 2026 10:04:19 +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 01/17] spi: axiado: Simplify clock management with devm_clk_get_enabled() Date: Thu, 19 Mar 2026 10:03:57 +0800 Message-Id: <52f7e0ebd2f0ece71929384444e1ae87506e5e2d.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 the "pclk" and "ref" clocks. This reduces boilerplate code and error handling, as the managed API automatically disables the clocks when the device is removed or if probe fails. Remove the now-unnecessary clk_disable_unprepare() calls from the probe error paths and the remove callback. Rename the error label from 'clk_dis_all' to 'err_disable_pm_runtime' to reflect that only PM runtime cleanup remains. Signed-off-by: Pei Xiao --- drivers/spi/spi-axiado.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/drivers/spi/spi-axiado.c b/drivers/spi/spi-axiado.c index dc55c55ae63c..d7918ea7c586 100644 --- a/drivers/spi/spi-axiado.c +++ b/drivers/spi/spi-axiado.c @@ -768,25 +768,15 @@ static int ax_spi_probe(struct platform_device *pdev) if (IS_ERR(xspi->regs)) return PTR_ERR(xspi->regs); =20 - xspi->pclk =3D devm_clk_get(&pdev->dev, "pclk"); + xspi->pclk =3D devm_clk_get_enabled(&pdev->dev, "pclk"); if (IS_ERR(xspi->pclk)) return dev_err_probe(&pdev->dev, PTR_ERR(xspi->pclk), - "pclk clock not found.\n"); + "Unable to enable APB clock.\n"); =20 - xspi->ref_clk =3D devm_clk_get(&pdev->dev, "ref"); + xspi->ref_clk =3D devm_clk_get_enabled(&pdev->dev, "ref"); if (IS_ERR(xspi->ref_clk)) return dev_err_probe(&pdev->dev, PTR_ERR(xspi->ref_clk), - "ref clock not found.\n"); - - ret =3D clk_prepare_enable(xspi->pclk); - if (ret) - return dev_err_probe(&pdev->dev, ret, "Unable to enable APB clock.\n"); - - ret =3D clk_prepare_enable(xspi->ref_clk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable device clock.\n"); - goto clk_dis_apb; - } + "Unable to enable device clock.\n"); =20 pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); @@ -815,7 +805,7 @@ static int ax_spi_probe(struct platform_device *pdev) irq =3D platform_get_irq(pdev, 0); if (irq <=3D 0) { ret =3D -ENXIO; - goto clk_dis_all; + goto err_disable_pm_runtime; } =20 ret =3D devm_request_irq(&pdev->dev, irq, ax_spi_irq, @@ -823,7 +813,7 @@ static int ax_spi_probe(struct platform_device *pdev) if (ret !=3D 0) { ret =3D -ENXIO; dev_err(&pdev->dev, "request_irq failed\n"); - goto clk_dis_all; + goto err_disable_pm_runtime; } =20 ctlr->use_gpio_descriptors =3D true; @@ -849,17 +839,14 @@ static int ax_spi_probe(struct platform_device *pdev) ret =3D spi_register_controller(ctlr); if (ret) { dev_err(&pdev->dev, "spi_register_controller failed\n"); - goto clk_dis_all; + goto err_disable_pm_runtime; } =20 return ret; =20 -clk_dis_all: +err_disable_pm_runtime: pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(xspi->ref_clk); -clk_dis_apb: - clk_disable_unprepare(xspi->pclk); =20 return ret; } @@ -875,15 +862,12 @@ static int ax_spi_probe(struct platform_device *pdev) static void ax_spi_remove(struct platform_device *pdev) { struct spi_controller *ctlr =3D platform_get_drvdata(pdev); - struct ax_spi *xspi =3D spi_controller_get_devdata(ctlr); =20 spi_unregister_controller(ctlr); =20 pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); =20 - clk_disable_unprepare(xspi->ref_clk); - clk_disable_unprepare(xspi->pclk); } =20 /** --=20 2.25.1