Skip to contentSkip to conversation

drm: Move to using devm_platform_ioremap_resource

PATCH In review Anusha Srivatsa 9 participants 41 messages Jan 28, 2025 – Feb 5, 2025

Subsystems (23)
lore
Share & tools
lore
#0 lore raw

cover drm: Move to using devm_platform_ioremap_resource

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.

Address a TODO item in the GPU section.

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);

---
Anusha Srivatsa (14):
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/meson: move to devm_platform_ioremap_resource() usage drm/mxsfb: move to devm_platform_ioremap_resource() usage drm/rockchip: 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                      | 15 ---------------
 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/meson/meson_drv.c               |  9 +--------
 drivers/gpu/drm/mxsfb/lcdif_drv.c               |  4 +---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c               |  4 +---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.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                   | 10 +---------
 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                  |  9 ++-------
 30 files changed, 30 insertions(+), 164 deletions(-)

---
base-commit: c4b9570cfb63501638db720f3bee9f6dfd044b82
change-id: 20250128-cocci-memory-api-266e13a057e7

Best regards,

Signature · 1 line
Anusha Srivatsa <[email protected]>
#1 lore raw

PATCH 1/14 drm/aspeed: move to devm_platform_ioremap_resource() usage

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);

---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +1 -3
index 397e677a691c2c6d199063f44358196a4569b389..46094cca297479d1cf19f6db99538c5e7a0fec92 100644
@@ -144,11 +144,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
 	struct device_node *np = pdev->dev.of_node;
 	const struct aspeed_gfx_config *config;
-	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base = devm_ioremap_resource(drm->dev, res);
+	priv->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->base))
 		return PTR_ERR(priv->base);
 
Signature · 1 line
2.47.0
maintainer Acked-by on v1 1/14
#2 lore raw

Re: [PATCH 01/14] drm/aspeed: move to devm_platform_ioremap_resource() usage

Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 2 lines
maintainer Reviewed-by on v1 1/14
#3 lore raw

Re: [PATCH 01/14] drm/aspeed: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa
Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 2 lines

Maxime

#4 lore raw

PATCH 2/14 drm/fsl-dcu: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 Stefan Agner <[email protected]>
Cc Alison Wang <[email protected]>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +1 -3
index 03b076db9381a5db0bff6576cda2772495a61fed..3bbfc1b56a6557e2f54d2b7ed099531053871341 100644
@@ -260,7 +260,6 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
 	struct fsl_dcu_drm_device *fsl_dev;
 	struct drm_device *drm;
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	void __iomem *base;
 	struct clk *pix_clk_in;
 	char pix_clk_name[32];
@@ -278,8 +277,7 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	fsl_dev->soc = id->data;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	base = devm_ioremap_resource(dev, res);
+	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base)) {
 		ret = PTR_ERR(base);
 		return ret;
Signature · 1 line
2.47.0
maintainer Reviewed-by on v1 2/14
#5 lore raw

Re: [PATCH 02/14] drm/fsl-dcu: move to devm_platform_ioremap_resource() usage

Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 3 lines
Cc Stefan Agner <[email protected]>
Cc Alison Wang <[email protected]>

Maxime

#6 lore raw

PATCH 3/14 drm/hisilicon: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 Xinliang Liu <[email protected]>
Cc Tian Tao <[email protected]>
Cc Xinwei Kong <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Yongqin Liu <[email protected]>
Cc John Stultz <[email protected]>
---
 drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c    | 4 +---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +1 -3
index 2eea9fb0e76bf3ead8f5914e6ebb65b5b3603b9a..e80debdc41763357cb2cf321205c0dfac80a911e 100644
@@ -825,7 +825,6 @@ static const struct component_ops dsi_ops = {
 static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi)
 {
 	struct dsi_hw_ctx *ctx = dsi->ctx;
-	struct resource *res;
 
 	ctx->pclk = devm_clk_get(&pdev->dev, "pclk");
 	if (IS_ERR(ctx->pclk)) {
@@ -833,8 +832,7 @@ static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi)
 		return PTR_ERR(ctx->pclk);
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ctx->base = devm_ioremap_resource(&pdev->dev, res);
+	ctx->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(ctx->base)) {
 		DRM_ERROR("failed to remap dsi io region\n");
 		return PTR_ERR(ctx->base);
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +1 -3
index 2eb49177ac42bc6dba692328cca5c99d5925041c..45c4eb008ad5d639340f769ad022d186ec454722 100644
@@ -844,7 +844,6 @@ static struct drm_plane_funcs ade_plane_funcs = {
 static void *ade_hw_ctx_alloc(struct platform_device *pdev,
 			      struct drm_crtc *crtc)
 {
-	struct resource *res;
 	struct device *dev = &pdev->dev;
 	struct device_node *np = pdev->dev.of_node;
 	struct ade_hw_ctx *ctx = NULL;
@@ -856,8 +855,7 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev,
 		return ERR_PTR(-ENOMEM);
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ctx->base = devm_ioremap_resource(dev, res);
+	ctx->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(ctx->base)) {
 		DRM_ERROR("failed to remap ade io base\n");
 		return ERR_PTR(-EIO);
Signature · 1 line
2.47.0
maintainer Reviewed-by on v1 3/14
#7 lore raw

Re: [PATCH 03/14] drm/hisilicon: move to devm_platform_ioremap_resource() usage

Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 8 lines
Cc Xinliang Liu <[email protected]>
Cc Tian Tao <[email protected]>
Cc Xinwei Kong <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Yongqin Liu <[email protected]>
Cc John Stultz <[email protected]>

Maxime

#8 lore raw

PATCH 4/14 drm/mediatek: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 Chun-Kuang Hu <[email protected]>
Cc Philipp Zabel <[email protected]>
---
 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 +---
 8 files changed, 8 insertions(+), 24 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_color.c +1 -3
index dd8433a38282a9ba1bcc3a4ddd01dd89738ccb60..39c7de4cdcc16b56a5a1d046aaabaf5580227ed2 100644
@@ -96,7 +96,6 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_disp_color *priv;
-	struct resource *res;
 	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -108,8 +107,7 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(priv->clk),
 				     "failed to get color clk\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->regs = devm_ioremap_resource(dev, res);
+	priv->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->regs))
 		return dev_err_probe(dev, PTR_ERR(priv->regs),
 				     "failed to ioremap color\n");
drivers/gpu/drm/mediatek/mtk_disp_gamma.c +1 -3
index b17b11d93846f2019d8c4afb294375333e22dc42..8afd15006df2a21f3f52fe00eca3c5501f4fb76a 100644
@@ -256,7 +256,6 @@ static int mtk_disp_gamma_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_disp_gamma *priv;
-	struct resource *res;
 	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -268,8 +267,7 @@ static int mtk_disp_gamma_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(priv->clk),
 				     "failed to get gamma clk\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->regs = devm_ioremap_resource(dev, res);
+	priv->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->regs))
 		return dev_err_probe(dev, PTR_ERR(priv->regs),
 				     "failed to ioremap gamma\n");
drivers/gpu/drm/mediatek/mtk_disp_merge.c +1 -3
index 563b1b248fbbb38ef03bb3e3ceecdd265961df60..b174dda091d3fbd16796e8e128b030fccf5b902c 100644
@@ -306,7 +306,6 @@ static const struct component_ops mtk_disp_merge_component_ops = {
 static int mtk_disp_merge_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	struct mtk_disp_merge *priv;
 	int ret;
 
@@ -314,8 +313,7 @@ static int mtk_disp_merge_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->regs = devm_ioremap_resource(dev, res);
+	priv->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->regs))
 		return dev_err_probe(dev, PTR_ERR(priv->regs),
 				     "failed to ioremap merge\n");
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -3
index df82cea4bb79c472acbb66e0df27fbad3e70bd20..d0581c4e3c999cf865fdd0aaf4c2f38dd404926e 100644
@@ -604,7 +604,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_disp_ovl *priv;
-	struct resource *res;
 	int irq;
 	int ret;
 
@@ -621,8 +620,7 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(priv->clk),
 				     "failed to get ovl clk\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->regs = devm_ioremap_resource(dev, res);
+	priv->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->regs))
 		return dev_err_probe(dev, PTR_ERR(priv->regs),
 				     "failed to ioremap ovl\n");
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +1 -3
index bf47790e4d6be5d60070c63c15c75fa201cc4b27..c9d41d75e7f2a3af5820921b7e563da377ce8d0d 100644
@@ -313,7 +313,6 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_disp_rdma *priv;
-	struct resource *res;
 	int irq;
 	int ret;
 
@@ -330,8 +329,7 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(priv->clk),
 				     "failed to get rdma clk\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->regs = devm_ioremap_resource(dev, res);
+	priv->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->regs))
 		return dev_err_probe(dev, PTR_ERR(priv->regs),
 				     "failed to ioremap rdma\n");
drivers/gpu/drm/mediatek/mtk_dsi.c +1 -3
index 40752f2320548fbf6c7de96b18e8a636ac9c31be..f298293471de49473dd05973383dc22f7d3b6c23 100644
@@ -1192,7 +1192,6 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 {
 	struct mtk_dsi *dsi;
 	struct device *dev = &pdev->dev;
-	struct resource *regs;
 	int irq_num;
 	int ret;
 
@@ -1217,8 +1216,7 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	if (IS_ERR(dsi->hs_clk))
 		return dev_err_probe(dev, PTR_ERR(dsi->hs_clk), "Failed to get hs clock\n");
 
-	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	dsi->regs = devm_ioremap_resource(dev, regs);
+	dsi->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(dsi->regs))
 		return dev_err_probe(dev, PTR_ERR(dsi->regs), "Failed to ioremap memory\n");
 
drivers/gpu/drm/mediatek/mtk_hdmi.c +1 -3
index ca82bc829cb96446d4d34eeef45848df03bd716b..d729c13590cb5ec176f15b680c262a26b677e6aa 100644
@@ -1425,7 +1425,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
 	struct device_node *cec_np, *remote, *i2c_np;
 	struct platform_device *cec_pdev;
 	struct regmap *regmap;
-	struct resource *mem;
 	int ret;
 
 	ret = mtk_hdmi_get_all_clk(hdmi, np);
@@ -1471,8 +1470,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
 	}
 	hdmi->sys_regmap = regmap;
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	hdmi->regs = devm_ioremap_resource(dev, mem);
+	hdmi->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(hdmi->regs)) {
 		ret = PTR_ERR(hdmi->regs);
 		goto put_device;
drivers/gpu/drm/mediatek/mtk_mdp_rdma.c +1 -3
index fc69ee38ce7d6a245a7460cfde8de426e83b2e80..7982788ae9df51f1a378d8d538737f38af7299f2 100644
@@ -291,7 +291,6 @@ static const struct component_ops mtk_mdp_rdma_component_ops = {
 static int mtk_mdp_rdma_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	struct mtk_mdp_rdma *priv;
 	int ret = 0;
 
@@ -299,8 +298,7 @@ static int mtk_mdp_rdma_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->regs = devm_ioremap_resource(dev, res);
+	priv->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->regs))
 		return dev_err_probe(dev, PTR_ERR(priv->regs),
 				     "failed to ioremap rdma\n");
Signature · 1 line
2.47.0
#9 lore raw

PATCH 5/14 drm/meson: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

Replace platform_get_resource_byname + devm_ioremap with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
@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);

---
 drivers/gpu/drm/meson/meson_drv.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +1 -8
index 81d2ee37e7732dca89d02347b9c972300b38771a..6c805805b7a7f675f8bb03944318972eb4df864e 100644
@@ -184,7 +184,6 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
 	const struct meson_drm_match_data *match;
 	struct meson_drm *priv;
 	struct drm_device *drm;
-	struct resource *res;
 	void __iomem *regs;
 	int ret, i;
 
@@ -220,14 +219,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
 	}
 
 	priv->io_base = regs;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi");
-	if (!res) {
-		ret = -EINVAL;
-		goto free_drm;
-	}
 	/* Simply ioremap since it may be a shared register zone */
-	regs = devm_ioremap(dev, res->start, resource_size(res));
+	regs = devm_platform_ioremap_resource_byname(pdev, "hhi");
 	if (!regs) {
 		ret = -EADDRNOTAVAIL;
 		goto free_drm;
Signature · 1 line
2.47.0
maintainer
#10 lore raw

Re: [PATCH 05/14] drm/meson: move to devm_platform_ioremap_resource() usage

Quoted 43 lines · Anusha Srivatsa

Replace platform_get_resource_byname + devm_ioremap with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
@rule_3@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource_byname(pdev,mem,name);

<...

drivers/gpu/drm/meson/meson_drv.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);
---
 drivers/gpu/drm/meson/meson_drv.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +0 -1
index 81d2ee37e7732dca89d02347b9c972300b38771a..6c805805b7a7f675f8bb03944318972eb4df864e 100644
@@ -184,7 +184,6 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
 	const struct meson_drm_match_data *match;
 	struct meson_drm *priv;
 	struct drm_device *drm;
-	struct resource *res;
 	void __iomem *regs;
 	int ret, i;
 
@@ -220,14 +219,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
 	}
 

drivers/gpu/drm/meson/meson_drv.c static int meson_drv_bind_master(struct device *dev, bool has_components) · line 223

Quoted 10 lines
drivers/gpu/drm/meson/meson_drv.c +1 -7
 	priv->io_base = regs;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi");
-	if (!res) {
-		ret = -EINVAL;
-		goto free_drm;
-	}
 	/* Simply ioremap since it may be a shared register zone */
