<br><br><div class="gmail_quote">2012/12/26 Sachin Kamat <span dir="ltr"><<a href="mailto:sachin.kamat@linaro.org" target="_blank">sachin.kamat@linaro.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br><br>On Wednesday, 26 December 2012, Inki Dae <<a href="mailto:inki.dae@samsung.com" target="_blank">inki.dae@samsung.com</a>> wrote:<br>><br>><br>> 2012/12/24 Sachin Kamat <<a href="mailto:sachin.kamat@linaro.org" target="_blank">sachin.kamat@linaro.org</a>><br>
>><br>>> This eliminates the need for explicit clk_put and makes the<br>>> cleanup and exit path code simpler.<br>>><br>>> Cc: Eunchul Kim <<a href="mailto:chulspro.kim@samsung.com" target="_blank">chulspro.kim@samsung.com</a>><br>
>> Signed-off-by: Sachin Kamat <<a href="mailto:sachin.kamat@linaro.org" target="_blank">sachin.kamat@linaro.org</a>><br>>> ---<br>>> drivers/gpu/drm/exynos/exynos_drm_fimc.c | 46 ++++++-----------------------<br>
>> 1 files changed, 10 insertions(+), 36 deletions(-)<br>>><br>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c<br>>> index 972aa70..c4006b8 100644<br>
>> --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c<br>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c<br>>> @@ -1739,64 +1739,50 @@ static int __devinit fimc_probe(struct platform_device *pdev)<br>>> platform_get_device_id(pdev)->driver_data;<br>
>><br>>> /* clock control */<br>>> - ctx->sclk_fimc_clk = clk_get(dev, "sclk_fimc");<br>>> + ctx->sclk_fimc_clk = devm_clk_get(dev, "sclk_fimc");<br>>> if (IS_ERR(ctx->sclk_fimc_clk)) {<br>
>> dev_err(dev, "failed to get src fimc clock.\n");<br>>> return PTR_ERR(ctx->sclk_fimc_clk);<br>>> }<br>>> clk_enable(ctx->sclk_fimc_clk);<br>
>><br>>> - ctx->fimc_clk = clk_get(dev, "fimc");<br>>> + ctx->fimc_clk = devm_clk_get(dev, "fimc");<br>>> if (IS_ERR(ctx->fimc_clk)) {<br>>> dev_err(dev, "failed to get fimc clock.\n");<br>
>> clk_disable(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->sclk_fimc_clk);<br>>> return PTR_ERR(ctx->fimc_clk);<br>>> }<br>>><br>
>> - ctx->wb_clk = clk_get(dev, "pxl_async0");<br>
>> + ctx->wb_clk = devm_clk_get(dev, "pxl_async0");<br>>> if (IS_ERR(ctx->wb_clk)) {<br>>> dev_err(dev, "failed to get writeback a clock.\n");<br>
>> clk_disable(ctx->sclk_fimc_clk);<br>
>> - clk_put(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->fimc_clk);<br>>> return PTR_ERR(ctx->wb_clk);<br>>> }<br>>><br>>> - ctx->wb_b_clk = clk_get(dev, "pxl_async1");<br>
>> + ctx->wb_b_clk = devm_clk_get(dev, "pxl_async1");<br>>> if (IS_ERR(ctx->wb_b_clk)) {<br>>> dev_err(dev, "failed to get writeback b clock.\n");<br>
>> clk_disable(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->fimc_clk);<br>>> - clk_put(ctx->wb_clk);<br>
>> return PTR_ERR(ctx->wb_b_clk);<br>>> }<br>>><br>>> - parent_clk = clk_get(dev, ddata->parent_clk);<br>>> + parent_clk = devm_clk_get(dev, ddata->parent_clk);<br>
>><br>>> if (IS_ERR(parent_clk)) {<br>>> dev_err(dev, "failed to get parent clock.\n");<br>>> clk_disable(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->sclk_fimc_clk);<br>
>> - clk_put(ctx->fimc_clk);<br>>> - clk_put(ctx->wb_clk);<br>>> - clk_put(ctx->wb_b_clk);<br>>> return PTR_ERR(parent_clk);<br>>> }<br>
>><br>>> if (clk_set_parent(ctx->sclk_fimc_clk, parent_clk)) {<br>>> dev_err(dev, "failed to set parent.\n");<br>>> - clk_put(parent_clk);<br>>> + devm_clk_put(dev, parent_clk);<br>
><br>> remove the above call. is there any reason that devm_clk_put should be called here?<br><br></div></div>Devm resources are freed/released automatically only when the device detaches. In the above case the clock was released explicitly (for whatever reasons) earlier. Hence i have used devm call to keep the code logic same as i do not know the behavior if this clock is 'put' when the device detaches instead of here.<div class="HOEnZb">
<div class="h5"><br></div></div></blockquote><div><br>If probe is failed, devm resources are released by devres_release_all(). So that is unnecessary call. Remove it.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
<br>> <br>>><br>>> clk_disable(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->fimc_clk);<br>>> - clk_put(ctx->wb_clk);<br>
>> - clk_put(ctx->wb_b_clk);<br>>> return -EINVAL;<br>>> }<br>>><br>>> - clk_put(parent_clk);<br>>> + devm_clk_put(dev, parent_clk);<br>
><br>> ditto.<br>> <br>>><br>>> clk_set_rate(ctx->sclk_fimc_clk, pdata->clk_rate);<br>>><br>>> /* resource memory */<br>>> @@ -1804,16 +1790,14 @@ static int __devinit fimc_probe(struct platform_device *pdev)<br>
>> ctx->regs = devm_request_and_ioremap(dev, ctx->regs_res);<br>>> if (!ctx->regs) {<br>>> dev_err(dev, "failed to map registers.\n");<br>>> - ret = -ENXIO;<br>
>> - goto err_clk;<br>>> + return -ENXIO;<br>>> }<br>>><br>>> /* resource irq */<br>>> res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);<br>
>> if (!res) {<br>>> dev_err(dev, "failed to request irq resource.\n");<br>>> - ret = -ENOENT;<br>>> - goto err_clk;<br>>> + return -ENOENT;<br>
>> }<br>>><br>>> ctx->irq = res->start;<br>>> @@ -1821,7 +1805,7 @@ static int __devinit fimc_probe(struct platform_device *pdev)<br>>> IRQF_ONESHOT, "drm_fimc", ctx);<br>
>> if (ret < 0) {<br>>> dev_err(dev, "failed to request irq.\n");<br>>> - goto err_clk;<br>>> + return ret;<br>>> }<br>
>><br>>> /* context initailization */<br>>> @@ -1867,11 +1851,6 @@ err_ippdrv_register:<br>>> pm_runtime_disable(dev);<br>>> err_get_irq:<br>>> free_irq(ctx->irq, ctx);<br>
>> -err_clk:<br>>> - clk_put(ctx->sclk_fimc_clk);<br>>> - clk_put(ctx->fimc_clk);<br>>> - clk_put(ctx->wb_clk);<br>>> - clk_put(ctx->wb_b_clk);<br>>><br>
>> return ret;<br>>> }<br>>> @@ -1891,11 +1870,6 @@ static int __devexit fimc_remove(struct platform_device *pdev)<br>>><br>>> free_irq(ctx->irq, ctx);<br>>><br>>> - clk_put(ctx->sclk_fimc_clk);<br>
>> - clk_put(ctx->fimc_clk);<br>>> - clk_put(ctx->wb_clk);<br>>> - clk_put(ctx->wb_b_clk);<br>>> -<br>>> return 0;<br>>> }<br>>><br>>> --<br>
>> 1.7.4.1<br>>><br>>> _______________________________________________<br>>> dri-devel mailing list<br>>> <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
>> <a href="http://lists.freedesktop.org/mailman/listinfo/dri-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>><br>><br><br></div></div><span class="HOEnZb"><font color="#888888">-- <br>
<div>With warm regards,</div>
<div>Sachin</div><br>
</font></span><br>_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/dri-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
<br></blockquote></div><br>