From ae16c64fba01d68ef0404051ae0eda42ea4177c8 Mon Sep 17 00:00:00 2001 From: Appana Durga Kedareswara rao Date: Fri, 12 Oct 2018 09:51:07 +0530 Subject: [PATCH] gpio: gpio-xilinx: Fix unbalanced clock reference count while unloading the module, in case of graceful exit driver is not handling the clocks properly. This patch fixes this issue. Signed-off-by: Appana Durga Kedareswara rao Reviewed-by: Shubhrajyoti Datta Signed-off-by: Michal Simek --- drivers/gpio/gpio-xilinx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index d0f0a0ec09d8..cabbce4ea787 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -570,7 +570,9 @@ static int xgpio_remove(struct platform_device *pdev) struct xgpio_instance *chip = platform_get_drvdata(pdev); of_mm_gpiochip_remove(&chip->mmchip); - clk_disable_unprepare(chip->clk); + if (!pm_runtime_suspended(&pdev->dev)) + clk_disable(chip->clk); + clk_unprepare(chip->clk); pm_runtime_disable(&pdev->dev); return 0; @@ -661,17 +663,15 @@ static int xgpio_of_probe(struct platform_device *pdev) return status; } + pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); - status = pm_runtime_get_sync(&pdev->dev); - if (status < 0) - goto err_unprepare_clk; /* Call the OF gpio helper to setup and register the GPIO device */ status = of_mm_gpiochip_add(np, &chip->mmchip); if (status) { pr_err("%pOF: error in probe function with status %d\n", np, status); - goto err_pm_put; + goto err_unprepare_clk; } status = xgpio_irq_setup(np, chip); -- 2.39.2