-	regs = devm_ioremap(dev, res->start, resource_size(res));
+	regs = devm_platform_ioremap_resource_byname(pdev, "hhi");

Given the comment, this one should probably be skipped.

Maxime

maintainer
#11 lore raw

Re: [PATCH 05/14] drm/meson: move to devm_platform_ioremap_resource() usage

Quoted 44 lines · Maxime Ripard
Quoted 43 lines · Anusha Srivatsa

Replace platform_get_resource_byname + devm_ioremap with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
@rule_3@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource_byname(pdev,mem,name);

<...

drivers/gpu/drm/meson/meson_drv.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);
---
  drivers/gpu/drm/meson/meson_drv.c | 9 +--------
  1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +0 -1
index 81d2ee37e7732dca89d02347b9c972300b38771a..6c805805b7a7f675f8bb03944318972eb4df864e 100644
@@ -184,7 +184,6 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
  	const struct meson_drm_match_data *match;
  	struct meson_drm *priv;
  	struct drm_device *drm;
-	struct resource *res;
  	void __iomem *regs;
  	int ret, i;
 
@@ -220,14 +219,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
  	}
 
Quoted 13 lines

drivers/gpu/drm/meson/meson_drv.c static int meson_drv_bind_master(struct device *dev, bool has_components) · line 223

Quoted 10 lines
drivers/gpu/drm/meson/meson_drv.c +1 -7
  	priv->io_base = regs;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi");
-	if (!res) {
-		ret = -EINVAL;
-		goto free_drm;
-	}
  	/* Simply ioremap since it may be a shared register zone */
-	regs = devm_ioremap(dev, res->start, resource_size(res));
+	regs = devm_platform_ioremap_resource_byname(pdev, "hhi");

Given the comment, this one should probably be skipped.

Yes please skip this one.

Thanks,
Neil

Quoted 1 line

Maxime

#12 lore raw

PATCH 6/14 drm/mxsfb: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 Marek Vasut <[email protected]>
Cc Stefan Agner <[email protected]>
---
 drivers/gpu/drm/mxsfb/lcdif_drv.c | 4 +---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/mxsfb/lcdif_drv.c +1 -3
index 8ee00f59ca821cea8e823e7100fb4d7534283994..fcb2a7517377e9a5bbd2997c578c579b1b079f92 100644
@@ -134,7 +134,6 @@ static int lcdif_load(struct drm_device *drm)
 {
 	struct platform_device *pdev = to_platform_device(drm->dev);
 	struct lcdif_drm_private *lcdif;
-	struct resource *res;
 	int ret;
 
 	lcdif = devm_kzalloc(&pdev->dev, sizeof(*lcdif), GFP_KERNEL);
@@ -144,8 +143,7 @@ static int lcdif_load(struct drm_device *drm)
 	lcdif->drm = drm;
 	drm->dev_private = lcdif;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	lcdif->base = devm_ioremap_resource(drm->dev, res);
+	lcdif->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(lcdif->base))
 		return PTR_ERR(lcdif->base);
 
drivers/gpu/drm/mxsfb/mxsfb_drv.c +1 -3
index 59020862cf65e5cc488903f1263ed16dfbce06f9..377d4c4c9979ad9538cfec5464827a82936f811b 100644
@@ -215,7 +215,6 @@ static int mxsfb_load(struct drm_device *drm,
 {
 	struct platform_device *pdev = to_platform_device(drm->dev);
 	struct mxsfb_drm_private *mxsfb;
-	struct resource *res;
 	int ret;
 
 	mxsfb = devm_kzalloc(&pdev->dev, sizeof(*mxsfb), GFP_KERNEL);
@@ -226,8 +225,7 @@ static int mxsfb_load(struct drm_device *drm,
 	drm->dev_private = mxsfb;
 	mxsfb->devdata = devdata;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	mxsfb->base = devm_ioremap_resource(drm->dev, res);
+	mxsfb->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(mxsfb->base))
 		return PTR_ERR(mxsfb->base);
 
Signature · 1 line
2.47.0
maintainer Reviewed-by on v1 6/14
#13 lore raw

Re: [PATCH 06/14] drm/mxsfb: move to devm_platform_ioremap_resource() usage

Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 3 lines
Cc Marek Vasut <[email protected]>
Cc Stefan Agner <[email protected]>

Maxime

#14 lore raw

PATCH 7/14 drm/rockchip: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 <[email protected]>
Cc Heiko Stübner <[email protected]>
Cc Andy Yan <[email protected]>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1 -3
index 57747f1cff26e444ef3569983d6a7f7922f03ff7..4c639f7c868907fc35ce22f2ef7e281ad85c2d9e 100644
@@ -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);
Signature · 1 line
2.47.0
#15 lore raw

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

kernel test robot noticed the following build errors:

Hi Anusha,

kernel test robot noticed the following build errors:

[auto build test ERROR on c4b9570cfb63501638db720f3bee9f6dfd044b82]

url:    https://github.com/intel-lab-lkp/linux/commits/Anusha-Srivatsa/drm-aspeed-move-to-devm_platform_ioremap_resource-usage/20250129-063524
base:   c4b9570cfb63501638db720f3bee9f6dfd044b82
patch link:    https://lore.kernel.org/r/20250128-cocci-memory-api-v1-7-0d1609a29587%40redhat.com
patch subject: [PATCH 07/14] drm/rockchip: move to devm_platform_ioremap_resource() usage
config: loongarch-randconfig-001-20250129 (https://download.01.org/0day-ci/archive/20250129/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250129/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/gpu/drm/rockchip/rockchip_drm_vop.c: In function 'vop_bind':

>> drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34: error: 'res' undeclared (first use in this function); did you mean 'ret'?
    2212 |         vop->len = resource_size(res);
         |                                  ^~~
         |                                  ret

drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34: note: each undeclared identifier is reported only once for each function it appears in

vim +2212 drivers/gpu/drm/rockchip/rockchip_drm_vop.c

69c34e41f5d4e8 Yakir Yang          2016-07-24  2183  
2048e3286f347d Mark Yao            2014-08-22  2184  static int vop_bind(struct device *dev, struct device *master, void *data)
2048e3286f347d Mark Yao            2014-08-22  2185  {
2048e3286f347d Mark Yao            2014-08-22  2186  	struct platform_device *pdev = to_platform_device(dev);
2048e3286f347d Mark Yao            2014-08-22  2187  	const struct vop_data *vop_data;
2048e3286f347d Mark Yao            2014-08-22  2188  	struct drm_device *drm_dev = data;
2048e3286f347d Mark Yao            2014-08-22  2189  	struct vop *vop;
3ea68922fc4148 Heiko Stuebner      2015-04-20  2190  	int ret, irq;
2048e3286f347d Mark Yao            2014-08-22  2191  
a67719d182291b Mark Yao            2015-12-15  2192  	vop_data = of_device_get_match_data(dev);
2048e3286f347d Mark Yao            2014-08-22  2193  	if (!vop_data)
2048e3286f347d Mark Yao            2014-08-22  2194  		return -ENODEV;
2048e3286f347d Mark Yao            2014-08-22  2195  
2048e3286f347d Mark Yao            2014-08-22  2196  	/* Allocate vop struct and its vop_win array */
29adeb4f954b2e Gustavo A. R. Silva 2018-08-26  2197  	vop = devm_kzalloc(dev, struct_size(vop, win, vop_data->win_size),
29adeb4f954b2e Gustavo A. R. Silva 2018-08-26  2198  			   GFP_KERNEL);
2048e3286f347d Mark Yao            2014-08-22  2199  	if (!vop)
2048e3286f347d Mark Yao            2014-08-22  2200  		return -ENOMEM;
2048e3286f347d Mark Yao            2014-08-22  2201  
2048e3286f347d Mark Yao            2014-08-22  2202  	vop->dev = dev;
2048e3286f347d Mark Yao            2014-08-22  2203  	vop->data = vop_data;
2048e3286f347d Mark Yao            2014-08-22  2204  	vop->drm_dev = drm_dev;
2048e3286f347d Mark Yao            2014-08-22  2205  	dev_set_drvdata(dev, vop);
2048e3286f347d Mark Yao            2014-08-22  2206  
2048e3286f347d Mark Yao            2014-08-22  2207  	vop_win_init(vop);
2048e3286f347d Mark Yao            2014-08-22  2208  
a9f1c21b76a84b Anusha Srivatsa     2025-01-28  2209  	vop->regs = devm_platform_ioremap_resource(pdev, 0);
2048e3286f347d Mark Yao            2014-08-22  2210  	if (IS_ERR(vop->regs))
2048e3286f347d Mark Yao            2014-08-22  2211  		return PTR_ERR(vop->regs);
f8c242908ad15b Yang Yingliang      2022-04-22 @2212  	vop->len = resource_size(res);
2048e3286f347d Mark Yao            2014-08-22  2213  
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2214  	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2215  	if (res) {
7ae7a6211fe725 Hugh Cole-Baker     2021-10-19  2216  		if (vop_data->lut_size != 1024 && vop_data->lut_size != 256) {
7ae7a6211fe725 Hugh Cole-Baker     2021-10-19  2217  			DRM_DEV_ERROR(dev, "unsupported gamma LUT size %d\n", vop_data->lut_size);
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2218  			return -EINVAL;
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2219  		}
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2220  		vop->lut_regs = devm_ioremap_resource(dev, res);
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2221  		if (IS_ERR(vop->lut_regs))
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2222  			return PTR_ERR(vop->lut_regs);
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2223  	}
b23ab6ac6d768f Ezequiel Garcia     2019-10-10  2224  
2048e3286f347d Mark Yao            2014-08-22  2225  	vop->regsbak = devm_kzalloc(dev, vop->len, GFP_KERNEL);
2048e3286f347d Mark Yao            2014-08-22  2226  	if (!vop->regsbak)
2048e3286f347d Mark Yao            2014-08-22  2227  		return -ENOMEM;
2048e3286f347d Mark Yao            2014-08-22  2228  
3ea68922fc4148 Heiko Stuebner      2015-04-20  2229  	irq = platform_get_irq(pdev, 0);
3ea68922fc4148 Heiko Stuebner      2015-04-20  2230  	if (irq < 0) {
d8dd68045c5879 Haneen Mohammed     2017-09-15  2231  		DRM_DEV_ERROR(dev, "cannot find irq for vop\n");
3ea68922fc4148 Heiko Stuebner      2015-04-20  2232  		return irq;
2048e3286f347d Mark Yao            2014-08-22  2233  	}
3ea68922fc4148 Heiko Stuebner      2015-04-20  2234  	vop->irq = (unsigned int)irq;
2048e3286f347d Mark Yao            2014-08-22  2235  
2048e3286f347d Mark Yao            2014-08-22  2236  	spin_lock_init(&vop->reg_lock);
2048e3286f347d Mark Yao            2014-08-22  2237  	spin_lock_init(&vop->irq_lock);
e334d48b2cd4aa zain wang           2018-03-09  2238  	mutex_init(&vop->vop_lock);
2048e3286f347d Mark Yao            2014-08-22  2239  
2048e3286f347d Mark Yao            2014-08-22  2240  	ret = vop_create_crtc(vop);
2048e3286f347d Mark Yao            2014-08-22  2241  	if (ret)
5f9e93fed4d45e Marc Zyngier        2018-02-20  2242  		return ret;
2048e3286f347d Mark Yao            2014-08-22  2243  
2048e3286f347d Mark Yao            2014-08-22  2244  	pm_runtime_enable(&pdev->dev);
5182c1a556d7ff Yakir Yang          2016-07-24  2245  
5e570373c015b6 Jeffy Chen          2017-04-06  2246  	ret = vop_initial(vop);
5e570373c015b6 Jeffy Chen          2017-04-06  2247  	if (ret < 0) {
d8dd68045c5879 Haneen Mohammed     2017-09-15  2248  		DRM_DEV_ERROR(&pdev->dev,
d8dd68045c5879 Haneen Mohammed     2017-09-15  2249  			      "cannot initial vop dev - err %d\n", ret);
5e570373c015b6 Jeffy Chen          2017-04-06  2250  		goto err_disable_pm_runtime;
5e570373c015b6 Jeffy Chen          2017-04-06  2251  	}
5e570373c015b6 Jeffy Chen          2017-04-06  2252  
5f9e93fed4d45e Marc Zyngier        2018-02-20  2253  	ret = devm_request_irq(dev, vop->irq, vop_isr,
5f9e93fed4d45e Marc Zyngier        2018-02-20  2254  			       IRQF_SHARED, dev_name(dev), vop);
5f9e93fed4d45e Marc Zyngier        2018-02-20  2255  	if (ret)
5f9e93fed4d45e Marc Zyngier        2018-02-20  2256  		goto err_disable_pm_runtime;
5f9e93fed4d45e Marc Zyngier        2018-02-20  2257  
1f0f0151517278 Sandy Huang         2018-08-30  2258  	if (vop->data->feature & VOP_FEATURE_INTERNAL_RGB) {
03db8f25cf16c5 Michael Riesch      2023-01-24  2259  		vop->rgb = rockchip_rgb_init(dev, &vop->crtc, vop->drm_dev, 0);
1f0f0151517278 Sandy Huang         2018-08-30  2260  		if (IS_ERR(vop->rgb)) {
1f0f0151517278 Sandy Huang         2018-08-30  2261  			ret = PTR_ERR(vop->rgb);
1f0f0151517278 Sandy Huang         2018-08-30  2262  			goto err_disable_pm_runtime;
1f0f0151517278 Sandy Huang         2018-08-30  2263  		}
1f0f0151517278 Sandy Huang         2018-08-30  2264  	}
1f0f0151517278 Sandy Huang         2018-08-30  2265  
421be3ee36a497 Robin Murphy        2022-04-05  2266  	rockchip_drm_dma_init_device(drm_dev, dev);
421be3ee36a497 Robin Murphy        2022-04-05  2267  
2048e3286f347d Mark Yao            2014-08-22  2268  	return 0;
8c763c9b1072c9 Sean Paul           2016-09-16  2269  
5e570373c015b6 Jeffy Chen          2017-04-06  2270  err_disable_pm_runtime:
5e570373c015b6 Jeffy Chen          2017-04-06  2271  	pm_runtime_disable(&pdev->dev);
5e570373c015b6 Jeffy Chen          2017-04-06  2272  	vop_destroy_crtc(vop);
8c763c9b1072c9 Sean Paul           2016-09-16  2273  	return ret;
2048e3286f347d Mark Yao            2014-08-22  2274  }
2048e3286f347d Mark Yao            2014-08-22  2275  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#16 lore raw

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

In reply to Anusha Srivatsa
Quoted 36 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Cc Sandy Huang <[email protected]>
Cc Heiko Stübner <[email protected]>
Cc Andy Yan <[email protected]>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +0 -1
index 57747f1cff26e444ef3569983d6a7f7922f03ff7..4c639f7c868907fc35ce22f2ef7e281ad85c2d9e 100644
@@ -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);

drivers/gpu/drm/rockchip/rockchip_drm_vop.c static int vop_bind(struct device *dev, struct device *master, void *data) · line 2212

Quoted 9 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1 -2
@@ -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

#17 lore raw

PATCH 8/14 drm/sprd: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

Replace platform_get_resource + devm_ioremap
with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
@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);

