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 E86A7283FE3; 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=bHT5sDZlt5u47DKLc3JtltU8GFs3FvaHNY7UGjBBAlLeQcIi/1Rnx/gDZaQCiuXZm91lqBBbF85I+HkkeXUZ2KXg6IeJUOSO+EetJs/Vbp2lCKyZk7pwTtuSzZU+PBhjsrvgslGqPjEJw5V97hMTAf4qNd9b5X2TBNcmsi5VgmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773885869; c=relaxed/simple; bh=lg7C9qW2QnqB/VfcMdst6CcxTTTc8G8tOzjqOik5gPM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cW/PDrW/vodMbscyQDqalQt1CZ6EtRn2D+sHL0bGLerW16XNw688u+sXX+/g0s8keaOfpZVVhUrHQWWJ/dfxzwRHK/cGfcaxTa2DL1eCpCZeuyxa1aQ0+qZLk6Vo+JyzXgxJ6ls96Mt2NRisOm23FVzURAHliDFiXimjJQYVSHc= 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: f1f59a80233711f1a21c59e7364eecb8-20260319 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:eaaaae9a-a5c7-4de2-aedf-1e0a176cf0cd,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:c402c4563c8dcd41f9f9f590a804b60b,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: f1f59a80233711f1a21c59e7364eecb8-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 1584200364; Thu, 19 Mar 2026 10:04:21 +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 06/17] spi: npcm-pspi: Simplify clock handling with devm_clk_get_enabled() Date: Thu, 19 Mar 2026 10:04:02 +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 the clock. This reduces boilerplate code and error handling, as the managed API automatically disables the clock when the device is removed or if probe fails. Remove the now-unnecessary clk_disable_unprepare() calls from the probe error path and the remove callback. Adjust error handling labels accordingly. Signed-off-by: Pei Xiao --- drivers/spi/spi-npcm-pspi.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c index e60b3cc398ec..ae7f9a70fbcf 100644 --- a/drivers/spi/spi-npcm-pspi.c +++ b/drivers/spi/spi-npcm-pspi.c @@ -361,27 +361,23 @@ static int npcm_pspi_probe(struct platform_device *pd= ev) goto out_host_put; } =20 - priv->clk =3D devm_clk_get(&pdev->dev, NULL); + priv->clk =3D devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "failed to get clock\n"); + dev_err(&pdev->dev, "failed to enable clock\n"); ret =3D PTR_ERR(priv->clk); goto out_host_put; } =20 - ret =3D clk_prepare_enable(priv->clk); - if (ret) - goto out_host_put; - irq =3D platform_get_irq(pdev, 0); if (irq < 0) { ret =3D irq; - goto out_disable_clk; + goto out_host_put; } =20 priv->reset =3D devm_reset_control_get(&pdev->dev, NULL); if (IS_ERR(priv->reset)) { ret =3D PTR_ERR(priv->reset); - goto out_disable_clk; + goto out_host_put; } =20 /* reset SPI-HW block */ @@ -391,7 +387,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) "npcm-pspi", priv); if (ret) { dev_err(&pdev->dev, "failed to request IRQ\n"); - goto out_disable_clk; + goto out_host_put; } =20 init_completion(&priv->xfer_done); @@ -415,15 +411,12 @@ static int npcm_pspi_probe(struct platform_device *pd= ev) =20 ret =3D devm_spi_register_controller(&pdev->dev, host); if (ret) - goto out_disable_clk; + goto out_host_put; =20 pr_info("NPCM Peripheral SPI %d probed\n", host->bus_num); =20 return 0; =20 -out_disable_clk: - clk_disable_unprepare(priv->clk); - out_host_put: spi_controller_put(host); return ret; @@ -435,7 +428,6 @@ static void npcm_pspi_remove(struct platform_device *pd= ev) struct npcm_pspi *priv =3D spi_controller_get_devdata(host); =20 npcm_pspi_reset_hw(priv); - clk_disable_unprepare(priv->clk); } =20 static const struct of_device_id npcm_pspi_match[] =3D { --=20 2.25.1