* [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource
@ 2025-03-04 21:05 Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 1/7] drm/fsl-dcu: move to devm_platform_ioremap_resource() usage Anusha Srivatsa
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, Anusha Srivatsa, Dmitry Baryshkov,
Raphael Gallais-Pou
Start replacing the below occurences with the newer API:
- (devm_)platform_get_resource + devm_ioremap_resource
- (devm_)platform_get_resource + (devm_)ioremap
- platform_get_resource_byname + devm_ioremap
Move all these occurences to uses devm_platform_ioremap_resource
instead.
This is v5 of the series.
Changes in v5:
- Some patches already merged, leave them out.
- Handle return properly. The new API returns a error pointers
and not NULL. While this is taken care of in most drivers in
the series, the sprd and sti needed changes. Thanks to Dan
for pointing this out with his fix:
https://lore.kernel.org/dri-devel/a952e2b4-d4b8-49ac-abd9-9967c50f4a80@stanley.mountain/
Changes in v4:
- Address vc4 driver compilation error
Changes in v3:
- Keep the old snippet of documentation and add further
clarification (Thomas)
- change in vc4 driver for the a resource is not needed.
Add a comment to clarify why that is left behind (Maxime)
Changes in v2:
- Fix compilation errors
Used Coccinelle to make the code changes.Semantic patch:
//First Case
//rule s/platform_get_resource + devm_ioremap_resource/devm_platform_ioremap_resource
@rule_1@
identifier res;
expression ioremap_res;
identifier pdev;
@@
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
-ioremap_res = devm_ioremap_resource(...);
+ioremap_res = devm_platform_ioremap_resource(pdev,0);
//Second case
//rule s/(devm_)platform_get_resource + (devm_)ioremap/devm_platform_ioremap_resource.
@rule_2@
identifier res;
expression ioremap;
identifier pdev;
@@
-struct resource *res;
...
-res = platform_get_resource(pdev,...);
<...
-if (!res) {
-...
-}
...>
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource(pdev,0);
//Third case
//rule s/(devm_)platform_get_resource_byname + (devm_)ioremap/devm_platform_ioremap_resource_byname.
@rule_3@
identifier res;
expression ioremap;
identifier pdev;
constant mem;
expression name;
@@
-struct resource *res;
<+...
-res = platform_get_resource_byname(pdev,mem,name);
<...
-if (!res) {
-...
-}
...>
-ioremap = devm_ioremap(...);
+ioremap = devm_platform_ioremap_resource_byname(pdev,name);
...+>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
Anusha Srivatsa (7):
drm/fsl-dcu: move to devm_platform_ioremap_resource() usage
drm/hisilicon: move to devm_platform_ioremap_resource() usage
drm/mxsfb: move to devm_platform_ioremap_resource() usage
drm/sprd: move to devm_platform_ioremap_resource() usage
drm/sti: move to devm_platform_ioremap_resource() usage
drm/tegra: move to devm_platform_ioremap_resource() usage
Documentation: Update the todo
Documentation/gpu/todo.rst | 13 +++++++------
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/mxsfb/lcdif_drv.c | 4 +---
drivers/gpu/drm/mxsfb/mxsfb_drv.c | 4 +---
drivers/gpu/drm/sprd/sprd_dpu.c | 13 +++----------
drivers/gpu/drm/sprd/sprd_dsi.c | 13 +++----------
drivers/gpu/drm/sti/sti_compositor.c | 14 +++-----------
drivers/gpu/drm/sti/sti_dvo.c | 14 +++-----------
drivers/gpu/drm/sti/sti_hda.c | 13 +++----------
drivers/gpu/drm/sti/sti_hdmi.c | 15 +++------------
drivers/gpu/drm/sti/sti_hqvdp.c | 14 +++-----------
drivers/gpu/drm/sti/sti_tvout.c | 14 +++-----------
drivers/gpu/drm/sti/sti_vtg.c | 14 +++-----------
drivers/gpu/drm/tegra/dsi.c | 4 +---
16 files changed, 40 insertions(+), 121 deletions(-)
---
base-commit: 0670c2f56e45b3f4541985a9ebe06d04308e43b0
change-id: 20250304-mem-fixes-34df71d18b98
Best regards,
--
Anusha Srivatsa <asrivats@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 1/7] drm/fsl-dcu: move to devm_platform_ioremap_resource() usage
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
@ 2025-03-04 21:05 ` Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 2/7] drm/hisilicon: " Anusha Srivatsa
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, 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 <stefan@agner.ch>
Cc: Alison Wang <alison.wang@nxp.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index 03b076db9381a5db0bff6576cda2772495a61fed..3bbfc1b56a6557e2f54d2b7ed099531053871341 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -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;
--
2.48.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 2/7] drm/hisilicon: move to devm_platform_ioremap_resource() usage
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 1/7] drm/fsl-dcu: move to devm_platform_ioremap_resource() usage Anusha Srivatsa
@ 2025-03-04 21:05 ` Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 3/7] drm/mxsfb: " Anusha Srivatsa
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, 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 <xinliang.liu@linaro.org>
Cc: Tian Tao <tiantao6@hisilicon.com>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Yongqin Liu <yongqin.liu@linaro.org>
Cc: John Stultz <jstultz@google.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
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(-)
diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
index 2eea9fb0e76bf3ead8f5914e6ebb65b5b3603b9a..e80debdc41763357cb2cf321205c0dfac80a911e 100644
--- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
+++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c
@@ -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);
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index 2eb49177ac42bc6dba692328cca5c99d5925041c..45c4eb008ad5d639340f769ad022d186ec454722 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -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);
--
2.48.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 3/7] drm/mxsfb: move to devm_platform_ioremap_resource() usage
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 1/7] drm/fsl-dcu: move to devm_platform_ioremap_resource() usage Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 2/7] drm/hisilicon: " Anusha Srivatsa
@ 2025-03-04 21:05 ` Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 4/7] drm/sprd: " Anusha Srivatsa
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, 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 <marex@denx.de>
Cc: Stefan Agner <stefan@agner.ch>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
drivers/gpu/drm/mxsfb/lcdif_drv.c | 4 +---
drivers/gpu/drm/mxsfb/mxsfb_drv.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c
index 8ee00f59ca821cea8e823e7100fb4d7534283994..fcb2a7517377e9a5bbd2997c578c579b1b079f92 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
@@ -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);
diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 59020862cf65e5cc488903f1263ed16dfbce06f9..377d4c4c9979ad9538cfec5464827a82936f811b 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -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);
--
2.48.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 4/7] drm/sprd: move to devm_platform_ioremap_resource() usage
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
` (2 preceding siblings ...)
2025-03-04 21:05 ` [PATCH v5 3/7] drm/mxsfb: " Anusha Srivatsa
@ 2025-03-04 21:05 ` Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 5/7] drm/sti: " Anusha Srivatsa
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, Anusha Srivatsa, Dmitry Baryshkov
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);
v2: Address the return handling properly since
the new API returns error pointers and not NULL.
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
Reviewed-by: Chunyan Zhang <zhang.lyra@gmail.com>(v1)
Reviewed-by: Maxime Ripard <mripard@kernel.org>(v1)
---
drivers/gpu/drm/sprd/sprd_dpu.c | 13 +++----------
drivers/gpu/drm/sprd/sprd_dsi.c | 13 +++----------
2 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/sprd/sprd_dpu.c b/drivers/gpu/drm/sprd/sprd_dpu.c
index cb2816985305fd19eac27413c214681a5a1e9ffa..a3447622a33cd612e34be038e833222567bdcd2c 100644
--- a/drivers/gpu/drm/sprd/sprd_dpu.c
+++ b/drivers/gpu/drm/sprd/sprd_dpu.c
@@ -784,19 +784,12 @@ 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));
- if (!ctx->base) {
+ ctx->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(ctx->base)) {
dev_err(dev, "failed to map dpu registers\n");
- return -EFAULT;
+ return PTR_ERR(ctx->base);
}
ctx->irq = platform_get_irq(pdev, 0);
diff --git a/drivers/gpu/drm/sprd/sprd_dsi.c b/drivers/gpu/drm/sprd/sprd_dsi.c
index 8fc26479bb6bce0aa94914f49d0986a7e19326c1..23b0e1dc547a5023ee6ad7d5e1c49e2cec986bf0 100644
--- a/drivers/gpu/drm/sprd/sprd_dsi.c
+++ b/drivers/gpu/drm/sprd/sprd_dsi.c
@@ -901,18 +901,11 @@ 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));
- if (!ctx->base) {
+ ctx->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(ctx->base)) {
drm_err(dsi->drm, "failed to map dsi host registers\n");
- return -ENXIO;
+ return PTR_ERR(ctx->base);
}
ctx->regmap = devm_regmap_init(dev, ®map_tst_io, dsi, &byte_config);
--
2.48.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 5/7] drm/sti: move to devm_platform_ioremap_resource() usage
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
` (3 preceding siblings ...)
2025-03-04 21:05 ` [PATCH v5 4/7] drm/sprd: " Anusha Srivatsa
@ 2025-03-04 21:05 ` Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 6/7] drm/tegra: " Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 7/7] Documentation: Update the todo Anusha Srivatsa
6 siblings, 0 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, Anusha Srivatsa, Raphael Gallais-Pou
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);
v2: Fix compilation error.
v3: Handle returns properly since the new API return error pointers
and not NULL
Cc: Raphael Gallais-Pou <raphael.gallais-pou@foss.st.com>
Cc: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>(v2)
Acked-by: Raphael Gallais-Pou <rgallaispou@gmail.com>(v2)
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
drivers/gpu/drm/sti/sti_compositor.c | 14 +++-----------
drivers/gpu/drm/sti/sti_dvo.c | 14 +++-----------
drivers/gpu/drm/sti/sti_hda.c | 13 +++----------
drivers/gpu/drm/sti/sti_hdmi.c | 15 +++------------
drivers/gpu/drm/sti/sti_hqvdp.c | 14 +++-----------
drivers/gpu/drm/sti/sti_tvout.c | 14 +++-----------
drivers/gpu/drm/sti/sti_vtg.c | 14 +++-----------
7 files changed, 21 insertions(+), 77 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_compositor.c b/drivers/gpu/drm/sti/sti_compositor.c
index 063f82d23d80c4ba83624a0066a18416a2b37351..8c529b0cca8b48fca532cd15e1f36fbe5bcbc71e 100644
--- a/drivers/gpu/drm/sti/sti_compositor.c
+++ b/drivers/gpu/drm/sti/sti_compositor.c
@@ -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,17 +193,10 @@ 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));
- if (compo->regs == NULL) {
+ compo->regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(compo->regs)) {
DRM_ERROR("Register mapping failed\n");
- return -ENXIO;
+ return PTR_ERR(compo->regs);
}
/* Get clock resources */
diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index 4dcddd02629b6a1052be8fb8333bd3aa17c083c5..74a1eef4674eeabc445b53b380e325f785242024 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -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,16 +522,9 @@ 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));
- if (!dvo->regs)
- return -ENOMEM;
+ dvo->regs = devm_platform_ioremap_resource_byname(pdev, "dvo-reg");
+ if (IS_ERR(dvo->regs))
+ return PTR_ERR(dvo->regs);
dvo->clk_pix = devm_clk_get(dev, "dvo_pix");
if (IS_ERR(dvo->clk_pix)) {
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
index 14fdc00d2ba03d4f96ba407ac8e576decb6f32c0..eedccdf70833145d8cc316588915db2c766bb31a 100644
--- a/drivers/gpu/drm/sti/sti_hda.c
+++ b/drivers/gpu/drm/sti/sti_hda.c
@@ -750,16 +750,9 @@ 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));
- if (!hda->regs)
- return -ENOMEM;
+ hda->regs = devm_platform_ioremap_resource_byname(pdev, "hda-reg");
+ if (IS_ERR(hda->regs))
+ return PTR_ERR(hda->regs);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
"video-dacs-ctrl");
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index 164a34d793d86f114394048667ae3189e1c39242..37b8d619066ef14a2def26e2e4f90a9c2194238d 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -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,17 +1398,9 @@ 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));
- if (!hdmi->regs) {
- ret = -ENOMEM;
+ hdmi->regs = devm_platform_ioremap_resource_byname(pdev, "hdmi-reg");
+ if (IS_ERR(hdmi->regs)) {
+ ret = PTR_ERR(hdmi->regs);
goto release_adapter;
}
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index 0f658709c9d0d398c4eed65202443db9d0b41f8c..03684062309bbb9915d47fa6e6475cbb6c7beaaa 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -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,17 +1366,10 @@ 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));
- if (!hqvdp->regs) {
+ hqvdp->regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(hqvdp->regs)) {
DRM_ERROR("Register mapping failed\n");
- return -ENXIO;
+ return PTR_ERR(hqvdp->regs);
}
/* Get clock resources */
diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c
index af6c06f448c4819def8cc0d0836e30f991529690..6a464b035de800509fb6dc7c8780b5e1128643c1 100644
--- a/drivers/gpu/drm/sti/sti_tvout.c
+++ b/drivers/gpu/drm/sti/sti_tvout.c
@@ -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,16 +849,9 @@ 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));
- if (!tvout->regs)
- return -ENOMEM;
+ tvout->regs = devm_platform_ioremap_resource_byname(pdev, "tvout-reg");
+ if (IS_ERR(tvout->regs))
+ return PTR_ERR(tvout->regs);
/* get reset resources */
tvout->reset = devm_reset_control_get(dev, "tvout");
diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c
index 5ba469b711b5318e9e9e6d8df127fb8933d1fac1..ee81691b32036d209020498511841f6da053e17d 100644
--- a/drivers/gpu/drm/sti/sti_vtg.c
+++ b/drivers/gpu/drm/sti/sti_vtg.c
@@ -380,23 +380,15 @@ 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));
- if (!vtg->regs) {
+ vtg->regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(vtg->regs)) {
DRM_ERROR("failed to remap I/O memory\n");
- return -ENOMEM;
+ return PTR_ERR(vtg->regs);
}
vtg->irq = platform_get_irq(pdev, 0);
--
2.48.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 6/7] drm/tegra: move to devm_platform_ioremap_resource() usage
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
` (4 preceding siblings ...)
2025-03-04 21:05 ` [PATCH v5 5/7] drm/sti: " Anusha Srivatsa
@ 2025-03-04 21:05 ` Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 7/7] Documentation: Update the todo Anusha Srivatsa
6 siblings, 0 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, 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 <thierry.reding@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
---
drivers/gpu/drm/tegra/dsi.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
index 9bb077558167293c8e47ca9578cef13172b0b22f..b5089b7722676cfaee5d28216af4ae706a47f895 100644
--- a/drivers/gpu/drm/tegra/dsi.c
+++ b/drivers/gpu/drm/tegra/dsi.c
@@ -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;
--
2.48.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 7/7] Documentation: Update the todo
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
` (5 preceding siblings ...)
2025-03-04 21:05 ` [PATCH v5 6/7] drm/tegra: " Anusha Srivatsa
@ 2025-03-04 21:05 ` Anusha Srivatsa
6 siblings, 0 replies; 8+ messages in thread
From: Anusha Srivatsa @ 2025-03-04 21:05 UTC (permalink / raw)
To: Stefan Agner, Alison Wang, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Xinliang Liu,
Tian Tao, Xinwei Kong, Sumit Semwal, Yongqin Liu, John Stultz,
Marek Vasut, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Orson Zhai, Baolin Wang, Chunyan Zhang,
Alain Volmat, Raphael Gallais-Pou, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, Jonathan Corbet
Cc: Dan Carpenter, dri-devel, linux-kernel, imx, linux-arm-kernel,
linux-tegra, linux-doc, Anusha Srivatsa
Update the Documentation to be more precise.
v2: Update for clarity
v3: Further details in Todo
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
Documentation/gpu/todo.rst | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 256d0d1cb2164bd94f9b610a751b907834d96a21..c57777a24e03d91b1ffe04365f7356f2d938befd 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -441,14 +441,15 @@ Contact: Thomas Zimmermann <tzimmermann@suse.de>
Level: Intermediate
-Request memory regions in all drivers
--------------------------------------
+Request memory regions in all fbdev 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(),
+Old/ancient fbdev drivers do not request their memory properly.
+Go through these 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.
-
+where possible. Problematic areas include hardware that has exclusive ranges
+like VGA. VGA16fb does not request the range as it is expected.
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.
--
2.48.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-03-04 21:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-04 21:05 [PATCH v5 0/7] drm: Move to using devm_platform_ioremap_resource Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 1/7] drm/fsl-dcu: move to devm_platform_ioremap_resource() usage Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 2/7] drm/hisilicon: " Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 3/7] drm/mxsfb: " Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 4/7] drm/sprd: " Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 5/7] drm/sti: " Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 6/7] drm/tegra: " Anusha Srivatsa
2025-03-04 21:05 ` [PATCH v5 7/7] Documentation: Update the todo Anusha Srivatsa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®