Cc Chunyan Zhang <[email protected]>
Cc Dmitry Baryshkov <[email protected]>
---
 drivers/gpu/drm/sprd/sprd_dpu.c | 9 +--------
 drivers/gpu/drm/sprd/sprd_dsi.c | 9 +--------
 2 files changed, 2 insertions(+), 16 deletions(-)
drivers/gpu/drm/sprd/sprd_dpu.c +1 -8
index cb2816985305fd19eac27413c214681a5a1e9ffa..65cd5aa1634eee5a6735ccffa4ee3979844d92ce 100644
@@ -784,16 +784,9 @@ static int sprd_dpu_context_init(struct sprd_dpu *dpu,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct dpu_context *ctx = &dpu->ctx;
-	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "failed to get I/O resource\n");
-		return -EINVAL;
-	}
-
-	ctx->base = devm_ioremap(dev, res->start, resource_size(res));
+	ctx->base = devm_platform_ioremap_resource(pdev, 0);
 	if (!ctx->base) {
 		dev_err(dev, "failed to map dpu registers\n");
 		return -EFAULT;
drivers/gpu/drm/sprd/sprd_dsi.c +1 -8
index 8fc26479bb6bce0aa94914f49d0986a7e19326c1..1668bb4166ab0ad3812c5654244544a9caf249a6 100644
@@ -901,15 +901,8 @@ static int sprd_dsi_context_init(struct sprd_dsi *dsi,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct dsi_context *ctx = &dsi->ctx;
-	struct resource *res;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "failed to get I/O resource\n");
-		return -EINVAL;
-	}
-
-	ctx->base = devm_ioremap(dev, res->start, resource_size(res));
+	ctx->base = devm_platform_ioremap_resource(pdev, 0);
 	if (!ctx->base) {
 		drm_err(dsi->drm, "failed to map dsi host registers\n");
 		return -ENXIO;
Signature · 1 line
2.47.0
#18 lore raw

PATCH 9/14 drm/sti: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

Replace platform_get_resource/_byname + devm_ioremap with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:

@rule@
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);

and
@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);

---
 drivers/gpu/drm/sti/sti_compositor.c | 10 +---------
 drivers/gpu/drm/sti/sti_dvo.c        | 10 +---------
 drivers/gpu/drm/sti/sti_hda.c        | 10 +---------
 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 +---------
 7 files changed, 7 insertions(+), 64 deletions(-)
drivers/gpu/drm/sti/sti_compositor.c +1 -9
index 063f82d23d80c4ba83624a0066a18416a2b37351..7aefce6706ba2cd7d97a33228c9b9812edecf06f 100644
@@ -177,7 +177,6 @@ static int sti_compositor_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	struct device_node *vtg_np;
 	struct sti_compositor *compo;
-	struct resource *res;
 	unsigned int i;
 
 	compo = devm_kzalloc(dev, sizeof(*compo), GFP_KERNEL);
@@ -194,14 +193,7 @@ static int sti_compositor_probe(struct platform_device *pdev)
 
 	memcpy(&compo->data, of_match_node(compositor_of_match, np)->data,
 	       sizeof(struct sti_compositor_data));
-
-	/* Get Memory ressources */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		DRM_ERROR("Get memory resource failed\n");
-		return -ENXIO;
-	}
-	compo->regs = devm_ioremap(dev, res->start, resource_size(res));
+	compo->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (compo->regs == NULL) {
 		DRM_ERROR("Register mapping failed\n");
 		return -ENXIO;
drivers/gpu/drm/sti/sti_dvo.c +1 -9
index c6c2abaa1891cd3ea025805b50d275ec314512c3..660588f01f90950a9b2c180ab230188c19901f26 100644
@@ -511,7 +511,6 @@ static int sti_dvo_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct sti_dvo *dvo;
-	struct resource *res;
 	struct device_node *np = dev->of_node;
 
 	DRM_INFO("%s\n", __func__);
@@ -523,14 +522,7 @@ static int sti_dvo_probe(struct platform_device *pdev)
 	}
 
 	dvo->dev = pdev->dev;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dvo-reg");
-	if (!res) {
-		DRM_ERROR("Invalid dvo resource\n");
-		return -ENOMEM;
-	}
-	dvo->regs = devm_ioremap(dev, res->start,
-			resource_size(res));
+	dvo->regs = devm_platform_ioremap_resource_byname(pdev, "dvo-reg");
 	if (!dvo->regs)
 		return -ENOMEM;
 
drivers/gpu/drm/sti/sti_hda.c +1 -9
index b12863bea95559c4f874eb94cea8938609d435d4..28fde4c568d0069ecf2f2f69f5be0e87c1d5f4f3 100644
@@ -741,7 +741,6 @@ static int sti_hda_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct sti_hda *hda;
-	struct resource *res;
 
 	DRM_INFO("%s\n", __func__);
 
@@ -750,14 +749,7 @@ static int sti_hda_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	hda->dev = pdev->dev;
-
-	/* Get resources */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hda-reg");
-	if (!res) {
-		DRM_ERROR("Invalid hda resource\n");
-		return -ENOMEM;
-	}
-	hda->regs = devm_ioremap(dev, res->start, resource_size(res));
+	hda->regs = devm_platform_ioremap_resource_byname(pdev, "hda-reg");
 	if (!hda->regs)
 		return -ENOMEM;
 
drivers/gpu/drm/sti/sti_hdmi.c +1 -10
index ca2fe17de4a5d1e0199e59a97e6c7601e139ed9e..666143c48b0d0f2c20cd26323ddbc8e69d966622 100644
@@ -1380,7 +1380,6 @@ static int sti_hdmi_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct sti_hdmi *hdmi;
 	struct device_node *np = dev->of_node;
-	struct resource *res;
 	struct device_node *ddc;
 	int ret;
 
@@ -1399,15 +1398,7 @@ static int sti_hdmi_probe(struct platform_device *pdev)
 	}
 
 	hdmi->dev = pdev->dev;
-
-	/* Get resources */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg");
-	if (!res) {
-		DRM_ERROR("Invalid hdmi resource\n");
-		ret = -ENOMEM;
-		goto release_adapter;
-	}
-	hdmi->regs = devm_ioremap(dev, res->start, resource_size(res));
+	hdmi->regs = devm_platform_ioremap_resource_byname(pdev, "hdmi-reg");
 	if (!hdmi->regs) {
 		ret = -ENOMEM;
 		goto release_adapter;
drivers/gpu/drm/sti/sti_hqvdp.c +1 -9
index 0f658709c9d0d398c4eed65202443db9d0b41f8c..420395598d119a403d531211022e6005d6a2bd59 100644
@@ -1356,7 +1356,6 @@ static int sti_hqvdp_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *vtg_np;
 	struct sti_hqvdp *hqvdp;
-	struct resource *res;
 
 	DRM_DEBUG_DRIVER("\n");
 
@@ -1367,14 +1366,7 @@ static int sti_hqvdp_probe(struct platform_device *pdev)
 	}
 
 	hqvdp->dev = dev;
-
-	/* Get Memory resources */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		DRM_ERROR("Get memory resource failed\n");
-		return -ENXIO;
-	}
-	hqvdp->regs = devm_ioremap(dev, res->start, resource_size(res));
+	hqvdp->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (!hqvdp->regs) {
 		DRM_ERROR("Register mapping failed\n");
 		return -ENXIO;
drivers/gpu/drm/sti/sti_tvout.c +1 -9
index af6c06f448c4819def8cc0d0836e30f991529690..0bebe815f5e7567f84388af93723a6fa7d2cc7a2 100644
@@ -838,7 +838,6 @@ static int sti_tvout_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *node = dev->of_node;
 	struct sti_tvout *tvout;
-	struct resource *res;
 
 	DRM_INFO("%s\n", __func__);
 
@@ -850,14 +849,7 @@ static int sti_tvout_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	tvout->dev = dev;
-
-	/* get memory resources */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tvout-reg");
-	if (!res) {
-		DRM_ERROR("Invalid glue resource\n");
-		return -ENOMEM;
-	}
-	tvout->regs = devm_ioremap(dev, res->start, resource_size(res));
+	tvout->regs = devm_platform_ioremap_resource_byname(pdev, "tvout-reg");
 	if (!tvout->regs)
 		return -ENOMEM;
 
drivers/gpu/drm/sti/sti_vtg.c +1 -9
index 5ba469b711b5318e9e9e6d8df127fb8933d1fac1..b5353fe774d72fd629ecd3ef75a5d2817ca8617f 100644
@@ -380,20 +380,12 @@ static int vtg_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct sti_vtg *vtg;
-	struct resource *res;
 	int ret;
 
 	vtg = devm_kzalloc(dev, sizeof(*vtg), GFP_KERNEL);
 	if (!vtg)
 		return -ENOMEM;
-
-	/* Get Memory ressources */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		DRM_ERROR("Get memory resource failed\n");
-		return -ENOMEM;
-	}
-	vtg->regs = devm_ioremap(dev, res->start, resource_size(res));
+	vtg->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (!vtg->regs) {
 		DRM_ERROR("failed to remap I/O memory\n");
 		return -ENOMEM;
Signature · 1 line
2.47.0
#19 lore raw

Re: [PATCH 09/14] drm/sti: move to devm_platform_ioremap_resource() usage

Quoted 40 lines · Anusha Srivatsa

Replace platform_get_resource/_byname + devm_ioremap with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:

@rule@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource_byname(pdev,mem,name);

<...

drivers/gpu/drm/sti/sti_dvo.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);

and
@rule_2@
identifier res;
expression ioremap;
identifier pdev;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource(pdev,...);

<...

drivers/gpu/drm/sti/sti_dvo.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource(pdev,0);
Quoted 2 lines

Hi Anusha,

Thanks again for your work,

Quoted 71 lines
---
 drivers/gpu/drm/sti/sti_compositor.c | 10 +---------
 drivers/gpu/drm/sti/sti_dvo.c        | 10 +---------
 drivers/gpu/drm/sti/sti_hda.c        | 10 +---------
 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 +---------
 7 files changed, 7 insertions(+), 64 deletions(-)
drivers/gpu/drm/sti/sti_compositor.c +1 -9
index 063f82d23d80c4ba83624a0066a18416a2b37351..7aefce6706ba2cd7d97a33228c9b9812edecf06f 100644
@@ -177,7 +177,6 @@ static int sti_compositor_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	struct device_node *vtg_np;
 	struct sti_compositor *compo;
-	struct resource *res;
 	unsigned int i;
 
 	compo = devm_kzalloc(dev, sizeof(*compo), GFP_KERNEL);
@@ -194,14 +193,7 @@ static int sti_compositor_probe(struct platform_device *pdev)
 
 	memcpy(&compo->data, of_match_node(compositor_of_match, np)->data,
 	       sizeof(struct sti_compositor_data));
-
-	/* Get Memory ressources */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		DRM_ERROR("Get memory resource failed\n");
-		return -ENXIO;
-	}
-	compo->regs = devm_ioremap(dev, res->start, resource_size(res));
+	compo->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (compo->regs == NULL) {
 		DRM_ERROR("Register mapping failed\n");
 		return -ENXIO;
drivers/gpu/drm/sti/sti_dvo.c +1 -9
index c6c2abaa1891cd3ea025805b50d275ec314512c3..660588f01f90950a9b2c180ab230188c19901f26 100644
@@ -511,7 +511,6 @@ static int sti_dvo_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct sti_dvo *dvo;
-	struct resource *res;
 	struct device_node *np = dev->of_node;
 
 	DRM_INFO("%s\n", __func__);
@@ -523,14 +522,7 @@ static int sti_dvo_probe(struct platform_device *pdev)
 	}
 
 	dvo->dev = pdev->dev;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dvo-reg");
