[PATCH v2 05/17] media: rockchip: rga: use devres version of pm_runtime_enable

Nicolas Dufresne nicolas at ndufresne.ca
Tue Nov 24 12:51:44 PST 2026


Le mercredi 16 septembre 2026 à 17:09 +0200, Sven Püschel a écrit :
> Use the devres version of pm_runtime_enable named
> devm_pm_runtime_enable to ease up the cleanup handling. Also it avoids
> having a mixed cleanup order due to the following
> devm_platform_ioremap_resource being cleaned up anyways after the probe
> function has returned.
> 
> This also changes some dev_err calls to dev_err_probe for convenient
> returning. This may not print these messages in the error case, as
> dev_err_probe may handle them differently based on the error (e.g.
> ENOMEM won't be printed).
> 
> Signed-off-by: Sven Püschel <s.pueschel at pengutronix.de>
> 
> ---
> v2
> - added
> ---
>  drivers/media/platform/rockchip/rga/rga.c | 34 +++++++++++--------------------
>  1 file changed, 12 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
> index 8c03422d669cf..d7f0712177b70 100644
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -797,37 +797,31 @@ static int rga_probe(struct platform_device *pdev)
>  	if (ret)
>  		return dev_err_probe(&pdev->dev, ret, "Unable to parse OF data\n");
>  
> -	pm_runtime_enable(rga->dev);
> +	ret = devm_pm_runtime_enable(rga->dev);
> +	if (ret)
> +		return ret;
>  
>  	rga->regs = devm_platform_ioremap_resource(pdev, 0);
> -	if (IS_ERR(rga->regs)) {
> -		ret = PTR_ERR(rga->regs);
> -		goto err_put_clk;
> -	}
> +	if (IS_ERR(rga->regs))
> +		return PTR_ERR(rga->regs);
>  
>  	irq = platform_get_irq(pdev, 0);
> -	if (irq < 0) {
> -		ret = irq;
> -		goto err_put_clk;
> -	}
> +	if (irq < 0)
> +		return irq;
>  
>  	ret = devm_request_irq(rga->dev, irq, rga_isr,
>  			       rga_has_internal_iommu(rga) ? 0 : IRQF_SHARED,
>  			       dev_name(rga->dev), rga);
> -	if (ret < 0) {
> -		dev_err(rga->dev, "failed to request irq\n");
> -		goto err_put_clk;
> -	}
> +	if (ret < 0)
> +		return dev_err_probe(rga->dev, ret, "failed to request irq\n");
>  
>  	ret = dma_set_mask_and_coherent(rga->dev, DMA_BIT_MASK(32));
> -	if (ret) {
> -		dev_err(rga->dev, "32-bit DMA not supported");
> -		goto err_put_clk;
> -	}
> +	if (ret)
> +		dev_err_probe(rga->dev, ret, "32-bit DMA not supported");

Did you mean ?
		return dev_err_probe(rga->dev, ret, "32-bit DMA not
supported");

With this fixed:

Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

>  
>  	ret = v4l2_device_register(&pdev->dev, &rga->v4l2_dev);
>  	if (ret)
> -		goto err_put_clk;
> +		return ret;
>  	vfd = video_device_alloc();
>  	if (!vfd) {
>  		v4l2_err(&rga->v4l2_dev, "Failed to allocate video device\n");
> @@ -877,8 +871,6 @@ static int rga_probe(struct platform_device *pdev)
>  	video_device_release(vfd);
>  unreg_v4l2_dev:
>  	v4l2_device_unregister(&rga->v4l2_dev);
> -err_put_clk:
> -	pm_runtime_disable(rga->dev);
>  
>  	return ret;
>  }
> @@ -892,8 +884,6 @@ static void rga_remove(struct platform_device *pdev)
>  	v4l2_m2m_release(rga->m2m_dev);
>  	video_unregister_device(rga->vfd);
>  	v4l2_device_unregister(&rga->v4l2_dev);
> -
> -	pm_runtime_disable(rga->dev);
>  }
>  
>  static int __maybe_unused rga_runtime_suspend(struct device *dev)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20261124/faa2c73b/attachment.sig>


More information about the Linux-rockchip mailing list