diff mbox series

[-next,05/11] gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled()

Message ID 20230818093018.1051434-6-lizetao1@huawei.com (mailing list archive)
State New, archived
Headers show
Series gpio: Use devm_clk_get_*() helper function to simplify the drivers. | expand

Commit Message

Li Zetao Aug. 18, 2023, 9:30 a.m. UTC
Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
prepared and enabled clocks"), devm_clk_get_optional() and
clk_prepare_enable() can now be replaced by
devm_clk_get_optional_enabled() when the driver enables (and possibly
prepares) the clocks for the whole lifetime of the device. Moreover,
it is no longer necessary to unprepare and disable the clocks explicitly.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/gpio/gpio-mb86s7x.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Andy Shevchenko Aug. 18, 2023, 2:09 p.m. UTC | #1
On Fri, Aug 18, 2023 at 05:30:12PM +0800, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
> prepared and enabled clocks"), devm_clk_get_optional() and
> clk_prepare_enable() can now be replaced by
> devm_clk_get_optional_enabled() when the driver enables (and possibly
> prepares) the clocks for the whole lifetime of the device. Moreover,
> it is no longer necessary to unprepare and disable the clocks explicitly.

With this the clk member in the private struct is not needed anymore.
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c
index ca7eb5e8bfaa..8f2abc914dfa 100644
--- a/drivers/gpio/gpio-mb86s7x.c
+++ b/drivers/gpio/gpio-mb86s7x.c
@@ -170,14 +170,10 @@  static int mb86s70_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(gchip->base))
 		return PTR_ERR(gchip->base);
 
-	gchip->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	gchip->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR(gchip->clk))
 		return PTR_ERR(gchip->clk);
 
-	ret = clk_prepare_enable(gchip->clk);
-	if (ret)
-		return ret;
-
 	spin_lock_init(&gchip->lock);
 
 	gchip->gc.direction_output = mb86s70_gpio_direction_output;
@@ -196,7 +192,6 @@  static int mb86s70_gpio_probe(struct platform_device *pdev)
 	ret = gpiochip_add_data(&gchip->gc, gchip);
 	if (ret) {
 		dev_err(&pdev->dev, "couldn't register gpio driver\n");
-		clk_disable_unprepare(gchip->clk);
 		return ret;
 	}
 
@@ -211,7 +206,6 @@  static int mb86s70_gpio_remove(struct platform_device *pdev)
 
 	acpi_gpiochip_free_interrupts(&gchip->gc);
 	gpiochip_remove(&gchip->gc);
-	clk_disable_unprepare(gchip->clk);
 
 	return 0;
 }