-	if (!res) {
-		DRM_ERROR("Invalid dvo resource\n");
-		return -ENOMEM;
-	}
-	dvo->regs = devm_ioremap(dev, res->start,
-			resource_size(res));
+	dvo->regs = devm_platform_ioremap_resource_byname(pdev, "dvo-reg");
 	if (!dvo->regs)
 		return -ENOMEM;
 
drivers/gpu/drm/sti/sti_hda.c +0 -0
index b12863bea95559c4f874eb94cea8938609d435d4..28fde4c568d0069ecf2f2f69f5be0e87c1d5f4f3 100644

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device *pdev) · line 744

Quoted 4 lines
drivers/gpu/drm/sti/sti_hda.c +0 -1
@@ -741,7 +741,6 @@ static int sti_hda_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct sti_hda *hda;
-	struct resource *res;

There is a compile error, using an ARM toolchain on this patch and several others.

struct ressource *res is used on other places, which does not allow to remove the instanciation here.

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c: In function ‘sti_hda_probe’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9: error:
‘res’ undeclared (first use in this function)
  756 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |         ^~~ /local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9: note:
each undeclared identifier is reported only once for each function it appears in CC [M]  drivers/gpu/drm/nouveau/nvkm/core/event.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/sti/sti_hda.o] Error 1
make[8]: *** Waiting for unfinished jobs....

This can be applied:

* regarding [PATCH 07/14] rockchip driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:
In function ‘vop_bind’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
error: ‘res’ undeclared (first use in this function); did you mean ‘ret’? 2212 |         vop->len = resource_size(res);
      |                                  ^~~
      |                                  ret /local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
note: each undeclared identifier is reported only once for each function it appears in
  CC [M]  drivers/gpu/drm/nouveau/nvif/fifo.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/rockchip/rockchip_drm_vop.o] Error 1
make[8]: *** Waiting for unfinished jobs....

* regarding  [PATCH 13/14] vc4 driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c: In function ‘vc5_hdmi_init_resources’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9: error:
‘res’ undeclared (first use in this function); did you mean ‘ret’? 2961 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hd"); |         ^~~
      |         ret /local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9: note:
each undeclared identifier is reported only once for each function it appears in make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/vc4/vc4_hdmi.o] Error 1
make[8]: *** Waiting for unfinished jobs....

Regards,
Raphaël

Quoted 131 lines
drivers/gpu/drm/sti/sti_hda.c +1 -8
 	DRM_INFO("%s\n", __func__);
 
@@ -750,14 +749,7 @@ static int sti_hda_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	hda->dev = pdev->dev;
-
-	/* Get resources */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hda-reg");
-	if (!res) {
-		DRM_ERROR("Invalid hda resource\n");
-		return -ENOMEM;
-	}
-	hda->regs = devm_ioremap(dev, res->start, resource_size(res));
+	hda->regs = devm_platform_ioremap_resource_byname(pdev, "hda-reg");
 	if (!hda->regs)
 		return -ENOMEM;
 
drivers/gpu/drm/sti/sti_hdmi.c +1 -10
index ca2fe17de4a5d1e0199e59a97e6c7601e139ed9e..666143c48b0d0f2c20cd26323ddbc8e69d966622 100644
@@ -1380,7 +1380,6 @@ static int sti_hdmi_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct sti_hdmi *hdmi;
 	struct device_node *np = dev->of_node;
-	struct resource *res;
 	struct device_node *ddc;
 	int ret;
 
@@ -1399,15 +1398,7 @@ static int sti_hdmi_probe(struct platform_device *pdev)
 	}
 
 	hdmi->dev = pdev->dev;
-
-	/* Get resources */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg");
-	if (!res) {
-		DRM_ERROR("Invalid hdmi resource\n");
-		ret = -ENOMEM;
-		goto release_adapter;
-	}
-	hdmi->regs = devm_ioremap(dev, res->start, resource_size(res));
+	hdmi->regs = devm_platform_ioremap_resource_byname(pdev, "hdmi-reg");
 	if (!hdmi->regs) {
 		ret = -ENOMEM;
 		goto release_adapter;
drivers/gpu/drm/sti/sti_hqvdp.c +1 -9
index 0f658709c9d0d398c4eed65202443db9d0b41f8c..420395598d119a403d531211022e6005d6a2bd59 100644
@@ -1356,7 +1356,6 @@ static int sti_hqvdp_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *vtg_np;
 	struct sti_hqvdp *hqvdp;
-	struct resource *res;
 
 	DRM_DEBUG_DRIVER("\n");
 
@@ -1367,14 +1366,7 @@ static int sti_hqvdp_probe(struct platform_device *pdev)
 	}
 
 	hqvdp->dev = dev;
-
-	/* Get Memory resources */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		DRM_ERROR("Get memory resource failed\n");
-		return -ENXIO;
-	}
-	hqvdp->regs = devm_ioremap(dev, res->start, resource_size(res));
+	hqvdp->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (!hqvdp->regs) {
 		DRM_ERROR("Register mapping failed\n");
 		return -ENXIO;
drivers/gpu/drm/sti/sti_tvout.c +1 -9
index af6c06f448c4819def8cc0d0836e30f991529690..0bebe815f5e7567f84388af93723a6fa7d2cc7a2 100644
@@ -838,7 +838,6 @@ static int sti_tvout_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *node = dev->of_node;
 	struct sti_tvout *tvout;
-	struct resource *res;
 
 	DRM_INFO("%s\n", __func__);
 
@@ -850,14 +849,7 @@ static int sti_tvout_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	tvout->dev = dev;
-
-	/* get memory resources */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tvout-reg");
-	if (!res) {
-		DRM_ERROR("Invalid glue resource\n");
-		return -ENOMEM;
-	}
-	tvout->regs = devm_ioremap(dev, res->start, resource_size(res));
+	tvout->regs = devm_platform_ioremap_resource_byname(pdev, "tvout-reg");
 	if (!tvout->regs)
 		return -ENOMEM;
 
drivers/gpu/drm/sti/sti_vtg.c +1 -9
index 5ba469b711b5318e9e9e6d8df127fb8933d1fac1..b5353fe774d72fd629ecd3ef75a5d2817ca8617f 100644
@@ -380,20 +380,12 @@ static int vtg_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct sti_vtg *vtg;
-	struct resource *res;
 	int ret;
 
 	vtg = devm_kzalloc(dev, sizeof(*vtg), GFP_KERNEL);
 	if (!vtg)
 		return -ENOMEM;
-
-	/* Get Memory ressources */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		DRM_ERROR("Get memory resource failed\n");
-		return -ENOMEM;
-	}
-	vtg->regs = devm_ioremap(dev, res->start, resource_size(res));
+	vtg->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (!vtg->regs) {
 		DRM_ERROR("failed to remap I/O memory\n");
 		return -ENOMEM;
#20 lore raw

Re: [PATCH 09/14] drm/sti: move to devm_platform_ioremap_resource() usage

Quoted 204 lines · Raphael Gallais-Pou
Quoted 40 lines · Anusha Srivatsa

Replace platform_get_resource/_byname + devm_ioremap with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:

@rule@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource_byname(pdev,mem,name);

<...

drivers/gpu/drm/sti/sti_dvo.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);

and
@rule_2@
identifier res;
expression ioremap;
identifier pdev;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource(pdev,...);

<...

drivers/gpu/drm/sti/sti_dvo.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource(pdev,0);
Quoted 2 lines

Hi Anusha,

Thanks again for your work,

Review

Quoted 11 lines
---
 drivers/gpu/drm/sti/sti_compositor.c | 10 +---------
 drivers/gpu/drm/sti/sti_dvo.c        | 10 +---------
 drivers/gpu/drm/sti/sti_hda.c        | 10 +---------
 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 +---------
 7 files changed, 7 insertions(+), 64 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_compositor.c

Quoted 1 line

index

063f82d23d80c4ba83624a0066a18416a2b37351..7aefce6706ba2cd7d97a33228c9b9812edecf06f 100644

drivers/gpu/drm/sti/sti_compositor.c static int sti_compositor_probe(struct

Quoted 3 lines
drivers/gpu/drm/sti/sti_compositor.c +0 -0
@@ -177,7 +177,6 @@ static int sti_compositor_probe(struct

platform_device *pdev)

drivers/gpu/drm/sti/sti_compositor.c static int sti_compositor_probe(struct

Quoted 8 lines
drivers/gpu/drm/sti/sti_compositor.c +0 -1
      struct device_node *np = dev->of_node;
      struct device_node *vtg_np;
      struct sti_compositor *compo;
-     struct resource *res;
      unsigned int i;
 
      compo = devm_kzalloc(dev, sizeof(*compo), GFP_KERNEL);
@@ -194,14 +193,7 @@ static int sti_compositor_probe(struct

platform_device *pdev)

Review

Quoted 16 lines
drivers/gpu/drm/sti/sti_compositor.c +1 -8
      memcpy(&compo->data, of_match_node(compositor_of_match, np)->data,
             sizeof(struct sti_compositor_data));
-
-     /* Get Memory ressources */
-     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     if (res == NULL) {
-             DRM_ERROR("Get memory resource failed\n");
-             return -ENXIO;
-     }
-     compo->regs = devm_ioremap(dev, res->start, resource_size(res));
+     compo->regs = devm_platform_ioremap_resource(pdev, 0);
      if (compo->regs == NULL) {
              DRM_ERROR("Register mapping failed\n");
              return -ENXIO;
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_dvo.c

Quoted 1 line

index

c6c2abaa1891cd3ea025805b50d275ec314512c3..660588f01f90950a9b2c180ab230188c19901f26 100644

drivers/gpu/drm/sti/sti_dvo.c static int sti_dvo_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_dvo.c +0 -0
@@ -511,7 +511,6 @@ static int sti_dvo_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_dvo.c static int sti_dvo_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_dvo.c +0 -1
 {
      struct device *dev = &pdev->dev;
      struct sti_dvo *dvo;
-     struct resource *res;
      struct device_node *np = dev->of_node;
 
      DRM_INFO("%s\n", __func__);
@@ -523,14 +522,7 @@ static int sti_dvo_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_dvo.c static int sti_dvo_probe(struct platform_device *pdev)

Quoted 5 lines
drivers/gpu/drm/sti/sti_dvo.c +0 -2
      }
 
      dvo->dev = pdev->dev;
-
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"dvo-reg");

Review

Quoted 11 lines
drivers/gpu/drm/sti/sti_dvo.c +1 -6
-     if (!res) {
-             DRM_ERROR("Invalid dvo resource\n");
-             return -ENOMEM;
-     }
-     dvo->regs = devm_ioremap(dev, res->start,
-                     resource_size(res));
+     dvo->regs = devm_platform_ioremap_resource_byname(pdev, "dvo-reg");
      if (!dvo->regs)
              return -ENOMEM;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_hda.c

Quoted 1 line

index

b12863bea95559c4f874eb94cea8938609d435d4..28fde4c568d0069ecf2f2f69f5be0e87c1d5f4f3 100644

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_hda.c +0 -0
@@ -741,7 +741,6 @@ static int sti_hda_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device *pdev) · line 744

Quoted 4 lines
drivers/gpu/drm/sti/sti_hda.c +0 -1
 {
      struct device *dev = &pdev->dev;
      struct sti_hda *hda;
-     struct resource *res;

There is a compile error, using an ARM toolchain on this patch and several others.

struct ressource *res is used on other places, which does not allow to remove
the instanciation here.

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c: In function
‘sti_hda_probe’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9:
error:
‘res’ undeclared (first use in this function)

  756 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
      |         ^~~

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9:
note:
each undeclared identifier is reported only once for each function it appears in
CC [M] drivers/gpu/drm/nouveau/nvkm/core/event.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/sti/sti_hda.o] Error 1
make[8]: *** Waiting for unfinished jobs....

This can be applied:

* regarding [PATCH 07/14] rockchip driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:
In function ‘vop_bind’:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
error: ‘res’ undeclared (first use in this function); did you mean ‘ret’?

 2212 |         vop->len = resource_size(res);
      |                                  ^~~
      |                                  ret

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
note: each undeclared identifier is reported only once for each function it appears in
CC [M] drivers/gpu/drm/nouveau/nvif/fifo.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/rockchip/rockchip_drm_vop.o] Error 1
make[8]: *** Waiting for unfinished jobs....

* regarding [PATCH 13/14] vc4 driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c: In function
‘vc5_hdmi_init_resources’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9:
error:
‘res’ undeclared (first use in this function); did you mean ‘ret’?
2961 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"hd");
      |         ^~~
      |         ret
Quoted 9 lines

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9:
note:
each undeclared identifier is reported only once for each function it appears in
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/vc4/vc4_hdmi.o] Error 1
make[8]: *** Waiting for unfinished jobs....

Raphael,
In the sti_hda_probe, does it make sense to remove the second platform_get_resource_byname() (the one with video-dacs-ctrl resource) and apply the coccinelle transformation to it like the rest of the subsystem? I feel like that should be left as is and the rule should be adjusted to ensure that if "res" is further used then do not remove it. THoughts?

anusha

Quoted 161 lines

Regards,
Raphaël

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device

Quoted 4 lines
drivers/gpu/drm/sti/sti_hda.c +0 -0
      DRM_INFO("%s\n", __func__);
 
@@ -750,14 +749,7 @@ static int sti_hda_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_hda.c +0 -3
              return -ENOMEM;
 
      hda->dev = pdev->dev;
-
-     /* Get resources */
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"hda-reg");

Review

