Skip to content

Commit 4e26dda

Browse files
Zhang ZekunBartosz Golaszewski
authored andcommitted
gpio: xilinx: Use helper function devm_clk_get_optional_enabled()
devm_clk_get_optional() and clk_prepare_enable() can be replaced by helper function devm_clk_get_optional_enabled(). Let's simplify code with use of devm_clk_get_optional_enabled() and avoid calling clk_disable_unprepare(). Signed-off-by: Zhang Zekun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 162b169 commit 4e26dda

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

drivers/gpio/gpio-xilinx.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,9 @@ static int __maybe_unused xgpio_suspend(struct device *dev)
333333
*/
334334
static void xgpio_remove(struct platform_device *pdev)
335335
{
336-
struct xgpio_instance *gpio = platform_get_drvdata(pdev);
337-
338336
pm_runtime_get_sync(&pdev->dev);
339337
pm_runtime_put_noidle(&pdev->dev);
340338
pm_runtime_disable(&pdev->dev);
341-
clk_disable_unprepare(gpio->clk);
342339
}
343340

344341
/**
@@ -644,15 +641,10 @@ static int xgpio_probe(struct platform_device *pdev)
644641
return PTR_ERR(chip->regs);
645642
}
646643

647-
chip->clk = devm_clk_get_optional(&pdev->dev, NULL);
644+
chip->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
648645
if (IS_ERR(chip->clk))
649646
return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk), "input clock not found.\n");
650647

651-
status = clk_prepare_enable(chip->clk);
652-
if (status < 0) {
653-
dev_err(&pdev->dev, "Failed to prepare clk\n");
654-
return status;
655-
}
656648
pm_runtime_get_noresume(&pdev->dev);
657649
pm_runtime_set_active(&pdev->dev);
658650
pm_runtime_enable(&pdev->dev);
@@ -699,7 +691,6 @@ static int xgpio_probe(struct platform_device *pdev)
699691
err_pm_put:
700692
pm_runtime_disable(&pdev->dev);
701693
pm_runtime_put_noidle(&pdev->dev);
702-
clk_disable_unprepare(chip->clk);
703694
return status;
704695
}
705696

0 commit comments

Comments
 (0)