Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: uniphier: Simplify clock handling with devm_clk_get_enabled()

Replace devm_clk_get() followed by clk_prepare_enable() with
devm_clk_get_enabled() for the clock. This removes the need for
explicit clock enable and disable calls, as the managed API automatically
handles clock disabling on device removal or probe failure.

Remove the now-unnecessary clk_disable_unprepare() calls from the probe
error path and the remove callback. Adjust error labels accordingly.

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Link: https://patch.msgid.link/b2deeefd4ef1a4bce71116aabfcb7e81400f6d37.1775546948.git.xiaopei01@kylinos.cn
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pei Xiao and committed by
Mark Brown
fdca270f baa1cb25

+4 -14
+4 -14
drivers/spi/spi-uniphier.c
··· 666 666 } 667 667 priv->base_dma_addr = res->start; 668 668 669 - priv->clk = devm_clk_get(&pdev->dev, NULL); 669 + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL); 670 670 if (IS_ERR(priv->clk)) { 671 671 dev_err(&pdev->dev, "failed to get clock\n"); 672 672 ret = PTR_ERR(priv->clk); 673 673 goto out_host_put; 674 674 } 675 675 676 - ret = clk_prepare_enable(priv->clk); 677 - if (ret) 678 - goto out_host_put; 679 - 680 676 irq = platform_get_irq(pdev, 0); 681 677 if (irq < 0) { 682 678 ret = irq; 683 - goto out_disable_clk; 679 + goto out_host_put; 684 680 } 685 681 686 682 ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler, 687 683 0, "uniphier-spi", priv); 688 684 if (ret) { 689 685 dev_err(&pdev->dev, "failed to request IRQ\n"); 690 - goto out_disable_clk; 686 + goto out_host_put; 691 687 } 692 688 693 689 init_completion(&priv->xfer_done); ··· 712 716 if (IS_ERR_OR_NULL(host->dma_tx)) { 713 717 if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) { 714 718 ret = -EPROBE_DEFER; 715 - goto out_disable_clk; 719 + goto out_host_put; 716 720 } 717 721 host->dma_tx = NULL; 718 722 dma_tx_burst = INT_MAX; ··· 762 766 host->dma_tx = NULL; 763 767 } 764 768 765 - out_disable_clk: 766 - clk_disable_unprepare(priv->clk); 767 - 768 769 out_host_put: 769 770 spi_controller_put(host); 770 771 return ret; ··· 770 777 static void uniphier_spi_remove(struct platform_device *pdev) 771 778 { 772 779 struct spi_controller *host = platform_get_drvdata(pdev); 773 - struct uniphier_spi_priv *priv = spi_controller_get_devdata(host); 774 780 775 781 if (host->dma_tx) 776 782 dma_release_channel(host->dma_tx); 777 783 if (host->dma_rx) 778 784 dma_release_channel(host->dma_rx); 779 - 780 - clk_disable_unprepare(priv->clk); 781 785 } 782 786 783 787 static const struct of_device_id uniphier_spi_match[] = {