[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240821121048.31566-5-liulei.rjpt@vivo.com>
Date: Wed, 21 Aug 2024 20:10:42 +0800
From: Lei Liu <liulei.rjpt@...o.com>
To: Neal Liu <neal_liu@...eedtech.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Joel Stanley <joel@....id.au>,
Andrew Jeffery <andrew@...econstruct.com.au>,
Daniel Mack <daniel@...que.org>,
Haojian Zhuang <haojian.zhuang@...il.com>,
Robert Jarzmik <robert.jarzmik@...e.fr>,
Conor Dooley <conor.dooley@...rochip.com>,
Daire McNamara <daire.mcnamara@...rochip.com>,
Bin Liu <b-liu@...com>,
Lei Liu <liulei.rjpt@...o.com>,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
linux-aspeed@...ts.ozlabs.org,
linux-usb@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org
Cc: opensource.kernel@...o.com
Subject: [PATCH 4/5] usb: mpfs: Use devm_clk_get_enabled() helpers
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@...o.com>
---
drivers/usb/musb/mpfs.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/musb/mpfs.c b/drivers/usb/musb/mpfs.c
index 29c7e5cdb230..06faf5ab22e6 100644
--- a/drivers/usb/musb/mpfs.c
+++ b/drivers/usb/musb/mpfs.c
@@ -159,19 +159,13 @@ static int mpfs_probe(struct platform_device *pdev)
return -ENOMEM;
}
- clk = devm_clk_get(&pdev->dev, NULL);
+ clk = devm_clk_get_enable(&pdev->dev, NULL);
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(clk);
goto err_phy_release;
}
- ret = clk_prepare_enable(clk);
- if (ret) {
- dev_err(&pdev->dev, "failed to enable clock\n");
- goto err_phy_release;
- }
-
musb_pdev->dev.parent = dev;
musb_pdev->dev.coherent_dma_mask = DMA_BIT_MASK(39);
musb_pdev->dev.dma_mask = &musb_pdev->dev.coherent_dma_mask;
@@ -184,7 +178,7 @@ static int mpfs_probe(struct platform_device *pdev)
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) {
ret = -ENOMEM;
- goto err_clk_disable;
+ goto err_phy_release;
}
pdata->config = &mpfs_musb_hdrc_config;
@@ -203,7 +197,7 @@ static int mpfs_probe(struct platform_device *pdev)
dev_err(dev, "failed to register usb-phy %ld\n",
PTR_ERR(glue->phy));
ret = PTR_ERR(glue->phy);
- goto err_clk_disable;
+ goto err_phy_release;
}
platform_set_drvdata(pdev, glue);
@@ -211,27 +205,24 @@ static int mpfs_probe(struct platform_device *pdev)
ret = platform_device_add_resources(musb_pdev, pdev->resource, pdev->num_resources);
if (ret) {
dev_err(dev, "failed to add resources\n");
- goto err_clk_disable;
+ goto err_phy_release;
}
ret = platform_device_add_data(musb_pdev, pdata, sizeof(*pdata));
if (ret) {
dev_err(dev, "failed to add platform_data\n");
- goto err_clk_disable;
+ goto err_phy_release;
}
ret = platform_device_add(musb_pdev);
if (ret) {
dev_err(dev, "failed to register musb device\n");
- goto err_clk_disable;
+ goto err_phy_release;
}
dev_info(&pdev->dev, "Registered MPFS MUSB driver\n");
return 0;
-err_clk_disable:
- clk_disable_unprepare(clk);
-
err_phy_release:
usb_phy_generic_unregister(glue->phy);
platform_device_put(musb_pdev);
@@ -242,7 +233,6 @@ static void mpfs_remove(struct platform_device *pdev)
{
struct mpfs_glue *glue = platform_get_drvdata(pdev);
- clk_disable_unprepare(glue->clk);
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(pdev);
}
--
2.34.1
Powered by blists - more mailing lists