[PATCH 00/12] drm: Move to using devm_platform_ioremap_resource

Anusha Srivatsa
2025-02-05T20:09:20Z

Start replacing the below occurences with the newer API:
- (devm_)platform_get_resource + devm_ioremap_resource
- (devm_)platform_get_resource + (devm_)ioremap
- platform_get_resource_byname + devm_ioremap
Move all these occurences to uses devm_platform_ioremap_resource
instead.

This is v2 of the series. Changes from v1 [1]:
- Mostly fix the compilation errors :( What had passed locally
happened to be the wrong config with most drivers not enabled.
- Clarify the TODO item in the GPU section of Documentation
for anyone who wants to do it in future.
- Drop meson patch from discussion in v1
- Drop rockchip patch as well. Offline discussion with
Maxime led to the conclusion that using
devm_platform_get_and_ioremap_resource() would be a better
approach in that source file. Not adding that change as part of
this series, can be addressed separately.

[1] - https://patchwork.freedesktop.org/series/144073/

Used Coccinelle to make the code changes.Semantic patch:

//First Case
//rule s/platform_get_resource + devm_ioremap_resource/devm_platform_ioremap_resource
@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);

//Second case
//rule s/(devm_)platform_get_resource + (devm_)ioremap/devm_platform_ioremap_resource.
@rule_2@
identifier res;
expression ioremap;
identifier pdev;
@@
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
<...
-if (!res) {
-...
-}
...>
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource(pdev,0);

//Third case
//rule s/(devm_)platform_get_resource_byname + (devm_)ioremap/devm_platform_ioremap_resource_byname.
@rule_3@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@
-struct resource *res;
<+...
-res = platform_get_resource_byname(pdev,mem,name);
<...
-if (!res) {
-...
-}
...>
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);
...+>

Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
Anusha Srivatsa (12):
drm/aspeed: move to devm_platform_ioremap_resource() usage
drm/fsl-dcu: move to devm_platform_ioremap_resource() usage
drm/hisilicon: move to devm_platform_ioremap_resource() usage
drm/mediatek: move to devm_platform_ioremap_resource() usage
drm/mxsfb: move to devm_platform_ioremap_resource() usage
drm/sprd: move to devm_platform_ioremap_resource() usage
drm/sti: move to devm_platform_ioremap_resource() usage
drm/stm: move to devm_platform_ioremap_resource() usage
drm/tegra: move to devm_platform_ioremap_resource() usage
drm/tiny: move to devm_platform_ioremap_resource() usage
drm/vc4: move to devm_platform_ioremap_resource() usage
Documentation: Update the todo

Documentation/gpu/todo.rst | 12 +++---
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 4 +-
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 4 +-
drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 4 +-
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 4 +-
drivers/gpu/drm/mediatek/mtk_disp_color.c | 4 +-
drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 4 +-
drivers/gpu/drm/mediatek/mtk_disp_merge.c | 4 +-
drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 4 +-
drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 4 +-
drivers/gpu/drm/mediatek/mtk_dsi.c | 4 +-
drivers/gpu/drm/mediatek/mtk_hdmi.c | 4 +-
drivers/gpu/drm/mediatek/mtk_mdp_rdma.c | 4 +-
drivers/gpu/drm/mxsfb/lcdif_drv.c | 4 +-
drivers/gpu/drm/mxsfb/mxsfb_drv.c | 4 +-
drivers/gpu/drm/sprd/sprd_dpu.c | 9 +---
drivers/gpu/drm/sprd/sprd_dsi.c | 9 +---
drivers/gpu/drm/sti/sti_compositor.c | 10 +----
drivers/gpu/drm/sti/sti_dvo.c | 10 +----
drivers/gpu/drm/sti/sti_hda.c | 9 +---
drivers/gpu/drm/sti/sti_hdmi.c | 11 +----
drivers/gpu/drm/sti/sti_hqvdp.c | 10 +----
drivers/gpu/drm/sti/sti_tvout.c | 10 +----
drivers/gpu/drm/sti/sti_vtg.c | 10 +----
drivers/gpu/drm/stm/ltdc.c | 4 +-
drivers/gpu/drm/tegra/dsi.c | 4 +-
drivers/gpu/drm/tiny/arcpgu.c | 4 +-
drivers/gpu/drm/vc4/vc4_hdmi.c | 55 +++++++------------------
28 files changed, 46 insertions(+), 177 deletions(-)
---
base-commit: 92514ef226f511f2ca1fb1b8752966097518edc0
change-id: 20250205-mem-cocci-newapi-6db4b8116d6e

Best regards,
--
Anusha Srivatsa <asrivats@redhat.com>