From nobody Tue Apr 7 19:16:23 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 1B0653B9DA4; Thu, 12 Mar 2026 09:29:34 +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=1773307778; cv=none; b=cFvdksWEihUFfXhHpGbupiUagsxhixl4xXezSccvwWNczg0ZwtEi+jGizNY+1Zyf03V42nFSC8uSu8SIjK+hUvDi1zDlojnU67PARy15z4ULzosi1VJH9e/8BUTrD8aaHVq4l46UxoFZa16agr4h1oa8SnSLR+vUdWF3YeTP5Es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773307778; c=relaxed/simple; bh=VCB4M+lEmfXyT9206dMOaN6u6sF7wUrvWJCpVj+1YI8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C84FFoWQOlVpsmIgAXzPWOIdD29WVn1Ze+WAZc5rgi9aw4zvHQhGHYAfhCMMQjrSwl2ia9vdwjI3ptSwD2MaKoOD3W/WwVMWbyqhj/rlrOwZRklgYhxm2b22m+frJzbnC0OW1JCUmglHOUpZClbgMpwNKrTvDpHMruLI+KVyqzc= 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: f60949f61df511f1a21c59e7364eecb8-20260312 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.11,REQID:24b8e357-a0f3-444f-95de-e2dd910a74f7,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:77fcc3ae681b67b7ce53c0dd2c43748c,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: f60949f61df511f1a21c59e7364eecb8-20260312 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 59810514; Thu, 12 Mar 2026 17:29:25 +0800 From: Pei Xiao To: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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 Cc: Pei Xiao Subject: [PATCH 13/17] spi: stm32: Use helper function devm_clk_get_enabled() Date: Thu, 12 Mar 2026 17:29:05 +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" devm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code. Signed-off-by: Pei Xiao --- drivers/spi/spi-stm32.c | 59 +++++++++++++---------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 8a7f5a10d4af..b347caeee0dc 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -2360,25 +2360,22 @@ static int stm32_spi_probe(struct platform_device *= pdev) int ret; =20 cfg =3D of_device_get_match_data(&pdev->dev); - if (!cfg) { - dev_err(&pdev->dev, "Failed to get match data for platform\n"); - return -ENODEV; - } + if (!cfg) + return dev_err_probe(&pdev->dev, -ENODEV, "Failed to get + match data for platform\n"); =20 device_mode =3D of_property_read_bool(np, "spi-slave"); - if (!cfg->has_device_mode && device_mode) { - dev_err(&pdev->dev, "spi-slave not supported\n"); - return -EPERM; - } + if (!cfg->has_device_mode && device_mode) + return dev_err_probe(&pdev->dev, -EPERM, "spi-slave not + supported\n"); =20 if (device_mode) ctrl =3D devm_spi_alloc_target(&pdev->dev, sizeof(struct stm32_spi)); else ctrl =3D devm_spi_alloc_host(&pdev->dev, sizeof(struct stm32_spi)); - if (!ctrl) { - dev_err(&pdev->dev, "spi controller allocation failed\n"); - return -ENOMEM; - } + if (!ctrl) + return dev_err_probe(&pdev->dev, -ENOMEM, "spi controller + allocation failed\n"); platform_set_drvdata(pdev, ctrl); =20 spi =3D spi_controller_get_devdata(ctrl); @@ -2409,32 +2406,19 @@ static int stm32_spi_probe(struct platform_device *= pdev) return ret; } =20 - spi->clk =3D devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(spi->clk)) { - ret =3D PTR_ERR(spi->clk); - dev_err(&pdev->dev, "clk get failed: %d\n", ret); - return ret; - } + spi->clk =3D devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(spi->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(spi->clk), "clk get failed: %d\= n", ret); =20 - ret =3D clk_prepare_enable(spi->clk); - if (ret) { - dev_err(&pdev->dev, "clk enable failed: %d\n", ret); - return ret; - } spi->clk_rate =3D clk_get_rate(spi->clk); - if (!spi->clk_rate) { - dev_err(&pdev->dev, "clk rate =3D 0\n"); - ret =3D -EINVAL; - goto err_clk_disable; - } + if (!spi->clk_rate) + return dev_err_probe(&pdev->dev, -EINVAL, "clk rate =3D 0\n"); =20 rst =3D devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); if (rst) { - if (IS_ERR(rst)) { + if (IS_ERR(rst)) ret =3D dev_err_probe(&pdev->dev, PTR_ERR(rst), "failed to get reset\n"); - goto err_clk_disable; - } =20 reset_control_assert(rst); udelay(2); @@ -2461,11 +2445,9 @@ static int stm32_spi_probe(struct platform_device *p= dev) dev_dbg(spi->dev, "one message max size %d\n", spi->t_size_max); =20 ret =3D spi->cfg->config(spi); - if (ret) { - dev_err(&pdev->dev, "controller configuration failed: %d\n", - ret); - goto err_clk_disable; - } + if (ret) + return dev_err_probe(&pdev->dev, "controller configuration + failed: %d\n", ret); =20 ctrl->auto_runtime_pm =3D true; ctrl->bus_num =3D pdev->id; @@ -2490,8 +2472,7 @@ static int stm32_spi_probe(struct platform_device *pd= ev) dev_info(&pdev->dev, "tx dma disabled\n"); spi->dma_tx =3D NULL; } else { - dev_err_probe(&pdev->dev, ret, "failed to request tx dma channel\n"); - goto err_clk_disable; + return dev_err_probe(&pdev->dev, ret, "failed to request tx dma channel= \n"); } } else { ctrl->dma_tx =3D spi->dma_tx; @@ -2579,8 +2560,6 @@ static int stm32_spi_probe(struct platform_device *pd= ev) err_dma_tx_release: if (spi->dma_tx) dma_release_channel(spi->dma_tx); -err_clk_disable: - clk_disable_unprepare(spi->clk); =20 return ret; } --=20 2.25.1