diff mbox series

[07/14] drm/rockchip: move to devm_platform_ioremap_resource() usage

Message ID 20250128-cocci-memory-api-v1-7-0d1609a29587@redhat.com (mailing list archive)
State New
Delegated to: Neil Armstrong
Headers show
Series drm: Move to using devm_platform_ioremap_resource | expand

Commit Message

Anusha Srivatsa Jan. 28, 2025, 10:29 p.m. UTC
Replace platform_get_resource + devm_ioremap_resource
with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
@rule_1@
identifier res;
expression ioremap_res;
identifier pdev;
@@
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);

Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Heiko Stübner <heiko@sntech.de>
Cc: Andy Yan <andy.yan@rock-chips.com>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Maxime Ripard Jan. 29, 2025, 3:41 p.m. UTC | #1
On Tue, Jan 28, 2025 at 05:29:31PM -0500, Anusha Srivatsa wrote:
> Replace platform_get_resource + devm_ioremap_resource
> with just devm_platform_ioremap_resource()
> 
> Used Coccinelle to do this change. SmPl patch:
> @rule_1@
> identifier res;
> expression ioremap_res;
> identifier pdev;
> @@
> -struct resource *res;
> ...
> -res = platform_get_resource(pdev,...);
> -ioremap_res = devm_ioremap_resource(...);
> +ioremap_res = devm_platform_ioremap_resource(pdev,0);
> 
> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: Heiko Stübner <heiko@sntech.de>
> Cc: Andy Yan <andy.yan@rock-chips.com>
> Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
> ---
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 57747f1cff26e444ef3569983d6a7f7922f03ff7..4c639f7c868907fc35ce22f2ef7e281ad85c2d9e 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -2187,7 +2187,6 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
>  	const struct vop_data *vop_data;
>  	struct drm_device *drm_dev = data;
>  	struct vop *vop;
> -	struct resource *res;
>  	int ret, irq;
>  
>  	vop_data = of_device_get_match_data(dev);
> @@ -2207,8 +2206,7 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
>  
>  	vop_win_init(vop);
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	vop->regs = devm_ioremap_resource(dev, res);
> +	vop->regs = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(vop->regs))
>  		return PTR_ERR(vop->regs);
>  	vop->len = resource_size(res);

This one will result in a compile failure too, you removed res but it's
still used on the last line.

Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 57747f1cff26e444ef3569983d6a7f7922f03ff7..4c639f7c868907fc35ce22f2ef7e281ad85c2d9e 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -2187,7 +2187,6 @@  static int vop_bind(struct device *dev, struct device *master, void *data)
 	const struct vop_data *vop_data;
 	struct drm_device *drm_dev = data;
 	struct vop *vop;
-	struct resource *res;
 	int ret, irq;
 
 	vop_data = of_device_get_match_data(dev);
@@ -2207,8 +2206,7 @@  static int vop_bind(struct device *dev, struct device *master, void *data)
 
 	vop_win_init(vop);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	vop->regs = devm_ioremap_resource(dev, res);
+	vop->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(vop->regs))
 		return PTR_ERR(vop->regs);
 	vop->len = resource_size(res);