Quoted 10 lines
drivers/gpu/drm/sti/sti_hda.c +1 -5
-     if (!res) {
-             DRM_ERROR("Invalid hda resource\n");
-             return -ENOMEM;
-     }
-     hda->regs = devm_ioremap(dev, res->start, resource_size(res));
+     hda->regs = devm_platform_ioremap_resource_byname(pdev, "hda-reg");
      if (!hda->regs)
              return -ENOMEM;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_hdmi.c

Quoted 1 line

index

ca2fe17de4a5d1e0199e59a97e6c7601e139ed9e..666143c48b0d0f2c20cd26323ddbc8e69d966622 100644

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -0
@@ -1380,7 +1380,6 @@ static int sti_hdmi_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -1
      struct device *dev = &pdev->dev;
      struct sti_hdmi *hdmi;
      struct device_node *np = dev->of_node;
-     struct resource *res;
      struct device_node *ddc;
      int ret;
 
@@ -1399,15 +1398,7 @@ static int sti_hdmi_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -3
      }
 
      hdmi->dev = pdev->dev;
-
-     /* Get resources */
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"hdmi-reg");

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device *pdev)

Quoted 7 lines
drivers/gpu/drm/sti/sti_hdmi.c +1 -6
-     if (!res) {
-             DRM_ERROR("Invalid hdmi resource\n");
-             ret = -ENOMEM;
-             goto release_adapter;
-     }
-     hdmi->regs = devm_ioremap(dev, res->start, resource_size(res));
+     hdmi->regs = devm_platform_ioremap_resource_byname(pdev,

"hdmi-reg");

Review

Quoted 4 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -0
      if (!hdmi->regs) {
              ret = -ENOMEM;
              goto release_adapter;
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_hqvdp.c

Quoted 1 line

index

0f658709c9d0d398c4eed65202443db9d0b41f8c..420395598d119a403d531211022e6005d6a2bd59 100644

drivers/gpu/drm/sti/sti_hqvdp.c static int sti_hqvdp_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_hqvdp.c +0 -0
@@ -1356,7 +1356,6 @@ static int sti_hqvdp_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hqvdp.c static int sti_hqvdp_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_hqvdp.c +0 -1
      struct device *dev = &pdev->dev;
      struct device_node *vtg_np;
      struct sti_hqvdp *hqvdp;
-     struct resource *res;
 
      DRM_DEBUG_DRIVER("\n");
 
@@ -1367,14 +1366,7 @@ static int sti_hqvdp_probe(struct platform_device

*pdev)

Review

Quoted 16 lines
drivers/gpu/drm/sti/sti_hqvdp.c +1 -8
      }
 
      hqvdp->dev = dev;
-
-     /* Get Memory resources */
-     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     if (!res) {
-             DRM_ERROR("Get memory resource failed\n");
-             return -ENXIO;
-     }
-     hqvdp->regs = devm_ioremap(dev, res->start, resource_size(res));
+     hqvdp->regs = devm_platform_ioremap_resource(pdev, 0);
      if (!hqvdp->regs) {
              DRM_ERROR("Register mapping failed\n");
              return -ENXIO;
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_tvout.c

Quoted 1 line

index

af6c06f448c4819def8cc0d0836e30f991529690..0bebe815f5e7567f84388af93723a6fa7d2cc7a2 100644

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -0
@@ -838,7 +838,6 @@ static int sti_tvout_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -1
      struct device *dev = &pdev->dev;
      struct device_node *node = dev->of_node;
      struct sti_tvout *tvout;
-     struct resource *res;
 
      DRM_INFO("%s\n", __func__);
 
@@ -850,14 +849,7 @@ static int sti_tvout_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -3
              return -ENOMEM;
 
      tvout->dev = dev;
-
-     /* get memory resources */
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"tvout-reg");

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_tvout.c +1 -5
-     if (!res) {
-             DRM_ERROR("Invalid glue resource\n");
-             return -ENOMEM;
-     }
-     tvout->regs = devm_ioremap(dev, res->start, resource_size(res));
+     tvout->regs = devm_platform_ioremap_resource_byname(pdev,

"tvout-reg");

Review

Quoted 4 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -0
      if (!tvout->regs)
              return -ENOMEM;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_vtg.c

Quoted 1 line

index

5ba469b711b5318e9e9e6d8df127fb8933d1fac1..b5353fe774d72fd629ecd3ef75a5d2817ca8617f 100644

Quoted 25 lines
drivers/gpu/drm/sti/sti_vtg.c +1 -9
@@ -380,20 +380,12 @@ static int vtg_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
      struct sti_vtg *vtg;
-     struct resource *res;
      int ret;
 
      vtg = devm_kzalloc(dev, sizeof(*vtg), GFP_KERNEL);
      if (!vtg)
              return -ENOMEM;
-
-     /* Get Memory ressources */
-     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     if (!res) {
-             DRM_ERROR("Get memory resource failed\n");
-             return -ENOMEM;
-     }
-     vtg->regs = devm_ioremap(dev, res->start, resource_size(res));
+     vtg->regs = devm_platform_ioremap_resource(pdev, 0);
      if (!vtg->regs) {
              DRM_ERROR("failed to remap I/O memory\n");
              return -ENOMEM;
#21 lore raw

Re: [PATCH 09/14] drm/sti: move to devm_platform_ioremap_resource() usage

Quoted 212 lines · Anusha Srivatsa
Quoted 200 lines · Raphael Gallais-Pou
Quoted 40 lines · Anusha Srivatsa

Replace platform_get_resource/_byname + devm_ioremap with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:

@rule@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource_byname(pdev,mem,name);

<...

drivers/gpu/drm/sti/sti_dvo.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);

and
@rule_2@
identifier res;
expression ioremap;
identifier pdev;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource(pdev,...);

<...

drivers/gpu/drm/sti/sti_dvo.c +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource(pdev,0);
Quoted 2 lines

Hi Anusha,

Thanks again for your work,

Review

Quoted 11 lines
---
 drivers/gpu/drm/sti/sti_compositor.c | 10 +---------
 drivers/gpu/drm/sti/sti_dvo.c        | 10 +---------
 drivers/gpu/drm/sti/sti_hda.c        | 10 +---------
 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 +---------
 7 files changed, 7 insertions(+), 64 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_compositor.c

Quoted 1 line

index

063f82d23d80c4ba83624a0066a18416a2b37351..7aefce6706ba2cd7d97a33228c9b9812edecf06f 100644

drivers/gpu/drm/sti/sti_compositor.c static int sti_compositor_probe(struct

Quoted 3 lines
drivers/gpu/drm/sti/sti_compositor.c +0 -0
@@ -177,7 +177,6 @@ static int sti_compositor_probe(struct

platform_device *pdev)

drivers/gpu/drm/sti/sti_compositor.c static int sti_compositor_probe(struct

Quoted 8 lines
drivers/gpu/drm/sti/sti_compositor.c +0 -1
      struct device_node *np = dev->of_node;
      struct device_node *vtg_np;
      struct sti_compositor *compo;
-     struct resource *res;
      unsigned int i;
 
      compo = devm_kzalloc(dev, sizeof(*compo), GFP_KERNEL);
@@ -194,14 +193,7 @@ static int sti_compositor_probe(struct

platform_device *pdev)

Review

Quoted 15 lines
drivers/gpu/drm/sti/sti_compositor.c +1 -8
      memcpy(&compo->data, of_match_node(compositor_of_match, np)->data,
             sizeof(struct sti_compositor_data));
-
-     /* Get Memory ressources */
-     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     if (res == NULL) {
-             DRM_ERROR("Get memory resource failed\n");
-             return -ENXIO;
-     }
-     compo->regs = devm_ioremap(dev, res->start, resource_size(res));
+     compo->regs = devm_platform_ioremap_resource(pdev, 0);
      if (compo->regs == NULL) {
              DRM_ERROR("Register mapping failed\n");
              return -ENXIO;
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_dvo.c

Quoted 1 line

index

c6c2abaa1891cd3ea025805b50d275ec314512c3..660588f01f90950a9b2c180ab230188c19901f26 100644

drivers/gpu/drm/sti/sti_dvo.c static int sti_dvo_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_dvo.c +0 -0
@@ -511,7 +511,6 @@ static int sti_dvo_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_dvo.c static int sti_dvo_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_dvo.c +0 -1
 {
      struct device *dev = &pdev->dev;
      struct sti_dvo *dvo;
-     struct resource *res;
      struct device_node *np = dev->of_node;
 
      DRM_INFO("%s\n", __func__);
@@ -523,14 +522,7 @@ static int sti_dvo_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_dvo.c static int sti_dvo_probe(struct platform_device *pdev)

Quoted 5 lines
drivers/gpu/drm/sti/sti_dvo.c +0 -2
      }
 
      dvo->dev = pdev->dev;
-
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"dvo-reg");

Review

Quoted 11 lines
drivers/gpu/drm/sti/sti_dvo.c +1 -6
-     if (!res) {
-             DRM_ERROR("Invalid dvo resource\n");
-             return -ENOMEM;
-     }
-     dvo->regs = devm_ioremap(dev, res->start,
-                     resource_size(res));
+     dvo->regs = devm_platform_ioremap_resource_byname(pdev, "dvo-reg");
      if (!dvo->regs)
              return -ENOMEM;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_hda.c

Quoted 1 line

index

b12863bea95559c4f874eb94cea8938609d435d4..28fde4c568d0069ecf2f2f69f5be0e87c1d5f4f3 100644

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_hda.c +0 -0
@@ -741,7 +741,6 @@ static int sti_hda_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device *pdev) · line 744

Quoted 4 lines
drivers/gpu/drm/sti/sti_hda.c +0 -1
 {
      struct device *dev = &pdev->dev;
      struct sti_hda *hda;
-     struct resource *res;

There is a compile error, using an ARM toolchain on this patch and several others.

struct ressource *res is used on other places, which does not allow to remove
the instanciation here.

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c: In function
‘sti_hda_probe’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9:
error:
‘res’ undeclared (first use in this function)

  756 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
      |         ^~~

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/sti/sti_hda.c:756:9:
note:
each undeclared identifier is reported only once for each function it appears in
CC [M] drivers/gpu/drm/nouveau/nvkm/core/event.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/sti/sti_hda.o] Error 1
make[8]: *** Waiting for unfinished jobs....

This can be applied:

* regarding [PATCH 07/14] rockchip driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:
In function ‘vop_bind’:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
error: ‘res’ undeclared (first use in this function); did you mean ‘ret’?

 2212 |         vop->len = resource_size(res);
      |                                  ^~~
      |                                  ret

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/rockchip/rockchip_drm_vop.c:2212:34:
note: each undeclared identifier is reported only once for each function it appears in
CC [M] drivers/gpu/drm/nouveau/nvif/fifo.o
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/rockchip/rockchip_drm_vop.o] Error 1
make[8]: *** Waiting for unfinished jobs....

* regarding [PATCH 13/14] vc4 driver:

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c: In function
‘vc5_hdmi_init_resources’:
/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9:
error:
‘res’ undeclared (first use in this function); did you mean ‘ret’?
2961 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"hd");
      |         ^~~
      |         ret
Quoted 9 lines

/local/home/gallais1/src/drm-misc/drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9:
note:
each undeclared identifier is reported only once for each function it appears in
make[8]: *** [/local/home/gallais1/src/drm-misc/scripts/Makefile.build:194:
drivers/gpu/drm/vc4/vc4_hdmi.o] Error 1
make[8]: *** Waiting for unfinished jobs....

Quoted 8 lines

Raphael,
In the sti_hda_probe, does it make sense to remove the second platform_get_resource_byname() (the one with video-dacs-ctrl resource) and apply the coccinelle transformation to it like the rest of the subsystem? I feel like that should be left as is and the rule should be adjusted to ensure that if "res" is further used then do not remove it. THoughts?

anusha

Hi Anusha,

Agreed. The second platform_get_resource_byname should remain, with struct resource *res.

Regards,
Raphaël

Quoted 158 lines
Quoted 158 lines

Regards,
Raphaël

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_hda.c +0 -0
      DRM_INFO("%s\n", __func__);
 
@@ -750,14 +749,7 @@ static int sti_hda_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hda.c static int sti_hda_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_hda.c +0 -3
              return -ENOMEM;
 
      hda->dev = pdev->dev;
-
-     /* Get resources */
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"hda-reg");

Review

Quoted 10 lines
drivers/gpu/drm/sti/sti_hda.c +1 -5
-     if (!res) {
-             DRM_ERROR("Invalid hda resource\n");
-             return -ENOMEM;
-     }
-     hda->regs = devm_ioremap(dev, res->start, resource_size(res));
+     hda->regs = devm_platform_ioremap_resource_byname(pdev, "hda-reg");
      if (!hda->regs)
              return -ENOMEM;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_hdmi.c

Quoted 1 line

index

ca2fe17de4a5d1e0199e59a97e6c7601e139ed9e..666143c48b0d0f2c20cd26323ddbc8e69d966622 100644

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -0
@@ -1380,7 +1380,6 @@ static int sti_hdmi_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -1
      struct device *dev = &pdev->dev;
      struct sti_hdmi *hdmi;
      struct device_node *np = dev->of_node;
-     struct resource *res;
      struct device_node *ddc;
      int ret;
 
@@ -1399,15 +1398,7 @@ static int sti_hdmi_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -3
      }
 
      hdmi->dev = pdev->dev;
-
-     /* Get resources */
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"hdmi-reg");

drivers/gpu/drm/sti/sti_hdmi.c static int sti_hdmi_probe(struct platform_device *pdev)

