Skip to content

Commit

Permalink
gpio: gpio-xilinx: Fix unbalanced clock reference count
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kedareswararao authored and Michal Simek committed Oct 15, 2018
1 parent 6c6033a commit ae16c64
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/gpio/gpio-xilinx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ae16c64

Please sign in to comment.