Skip to content

Commit 3e272e6

Browse files
Pei Xiaogregkh
authored andcommitted
spi: uniphier: Simplify clock handling with devm_clk_get_enabled()
[ Upstream commit fdca270 ] 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> Stable-dep-of: 0245435 ("spi: uniphier: fix controller deregistration") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c9577d9 commit 3e272e6

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

drivers/spi/spi-uniphier.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -666,28 +666,24 @@ static int uniphier_spi_probe(struct platform_device *pdev)
666666
}
667667
priv->base_dma_addr = res->start;
668668

669-
priv->clk = devm_clk_get(&pdev->dev, NULL);
669+
priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
670670
if (IS_ERR(priv->clk)) {
671671
dev_err(&pdev->dev, "failed to get clock\n");
672672
ret = PTR_ERR(priv->clk);
673673
goto out_host_put;
674674
}
675675

676-
ret = clk_prepare_enable(priv->clk);
677-
if (ret)
678-
goto out_host_put;
679-
680676
irq = platform_get_irq(pdev, 0);
681677
if (irq < 0) {
682678
ret = irq;
683-
goto out_disable_clk;
679+
goto out_host_put;
684680
}
685681

686682
ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler,
687683
0, "uniphier-spi", priv);
688684
if (ret) {
689685
dev_err(&pdev->dev, "failed to request IRQ\n");
690-
goto out_disable_clk;
686+
goto out_host_put;
691687
}
692688

693689
init_completion(&priv->xfer_done);
@@ -717,7 +713,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
717713
if (IS_ERR_OR_NULL(host->dma_tx)) {
718714
if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
719715
ret = -EPROBE_DEFER;
720-
goto out_disable_clk;
716+
goto out_host_put;
721717
}
722718
host->dma_tx = NULL;
723719
dma_tx_burst = INT_MAX;
@@ -767,9 +763,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
767763
host->dma_tx = NULL;
768764
}
769765

770-
out_disable_clk:
771-
clk_disable_unprepare(priv->clk);
772-
773766
out_host_put:
774767
spi_controller_put(host);
775768
return ret;
@@ -778,14 +771,11 @@ static int uniphier_spi_probe(struct platform_device *pdev)
778771
static void uniphier_spi_remove(struct platform_device *pdev)
779772
{
780773
struct spi_controller *host = platform_get_drvdata(pdev);
781-
struct uniphier_spi_priv *priv = spi_controller_get_devdata(host);
782774

783775
if (host->dma_tx)
784776
dma_release_channel(host->dma_tx);
785777
if (host->dma_rx)
786778
dma_release_channel(host->dma_rx);
787-
788-
clk_disable_unprepare(priv->clk);
789779
}
790780

791781
static const struct of_device_id uniphier_spi_match[] = {

0 commit comments

Comments
 (0)