Quoted 7 lines
drivers/gpu/drm/sti/sti_hdmi.c +1 -6
-     if (!res) {
-             DRM_ERROR("Invalid hdmi resource\n");
-             ret = -ENOMEM;
-             goto release_adapter;
-     }
-     hdmi->regs = devm_ioremap(dev, res->start, resource_size(res));
+     hdmi->regs = devm_platform_ioremap_resource_byname(pdev,

"hdmi-reg");

Review

Quoted 4 lines
drivers/gpu/drm/sti/sti_hdmi.c +0 -0
      if (!hdmi->regs) {
              ret = -ENOMEM;
              goto release_adapter;
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_hqvdp.c

Quoted 1 line

index

0f658709c9d0d398c4eed65202443db9d0b41f8c..420395598d119a403d531211022e6005d6a2bd59 100644

drivers/gpu/drm/sti/sti_hqvdp.c static int sti_hqvdp_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_hqvdp.c +0 -0
@@ -1356,7 +1356,6 @@ static int sti_hqvdp_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_hqvdp.c static int sti_hqvdp_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_hqvdp.c +0 -1
      struct device *dev = &pdev->dev;
      struct device_node *vtg_np;
      struct sti_hqvdp *hqvdp;
-     struct resource *res;
 
      DRM_DEBUG_DRIVER("\n");
 
@@ -1367,14 +1366,7 @@ static int sti_hqvdp_probe(struct platform_device

*pdev)

Review

Quoted 16 lines
drivers/gpu/drm/sti/sti_hqvdp.c +1 -8
      }
 
      hqvdp->dev = dev;
-
-     /* Get Memory resources */
-     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     if (!res) {
-             DRM_ERROR("Get memory resource failed\n");
-             return -ENXIO;
-     }
-     hqvdp->regs = devm_ioremap(dev, res->start, resource_size(res));
+     hqvdp->regs = devm_platform_ioremap_resource(pdev, 0);
      if (!hqvdp->regs) {
              DRM_ERROR("Register mapping failed\n");
              return -ENXIO;
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_tvout.c

Quoted 1 line

index

af6c06f448c4819def8cc0d0836e30f991529690..0bebe815f5e7567f84388af93723a6fa7d2cc7a2 100644

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device

Quoted 3 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -0
@@ -838,7 +838,6 @@ static int sti_tvout_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device

Quoted 8 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -1
      struct device *dev = &pdev->dev;
      struct device_node *node = dev->of_node;
      struct sti_tvout *tvout;
-     struct resource *res;
 
      DRM_INFO("%s\n", __func__);
 
@@ -850,14 +849,7 @@ static int sti_tvout_probe(struct platform_device

*pdev)

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -3
              return -ENOMEM;
 
      tvout->dev = dev;
-
-     /* get memory resources */
-     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"tvout-reg");

drivers/gpu/drm/sti/sti_tvout.c static int sti_tvout_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/gpu/drm/sti/sti_tvout.c +1 -5
-     if (!res) {
-             DRM_ERROR("Invalid glue resource\n");
-             return -ENOMEM;
-     }
-     tvout->regs = devm_ioremap(dev, res->start, resource_size(res));
+     tvout->regs = devm_platform_ioremap_resource_byname(pdev,

"tvout-reg");

Review

Quoted 4 lines
drivers/gpu/drm/sti/sti_tvout.c +0 -0
      if (!tvout->regs)
              return -ENOMEM;
 
(quoted diff) +0 -0

b/drivers/gpu/drm/sti/sti_vtg.c

Quoted 1 line

index

5ba469b711b5318e9e9e6d8df127fb8933d1fac1..b5353fe774d72fd629ecd3ef75a5d2817ca8617f 100644

Quoted 25 lines
drivers/gpu/drm/sti/sti_vtg.c +1 -9
@@ -380,20 +380,12 @@ static int vtg_probe(struct platform_device *pdev)
 {
      struct device *dev = &pdev->dev;
      struct sti_vtg *vtg;
-     struct resource *res;
      int ret;
 
      vtg = devm_kzalloc(dev, sizeof(*vtg), GFP_KERNEL);
      if (!vtg)
              return -ENOMEM;
-
-     /* Get Memory ressources */
-     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-     if (!res) {
-             DRM_ERROR("Get memory resource failed\n");
-             return -ENOMEM;
-     }
-     vtg->regs = devm_ioremap(dev, res->start, resource_size(res));
+     vtg->regs = devm_platform_ioremap_resource(pdev, 0);
      if (!vtg->regs) {
              DRM_ERROR("failed to remap I/O memory\n");
              return -ENOMEM;
#22 lore raw

Re: [PATCH 09/14] drm/sti: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa
kernel test robot noticed the following build errors:

Hi Anusha,

kernel test robot noticed the following build errors:

[auto build test ERROR on c4b9570cfb63501638db720f3bee9f6dfd044b82]

url:    https://github.com/intel-lab-lkp/linux/commits/Anusha-Srivatsa/drm-aspeed-move-to-devm_platform_ioremap_resource-usage/20250129-063524
base:   c4b9570cfb63501638db720f3bee9f6dfd044b82
patch link:    https://lore.kernel.org/r/20250128-cocci-memory-api-v1-9-0d1609a29587%40redhat.com
patch subject: [PATCH 09/14] drm/sti: move to devm_platform_ioremap_resource() usage
config: csky-randconfig-002-20250129 (https://download.01.org/0day-ci/archive/20250129/[email protected]/config)
compiler: csky-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250129/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/gpu/drm/sti/sti_hda.c: In function 'sti_hda_probe':

>> drivers/gpu/drm/sti/sti_hda.c:756:9: error: 'res' undeclared (first use in this function)
     756 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
         |         ^~~

drivers/gpu/drm/sti/sti_hda.c:756:9: note: each undeclared identifier is reported only once for each function it appears in

vim +/res +756 drivers/gpu/drm/sti/sti_hda.c

c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  739  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  740  static int sti_hda_probe(struct platform_device *pdev)
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  741  {
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  742  	struct device *dev = &pdev->dev;
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  743  	struct sti_hda *hda;
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  744  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  745  	DRM_INFO("%s\n", __func__);
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  746  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  747  	hda = devm_kzalloc(dev, sizeof(*hda), GFP_KERNEL);
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  748  	if (!hda)
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  749  		return -ENOMEM;
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  750  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  751  	hda->dev = pdev->dev;
9235f657a03071 Anusha Srivatsa   2025-01-28  752  	hda->regs = devm_platform_ioremap_resource_byname(pdev, "hda-reg");
5024a2b7ae9a92 Wei Yongjun       2014-08-26  753  	if (!hda->regs)
5024a2b7ae9a92 Wei Yongjun       2014-08-26  754  		return -ENOMEM;
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  755  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30 @756  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  757  			"video-dacs-ctrl");
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  758  	if (res) {
4bdc0d676a6431 Christoph Hellwig 2020-01-06  759  		hda->video_dacs_ctrl = devm_ioremap(dev, res->start,
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  760  				resource_size(res));
5024a2b7ae9a92 Wei Yongjun       2014-08-26  761  		if (!hda->video_dacs_ctrl)
5024a2b7ae9a92 Wei Yongjun       2014-08-26  762  			return -ENOMEM;
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  763  	} else {
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  764  		/* If no existing video-dacs-ctrl resource continue the probe */
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  765  		DRM_DEBUG_DRIVER("No video-dacs-ctrl resource\n");
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  766  		hda->video_dacs_ctrl = NULL;
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  767  	}
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  768  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  769  	/* Get clock resources */
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  770  	hda->clk_pix = devm_clk_get(dev, "pix");
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  771  	if (IS_ERR(hda->clk_pix)) {
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  772  		DRM_ERROR("Cannot get hda_pix clock\n");
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  773  		return PTR_ERR(hda->clk_pix);
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  774  	}
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  775  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  776  	hda->clk_hddac = devm_clk_get(dev, "hddac");
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  777  	if (IS_ERR(hda->clk_hddac)) {
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  778  		DRM_ERROR("Cannot get hda_hddac clock\n");
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  779  		return PTR_ERR(hda->clk_hddac);
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  780  	}
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  781  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  782  	platform_set_drvdata(pdev, hda);
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  783  
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  784  	return component_add(&pdev->dev, &sti_hda_ops);
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  785  }
c86a5f6e1b9c84 Benjamin Gaignard 2014-07-30  786  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#23 lore raw

PATCH 10/14 drm/stm: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 Yannick Fertre <[email protected]>
Cc Raphael Gallais-Pou <[email protected]>
Cc Philippe Cornu <[email protected]>
---
 drivers/gpu/drm/stm/ltdc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/stm/ltdc.c +1 -3
index 54a73753eff98902012c6012914fa8c6482affbd..ba315c66a04d72758b9d3cfcd842432877f66d3a 100644
@@ -1900,7 +1900,6 @@ int ltdc_load(struct drm_device *ddev)
 	struct drm_panel *panel;
 	struct drm_crtc *crtc;
 	struct reset_control *rstc;
-	struct resource *res;
 	int irq, i, nb_endpoints;
 	int ret = -ENODEV;
 
@@ -1966,8 +1965,7 @@ int ltdc_load(struct drm_device *ddev)
 		reset_control_deassert(rstc);
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ldev->regs = devm_ioremap_resource(dev, res);
+	ldev->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(ldev->regs)) {
 		DRM_ERROR("Unable to get ltdc registers\n");
 		ret = PTR_ERR(ldev->regs);
Signature · 1 line
2.47.0
maintainer Acked-by on v1 10/14
#24 lore raw

Re: [PATCH 10/14] drm/stm: move to devm_platform_ioremap_resource() usage

Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 4 lines
Cc Yannick Fertre <[email protected]>
Cc Raphael Gallais-Pou <[email protected]>
Cc Philippe Cornu <[email protected]>

Hi Anusha,

Thanks for your work !

Regards,
Raphaël

#25 lore raw

PATCH 11/14 drm/tegra: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 Thierry Reding <[email protected]>
Cc Mikko Perttunen <[email protected]>
---
 drivers/gpu/drm/tegra/dsi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/tegra/dsi.c +1 -3
index 4a8cd9ed0a9414b2f40b716fa8c02aff038a53e0..51f1ed897f8e473f45f89ff3e2d99f66d2c80f21 100644
@@ -1564,7 +1564,6 @@ static int tegra_dsi_ganged_probe(struct tegra_dsi *dsi)
 static int tegra_dsi_probe(struct platform_device *pdev)
 {
 	struct tegra_dsi *dsi;
-	struct resource *regs;
 	int err;
 
 	dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL);
@@ -1636,8 +1635,7 @@ static int tegra_dsi_probe(struct platform_device *pdev)
 		goto remove;
 	}
 
-	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	dsi->regs = devm_ioremap_resource(&pdev->dev, regs);
+	dsi->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(dsi->regs)) {
 		err = PTR_ERR(dsi->regs);
 		goto remove;
Signature · 1 line
2.47.0
maintainer Reviewed-by on v1 11/14
#26 lore raw

Re: [PATCH 11/14] drm/tegra: move to devm_platform_ioremap_resource() usage

Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 3 lines
Cc Thierry Reding <[email protected]>
Cc Mikko Perttunen <[email protected]>

Maxime

#27 lore raw

PATCH 12/14 drm/tiny: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

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 Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
---
 drivers/gpu/drm/tiny/arcpgu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/tiny/arcpgu.c +1 -3
index 2748d1f21d8697275047886865a5518792a4dd7c..7cf0f0ea1bfe4fa82234a120b52837e26a8ee5b0 100644
@@ -253,7 +253,6 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	struct device_node *encoder_node = NULL, *endpoint_node = NULL;
 	struct drm_connector *connector = NULL;
 	struct drm_device *drm = &arcpgu->drm;
-	struct resource *res;
 	int ret;
 
 	arcpgu->clk = devm_clk_get(drm->dev, "pxlclk");
@@ -270,8 +269,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 	drm->mode_config.max_height = 1080;
 	drm->mode_config.funcs = &arcpgu_drm_modecfg_funcs;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	arcpgu->regs = devm_ioremap_resource(&pdev->dev, res);
+	arcpgu->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(arcpgu->regs))
 		return PTR_ERR(arcpgu->regs);
 
Signature · 1 line
2.47.0
maintainer Reviewed-by on v1 12/14
#28 lore raw

Re: [PATCH 12/14] drm/tiny: move to devm_platform_ioremap_resource() usage

Quoted 15 lines · Anusha Srivatsa

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;
@@

(quoted diff) +1 -3
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
Quoted 3 lines
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>

Maxime

#29 lore raw

PATCH 13/14 drm/vc4: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

Replace platform_get_resource_byname + devm_ioremap_resource with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
//rule s/(devm_)platform_get_resource_byname + //(devm_)ioremap/devm_platform_ioremap_resource. @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);

