]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
gpio: gpio-xilinx: Fix unbalanced clock reference count
authorAppana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
Fri, 12 Oct 2018 04:21:07 +0000 (09:51 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 15 Oct 2018 06:17:55 +0000 (08:17 +0200)
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 <appana.durga.rao@xilinx.com>
Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/gpio/gpio-xilinx.c

index d0f0a0ec09d8a28c3e9647714b557740c4de7be9..cabbce4ea7877686f088ef5d9962c6d1ac41da36 100644 (file)
@@ -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);