Skip to content

Commit

Permalink
uio_pruss: fix unbalanced pm_runtime calls
Browse files Browse the repository at this point in the history
Signed-off-by: Matthijs van Duin <[email protected]>
  • Loading branch information
mvduin authored and RobertCNelson committed Jan 28, 2020
1 parent 90a9707 commit e7db4b3
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions drivers/uio/uio_pruss.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev)
clk_disable(gdev->pruss_clk);
clk_put(gdev->pruss_clk);
kfree(gdev);
pm_runtime_put(dev);
pm_runtime_disable(dev);
}

static int pruss_probe(struct platform_device *pdev)
Expand All @@ -155,15 +157,25 @@ static int pruss_probe(struct platform_device *pdev)
kfree(gdev);
return -ENOMEM;
}

pm_runtime_enable(dev);
ret = pm_runtime_get_sync(dev);
if (ret < 0) {
dev_err(dev, "pm_runtime_get_sync() failed\n");
pm_runtime_disable(dev);
kfree(gdev->info);
kfree(gdev);
return ret;
}

#ifdef CONFIG_ARCH_DAVINCI_DA850
/* Power on PRU in case its not done as part of boot-loader */
gdev->pruss_clk = clk_get(dev, "pruss");
if (IS_ERR(gdev->pruss_clk)) {
dev_err(dev, "Failed to get clock\n");
ret = PTR_ERR(gdev->pruss_clk);
kfree(gdev->info);
kfree(gdev);
return ret;
gdev->pruss_clk = NULL;
goto out_free;
} else {
ret = clk_enable(gdev->pruss_clk);
if (ret) {
Expand All @@ -177,17 +189,10 @@ static int pruss_probe(struct platform_device *pdev)
#endif

if (dev->of_node) {
pm_runtime_enable(dev);
ret = pm_runtime_get_sync(dev);
if (IS_ERR_VALUE(ret)) {
dev_err(dev, "pm_runtime_get_sync() failed\n");
return ret;
}

ret = of_address_to_resource(dev->of_node, 0, &res);
if (IS_ERR_VALUE(ret)) {
dev_err(dev, "failed to parse DT reg\n");
return ret;
goto out_free;
}
regs_prussio = &res;
} else {
Expand Down

0 comments on commit e7db4b3

Please sign in to comment.