Cc Maxime Ripard <[email protected]>
Cc Dave Stevenson <[email protected]>
Cc "Maíra Canal" <[email protected]>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +2 -7
index 47d9ada98430634cfd8c1e21c2a4d00d501bab7e..e22733f8159aa4b247a915e24a236f620bae932c 100644
@@ -2951,15 +2951,10 @@ static int vc5_hdmi_init_resources(struct drm_device *drm,
 {
 	struct platform_device *pdev = vc4_hdmi->pdev;
 	struct device *dev = &pdev->dev;
-	struct resource *res;
 	int ret;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi");
-	if (!res)
-		return -ENODEV;
-
-	vc4_hdmi->hdmicore_regs = devm_ioremap(dev, res->start,
-					       resource_size(res));
+	vc4_hdmi->hdmicore_regs = devm_platform_ioremap_resource_byname(pdev,
+									"hdmi");
 	if (!vc4_hdmi->hdmicore_regs)
 		return -ENOMEM;
 
Signature · 1 line
2.47.0
#30 lore raw

Re: [PATCH 13/14] drm/vc4: move to devm_platform_ioremap_resource() usage

kernel test robot noticed the following build errors:

Hi Anusha,

kernel test robot noticed the following build errors:

[auto build test ERROR on c4b9570cfb63501638db720f3bee9f6dfd044b82]

url:    https://github.com/intel-lab-lkp/linux/commits/Anusha-Srivatsa/drm-aspeed-move-to-devm_platform_ioremap_resource-usage/20250129-063524
base:   c4b9570cfb63501638db720f3bee9f6dfd044b82
patch link:    https://lore.kernel.org/r/20250128-cocci-memory-api-v1-13-0d1609a29587%40redhat.com
patch subject: [PATCH 13/14] drm/vc4: move to devm_platform_ioremap_resource() usage
config: i386-buildonly-randconfig-006-20250129 (https://download.01.org/0day-ci/archive/20250129/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250129/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/gpu/drm/vc4/vc4_hdmi.c: In function 'vc5_hdmi_init_resources':

>> drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9: error: 'res' undeclared (first use in this function); did you mean 'ret'?
    2961 |         res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hd");
         |         ^~~
         |         ret

drivers/gpu/drm/vc4/vc4_hdmi.c:2961:9: note: each undeclared identifier is reported only once for each function it appears in

vim +2961 drivers/gpu/drm/vc4/vc4_hdmi.c

33c773eb62eaa1 Maxime Ripard   2020-09-03  2948  
a3dbb1c0165768 Maxime Ripard   2022-07-11  2949  static int vc5_hdmi_init_resources(struct drm_device *drm,
a3dbb1c0165768 Maxime Ripard   2022-07-11  2950  				   struct vc4_hdmi *vc4_hdmi)
8323989140f3e5 Maxime Ripard   2020-09-03  2951  {
8323989140f3e5 Maxime Ripard   2020-09-03  2952  	struct platform_device *pdev = vc4_hdmi->pdev;
8323989140f3e5 Maxime Ripard   2020-09-03  2953  	struct device *dev = &pdev->dev;
25eb441d55d479 Dave Stevenson  2022-06-13  2954  	int ret;
8323989140f3e5 Maxime Ripard   2020-09-03  2955  
6b3da32a2befda Anusha Srivatsa 2025-01-28  2956  	vc4_hdmi->hdmicore_regs = devm_platform_ioremap_resource_byname(pdev,
6b3da32a2befda Anusha Srivatsa 2025-01-28  2957  									"hdmi");
14929c5ae8b6dc Dan Carpenter   2020-09-10  2958  	if (!vc4_hdmi->hdmicore_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  2959  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  2960  
8323989140f3e5 Maxime Ripard   2020-09-03 @2961  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hd");
8323989140f3e5 Maxime Ripard   2020-09-03  2962  	if (!res)
8323989140f3e5 Maxime Ripard   2020-09-03  2963  		return -ENODEV;
8323989140f3e5 Maxime Ripard   2020-09-03  2964  
8323989140f3e5 Maxime Ripard   2020-09-03  2965  	vc4_hdmi->hd_regs = devm_ioremap(dev, res->start, resource_size(res));
14929c5ae8b6dc Dan Carpenter   2020-09-10  2966  	if (!vc4_hdmi->hd_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  2967  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  2968  
8323989140f3e5 Maxime Ripard   2020-09-03  2969  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cec");
8323989140f3e5 Maxime Ripard   2020-09-03  2970  	if (!res)
8323989140f3e5 Maxime Ripard   2020-09-03  2971  		return -ENODEV;
8323989140f3e5 Maxime Ripard   2020-09-03  2972  
8323989140f3e5 Maxime Ripard   2020-09-03  2973  	vc4_hdmi->cec_regs = devm_ioremap(dev, res->start, resource_size(res));
14929c5ae8b6dc Dan Carpenter   2020-09-10  2974  	if (!vc4_hdmi->cec_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  2975  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  2976  
8323989140f3e5 Maxime Ripard   2020-09-03  2977  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "csc");
8323989140f3e5 Maxime Ripard   2020-09-03  2978  	if (!res)
8323989140f3e5 Maxime Ripard   2020-09-03  2979  		return -ENODEV;
8323989140f3e5 Maxime Ripard   2020-09-03  2980  
8323989140f3e5 Maxime Ripard   2020-09-03  2981  	vc4_hdmi->csc_regs = devm_ioremap(dev, res->start, resource_size(res));
14929c5ae8b6dc Dan Carpenter   2020-09-10  2982  	if (!vc4_hdmi->csc_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  2983  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  2984  
8323989140f3e5 Maxime Ripard   2020-09-03  2985  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dvp");
8323989140f3e5 Maxime Ripard   2020-09-03  2986  	if (!res)
8323989140f3e5 Maxime Ripard   2020-09-03  2987  		return -ENODEV;
8323989140f3e5 Maxime Ripard   2020-09-03  2988  
8323989140f3e5 Maxime Ripard   2020-09-03  2989  	vc4_hdmi->dvp_regs = devm_ioremap(dev, res->start, resource_size(res));
14929c5ae8b6dc Dan Carpenter   2020-09-10  2990  	if (!vc4_hdmi->dvp_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  2991  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  2992  
8323989140f3e5 Maxime Ripard   2020-09-03  2993  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy");
8323989140f3e5 Maxime Ripard   2020-09-03  2994  	if (!res)
8323989140f3e5 Maxime Ripard   2020-09-03  2995  		return -ENODEV;
8323989140f3e5 Maxime Ripard   2020-09-03  2996  
8323989140f3e5 Maxime Ripard   2020-09-03  2997  	vc4_hdmi->phy_regs = devm_ioremap(dev, res->start, resource_size(res));
14929c5ae8b6dc Dan Carpenter   2020-09-10  2998  	if (!vc4_hdmi->phy_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  2999  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  3000  
8323989140f3e5 Maxime Ripard   2020-09-03  3001  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "packet");
8323989140f3e5 Maxime Ripard   2020-09-03  3002  	if (!res)
8323989140f3e5 Maxime Ripard   2020-09-03  3003  		return -ENODEV;
8323989140f3e5 Maxime Ripard   2020-09-03  3004  
8323989140f3e5 Maxime Ripard   2020-09-03  3005  	vc4_hdmi->ram_regs = devm_ioremap(dev, res->start, resource_size(res));
14929c5ae8b6dc Dan Carpenter   2020-09-10  3006  	if (!vc4_hdmi->ram_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  3007  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  3008  
8323989140f3e5 Maxime Ripard   2020-09-03  3009  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rm");
8323989140f3e5 Maxime Ripard   2020-09-03  3010  	if (!res)
8323989140f3e5 Maxime Ripard   2020-09-03  3011  		return -ENODEV;
8323989140f3e5 Maxime Ripard   2020-09-03  3012  
8323989140f3e5 Maxime Ripard   2020-09-03  3013  	vc4_hdmi->rm_regs = devm_ioremap(dev, res->start, resource_size(res));
14929c5ae8b6dc Dan Carpenter   2020-09-10  3014  	if (!vc4_hdmi->rm_regs)
14929c5ae8b6dc Dan Carpenter   2020-09-10  3015  		return -ENOMEM;
8323989140f3e5 Maxime Ripard   2020-09-03  3016  
8323989140f3e5 Maxime Ripard   2020-09-03  3017  	vc4_hdmi->hsm_clock = devm_clk_get(dev, "hdmi");
8323989140f3e5 Maxime Ripard   2020-09-03  3018  	if (IS_ERR(vc4_hdmi->hsm_clock)) {
59ac702a932028 Stefan Wahren   2024-08-21  3019  		drm_err(drm, "Failed to get HDMI state machine clock\n");
8323989140f3e5 Maxime Ripard   2020-09-03  3020  		return PTR_ERR(vc4_hdmi->hsm_clock);
8323989140f3e5 Maxime Ripard   2020-09-03  3021  	}
8323989140f3e5 Maxime Ripard   2020-09-03  3022  
8323989140f3e5 Maxime Ripard   2020-09-03  3023  	vc4_hdmi->pixel_bvb_clock = devm_clk_get(dev, "bvb");
8323989140f3e5 Maxime Ripard   2020-09-03  3024  	if (IS_ERR(vc4_hdmi->pixel_bvb_clock)) {
59ac702a932028 Stefan Wahren   2024-08-21  3025  		drm_err(drm, "Failed to get pixel bvb clock\n");
8323989140f3e5 Maxime Ripard   2020-09-03  3026  		return PTR_ERR(vc4_hdmi->pixel_bvb_clock);
8323989140f3e5 Maxime Ripard   2020-09-03  3027  	}
8323989140f3e5 Maxime Ripard   2020-09-03  3028  
8323989140f3e5 Maxime Ripard   2020-09-03  3029  	vc4_hdmi->audio_clock = devm_clk_get(dev, "audio");
8323989140f3e5 Maxime Ripard   2020-09-03  3030  	if (IS_ERR(vc4_hdmi->audio_clock)) {
59ac702a932028 Stefan Wahren   2024-08-21  3031  		drm_err(drm, "Failed to get audio clock\n");
8323989140f3e5 Maxime Ripard   2020-09-03  3032  		return PTR_ERR(vc4_hdmi->audio_clock);
8323989140f3e5 Maxime Ripard   2020-09-03  3033  	}
8323989140f3e5 Maxime Ripard   2020-09-03  3034  
23b7eb5c12b359 Maxime Ripard   2021-01-11  3035  	vc4_hdmi->cec_clock = devm_clk_get(dev, "cec");
23b7eb5c12b359 Maxime Ripard   2021-01-11  3036  	if (IS_ERR(vc4_hdmi->cec_clock)) {
59ac702a932028 Stefan Wahren   2024-08-21  3037  		drm_err(drm, "Failed to get CEC clock\n");
23b7eb5c12b359 Maxime Ripard   2021-01-11  3038  		return PTR_ERR(vc4_hdmi->cec_clock);
23b7eb5c12b359 Maxime Ripard   2021-01-11  3039  	}
23b7eb5c12b359 Maxime Ripard   2021-01-11  3040  
8323989140f3e5 Maxime Ripard   2020-09-03  3041  	vc4_hdmi->reset = devm_reset_control_get(dev, NULL);
8323989140f3e5 Maxime Ripard   2020-09-03  3042  	if (IS_ERR(vc4_hdmi->reset)) {
59ac702a932028 Stefan Wahren   2024-08-21  3043  		drm_err(drm, "Failed to get HDMI reset line\n");
8323989140f3e5 Maxime Ripard   2020-09-03  3044  		return PTR_ERR(vc4_hdmi->reset);
8323989140f3e5 Maxime Ripard   2020-09-03  3045  	}
8323989140f3e5 Maxime Ripard   2020-09-03  3046  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3047  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->hdmi_regset, VC4_HDMI);
25eb441d55d479 Dave Stevenson  2022-06-13  3048  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3049  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3050  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3051  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->hd_regset, VC4_HD);
25eb441d55d479 Dave Stevenson  2022-06-13  3052  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3053  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3054  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3055  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->cec_regset, VC5_CEC);
25eb441d55d479 Dave Stevenson  2022-06-13  3056  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3057  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3058  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3059  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->csc_regset, VC5_CSC);
25eb441d55d479 Dave Stevenson  2022-06-13  3060  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3061  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3062  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3063  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->dvp_regset, VC5_DVP);
25eb441d55d479 Dave Stevenson  2022-06-13  3064  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3065  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3066  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3067  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->phy_regset, VC5_PHY);
25eb441d55d479 Dave Stevenson  2022-06-13  3068  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3069  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3070  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3071  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->ram_regset, VC5_RAM);
25eb441d55d479 Dave Stevenson  2022-06-13  3072  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3073  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3074  
a3dbb1c0165768 Maxime Ripard   2022-07-11  3075  	ret = vc4_hdmi_build_regset(drm, vc4_hdmi, &vc4_hdmi->rm_regset, VC5_RM);
25eb441d55d479 Dave Stevenson  2022-06-13  3076  	if (ret)
25eb441d55d479 Dave Stevenson  2022-06-13  3077  		return ret;
25eb441d55d479 Dave Stevenson  2022-06-13  3078  
8323989140f3e5 Maxime Ripard   2020-09-03  3079  	return 0;
c8b75bca92cbf0 Eric Anholt     2015-03-02  3080  }
c8b75bca92cbf0 Eric Anholt     2015-03-02  3081  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#31 lore raw

Re: [PATCH 13/14] drm/vc4: move to devm_platform_ioremap_resource() usage

In reply to Anusha Srivatsa

Hi Anusha

Quoted 42 lines · Anusha Srivatsa

Replace platform_get_resource_byname + devm_ioremap_resource with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
//rule s/(devm_)platform_get_resource_byname +
//(devm_)ioremap/devm_platform_ioremap_resource.
@rule_3@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource_byname(pdev,mem,name);

<...

(quoted diff) +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);
Cc Maxime Ripard <[email protected]>
Cc Dave Stevenson <[email protected]>
Cc "Maíra Canal" <[email protected]>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +0 -1
index 47d9ada98430634cfd8c1e21c2a4d00d501bab7e..e22733f8159aa4b247a915e24a236f620bae932c 100644
@@ -2951,15 +2951,10 @@ static int vc5_hdmi_init_resources(struct drm_device *drm,
 {
        struct platform_device *pdev = vc4_hdmi->pdev;
        struct device *dev = &pdev->dev;
-       struct resource *res;

drivers/gpu/drm/vc4/vc4_hdmi.c static int vc5_hdmi_init_resources(struct drm_device *drm, · line 2957

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +2 -6
        int ret;
 
-       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi");
-       if (!res)
-               return -ENODEV;
-
-       vc4_hdmi->hdmicore_regs = devm_ioremap(dev, res->start,
-                                              resource_size(res));
+       vc4_hdmi->hdmicore_regs = devm_platform_ioremap_resource_byname(pdev,
+                                                                       "hdmi");

Whilst I totally agree with this change, why was only one of the 8 instances of this pattern within this function updated? Is that a limitation in your script?
https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/vc4/vc4_hdmi.c#L2957-L3020

Dave

Quoted 7 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +0 -1
        if (!vc4_hdmi->hdmicore_regs)
                return -ENOMEM;
 
 
--

2.47.0

#32 lore raw

Re: [PATCH 13/14] drm/vc4: move to devm_platform_ioremap_resource() usage

Quoted 59 lines · Dave Stevenson

Hi Anusha

Quoted 29 lines · Anusha Srivatsa

Replace platform_get_resource_byname + devm_ioremap_resource with just devm_platform_ioremap_resource()

Used Coccinelle to do this change. SmPl patch:
//rule s/(devm_)platform_get_resource_byname +
//(devm_)ioremap/devm_platform_ioremap_resource.
@rule_3@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@

(quoted diff) +0 -2
-struct resource *res;
...
-res = platform_get_resource_byname(pdev,mem,name);

<...

(quoted diff) +0 -3
-if (!res) {
-...
-}

...>

(quoted diff) +1 -1
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);
Cc Maxime Ripard <[email protected]>
Cc Dave Stevenson <[email protected]>
Cc "Maíra Canal" <[email protected]>

Review

Quoted 5 lines
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/vc4/vc4_hdmi.c

Quoted 1 line

index

47d9ada98430634cfd8c1e21c2a4d00d501bab7e..e22733f8159aa4b247a915e24a236f620bae932c 100644

drivers/gpu/drm/vc4/vc4_hdmi.c static int vc5_hdmi_init_resources(struct

Quoted 3 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +0 -0
@@ -2951,15 +2951,10 @@ static int vc5_hdmi_init_resources(struct

drm_device *drm,

drivers/gpu/drm/vc4/vc4_hdmi.c static int vc5_hdmi_init_resources(struct drm_device *drm,

Quoted 13 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -7
 {
        struct platform_device *pdev = vc4_hdmi->pdev;
        struct device *dev = &pdev->dev;
-       struct resource *res;
        int ret;
 
-       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi");
-       if (!res)
-               return -ENODEV;
-
-       vc4_hdmi->hdmicore_regs = devm_ioremap(dev, res->start,
-                                              resource_size(res));
+       vc4_hdmi->hdmicore_regs =

devm_platform_ioremap_resource_byname(pdev,

Quoted 10 lines

drivers/gpu/drm/vc4/vc4_hdmi.c static int vc5_hdmi_init_resources(struct · line 2957

Quoted 1 line
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -0
+

"hdmi");

Whilst I totally agree with this change, why was only one of the 8 instances of this pattern within this function updated? Is that a limitation in your script?

https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/vc4/vc4_hdmi.c#L2957-L3020

Yes! looks like it is. My script is missing one set of ellipses which makes it apply the rule only to the first appearance of the pattern. Will rectify this. Thanks!!

Anusha

Quoted 11 lines

Dave

Quoted 7 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +0 -1
        if (!vc4_hdmi->hdmicore_regs)
                return -ENOMEM;
 
 
--

2.47.0

#33 lore raw

PATCH 14/14 Documentation: Update the todo

In reply to Anusha Srivatsa

Remove the TODO now that this series addresses
the changes needed.

Cc Thomas Zimmermann <[email protected]>
---
 Documentation/gpu/todo.rst | 15 ---------------
 1 file changed, 15 deletions(-)
Documentation/gpu/todo.rst +0 -15
index 256d0d1cb2164bd94f9b610a751b907834d96a21..b5aa5f776cfe0916b98bddf791c65abe974834cf 100644
@@ -441,21 +441,6 @@ Contact: Thomas Zimmermann <[email protected]>
 
 Level: Intermediate
 
-Request memory regions in all drivers
--------------------------------------
-
-Go through all drivers and add code to request the memory regions that the
-driver uses. This requires adding calls to request_mem_region(),
-pci_request_region() or similar functions. Use helpers for managed cleanup
-where possible.
-
-Drivers are pretty bad at doing this and there used to be conflicts among
-DRM and fbdev drivers. Still, it's the correct thing to do.
-
-Contact: Thomas Zimmermann <[email protected]>
-
-Level: Starter
-
 Remove driver dependencies on FB_DEVICE
 ---------------------------------------
 
Signature · 1 line
2.47.0
#34 lore raw

Re: [PATCH 14/14] Documentation: Update the todo

Hi

Am 28.01.25 um 23:29 schrieb Anusha Srivatsa:

Quoted 2 lines

Remove the TODO now that this series addresses
the changes needed.

While your series is fine, this TODO item is unrelated. It's about various ancient fbdev drivers that do not reserve their memory regions correctly. So please drop patch 14 form the series.

Best regards
Thomas

Quoted 34 lines
Cc Thomas Zimmermann <[email protected]>
---
  Documentation/gpu/todo.rst | 15 ---------------
  1 file changed, 15 deletions(-)
Documentation/gpu/todo.rst +0 -15
index 256d0d1cb2164bd94f9b610a751b907834d96a21..b5aa5f776cfe0916b98bddf791c65abe974834cf 100644
@@ -441,21 +441,6 @@ Contact: Thomas Zimmermann <[email protected]>
 
  Level: Intermediate
 
-Request memory regions in all drivers
--------------------------------------
-
-Go through all drivers and add code to request the memory regions that the
-driver uses. This requires adding calls to request_mem_region(),
-pci_request_region() or similar functions. Use helpers for managed cleanup
-where possible.
-
-Drivers are pretty bad at doing this and there used to be conflicts among
-DRM and fbdev drivers. Still, it's the correct thing to do.
-
-Contact: Thomas Zimmermann <[email protected]>
-
-Level: Starter
-
  Remove driver dependencies on FB_DEVICE
  ---------------------------------------
 
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
maintainer
#35 lore raw

Re: [PATCH 14/14] Documentation: Update the todo

Hi Thomas,

Quoted 7 lines · Thomas Zimmermann

Am 28.01.25 um 23:29 schrieb Anusha Srivatsa:

Quoted 2 lines

Remove the TODO now that this series addresses
the changes needed.

While your series is fine, this TODO item is unrelated. It's about various ancient fbdev drivers that do not reserve their memory regions correctly. So please drop patch 14 form the series.

Is it? Could we rephrase the entry then? I'm the one that suggested Anusha to work on this, and it's still not clear to me what it means exactly if it's not what she worked on :)

Maxime

#36 lore raw

Re: [PATCH 14/14] Documentation: Update the todo

Quoted 7 lines · Maxime Ripard

Hi Thomas,

Quoted 4 lines · Thomas Zimmermann

Am 28.01.25 um 23:29 schrieb Anusha Srivatsa:

Quoted 2 lines

Remove the TODO now that this series addresses
the changes needed.

Quoted 7 lines
Quoted 3 lines

While your series is fine, this TODO item is unrelated. It's about various ancient fbdev drivers that do not reserve their memory regions correctly. So please drop patch 14 form the series.

Is it? Could we rephrase the entry then? I'm the one that suggested Anusha to work on this, and it's still not clear to me what it means exactly if it's not what she worked on :)

The text in the TODO sounds pretty clear to me. It says that not all drivers request the memory that they are going to use, and suggests to add those missing calls. But all of the drivers in this series already do that and the only change here is to convert them to use some of the newer helpers.

Thierry

maintainer
#37 lore raw

Re: [PATCH 14/14] Documentation: Update the todo

Quoted 12 lines · Thierry Reding
Quoted 11 lines · Maxime Ripard

Hi Thomas,

Quoted 7 lines · Thomas Zimmermann

Am 28.01.25 um 23:29 schrieb Anusha Srivatsa:

Quoted 2 lines

Remove the TODO now that this series addresses
the changes needed.

While your series is fine, this TODO item is unrelated. It's about various ancient fbdev drivers that do not reserve their memory regions correctly. So please drop patch 14 form the series.

Quoted 5 lines
Quoted 3 lines

Is it? Could we rephrase the entry then? I'm the one that suggested Anusha to work on this, and it's still not clear to me what it means exactly if it's not what she worked on :)

The text in the TODO sounds pretty clear to me.

The title is "Request memory regions in all drivers", and the first sentence is "Go through all drivers and add code to request the memory regions that the driver uses". It's definitely ambiguous if only fbdev drivers should be considered, even more so in the DRM documentation.

Quoted 2 lines

It says that not all drivers request the memory that they are going to use, and suggests to add those missing calls.

Right.

Quoted 1 line

But all of the drivers in this series already do that

Nope.

Quoted 2 lines

and the only change here is to convert them to use some of the newer helpers.

For some, yes. For others, it actually adds request_mem_region.

Maxime

#38 lore raw

Re: [PATCH 14/14] Documentation: Update the todo

Quoted 29 lines · Maxime Ripard
Quoted 12 lines · Thierry Reding
Quoted 11 lines · Maxime Ripard

Hi Thomas,

Quoted 7 lines · Thomas Zimmermann

Am 28.01.25 um 23:29 schrieb Anusha Srivatsa:

Quoted 2 lines

Remove the TODO now that this series addresses
the changes needed.

While your series is fine, this TODO item is unrelated. It's about various ancient fbdev drivers that do not reserve their memory regions correctly. So please drop patch 14 form the series.

Quoted 5 lines
Quoted 3 lines

Is it? Could we rephrase the entry then? I'm the one that suggested Anusha to work on this, and it's still not clear to me what it means exactly if it's not what she worked on :)

The text in the TODO sounds pretty clear to me.

The title is "Request memory regions in all drivers", and the first sentence is "Go through all drivers and add code to request the memory regions that the driver uses". It's definitely ambiguous if only fbdev drivers should be considered, even more so in the DRM documentation.

Quoted 2 lines

It says that not all drivers request the memory that they are going to use, and suggests to add those missing calls.

Right.

Quoted 8 lines
Quoted 1 line

But all of the drivers in this series already do that

Nope.

Quoted 2 lines

and the only change here is to convert them to use some of the newer helpers.

For some, yes. For others, it actually adds request_mem_region.

Ah... indeed. Well, on the face of it this looks like just another mass- conversion to the devm_platform_ioremap_resource() helper, so that's also confusing.

Maybe the right way to do this would be to split this into two series, one that actually does what the TODO suggests (and maybe updates the TODO to make it more obvious that after this only fbdev drivers are left) and another series that does the helper conversion.

Thierry

#39 lore raw

Re: [PATCH 14/14] Documentation: Update the todo

In reply to Maxime Ripard

Hi Maxime

Am 29.01.25 um 15:31 schrieb Maxime Ripard:

Quoted 4 lines

Hi Thomas,

Quoted 1 line · Thomas Zimmermann

Am 28.01.25 um 23:29 schrieb Anusha Srivatsa:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Remove the TODO now that this series addresses
the changes needed.

While your series is fine, this TODO item is unrelated. It's about various ancient fbdev drivers that do not reserve their memory regions correctly. So please drop patch 14 form the series.

Is it? Could we rephrase the entry then? I'm the one that suggested Anusha to work on this, and it's still not clear to me what it means exactly if it's not what she worked on :)

I guess, we could make this more precise.

Some old graphics drivers don't request their memory ranges correctly. It's usually a problem with hardware that has exclusive ranges, such as the VGA. Vga16fb doesn't request the range as it should. Someone needs to audit all those old drivers and fix them.

Best regards
Thomas

Quoted 2 lines

Maxime

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#40 lore raw

Re: [PATCH 14/14] Documentation: Update the todo

Quoted 19 lines · Thomas Zimmermann

Hi Maxime

Am 29.01.25 um 15:31 schrieb Maxime Ripard:

Quoted 7 lines

Hi Thomas,

Quoted 4 lines · Thomas Zimmermann

Am 28.01.25 um 23:29 schrieb Anusha Srivatsa:

Quoted 2 lines

Remove the TODO now that this series addresses
the changes needed.

While your series is fine, this TODO item is unrelated. It's about

various

Quoted 1 line
Quoted 1 line

ancient fbdev drivers that do not reserve their memory regions

correctly. So

Quoted 4 lines
Quoted 1 line

please drop patch 14 form the series.

Is it? Could we rephrase the entry then? I'm the one that suggested Anusha to work on this, and it's still not clear to me what it means exactly if it's not what she worked on :)

Quoted 8 lines

I guess, we could make this more precise.

Some old graphics drivers don't request their memory ranges correctly. It's usually a problem with hardware that has exclusive ranges, such as the VGA. Vga16fb doesn't request the range as it should. Someone needs to audit all those old drivers and fix them.

This sounds like a good next approach. I will make the documentation more clear.

Thanks for feedback everyone!

Anusha

Quoted 17 lines

Best regards
Thomas

Quoted 2 lines

Maxime

--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)