Skip to contentSkip to conversation

fbdev: wmt_ge_rops: use devm_platform_ioremap_resource()

PATCH Applied Amin GATTOUT 2 participants 2 messages Mar 4 – Mar 5

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

PATCH 1/1 fbdev: wmt_ge_rops: use devm_platform_ioremap_resource()

Replace the open-coded platform_get_resource() + ioremap() pair with devm_platform_ioremap_resource(), which requests the memory region and maps it in a single call, with automatic cleanup on device removal.

Also reset regbase to NULL in remove() so that the single-instance guard in probe() works correctly if the device is re-probed.

---
 drivers/video/fbdev/wmt_ge_rops.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/video/fbdev/wmt_ge_rops.c +4 -14
index 2bd26bfb2b46..0cf78bcadfa6 100644
@@ -148,25 +148,15 @@ EXPORT_SYMBOL_GPL(wmt_ge_sync);
 
 static int wmt_ge_rops_probe(struct platform_device *pdev)
 {
-	struct resource *res;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "no I/O memory resource defined\n");
-		return -ENODEV;
-	}
-
 	/* Only one ROP engine is presently supported. */
 	if (unlikely(regbase)) {
 		WARN_ON(1);
 		return -EBUSY;
 	}
 
-	regbase = ioremap(res->start, resource_size(res));
-	if (regbase == NULL) {
-		dev_err(&pdev->dev, "failed to map I/O memory\n");
-		return -EBUSY;
-	}
+	regbase = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(regbase))
+		return PTR_ERR(regbase);
 
 	writel(1, regbase + GE_ENABLE_OFF);
 	printk(KERN_INFO "Enabled support for WMT GE raster acceleration\n");
@@ -176,7 +166,7 @@ static int wmt_ge_rops_probe(struct platform_device *pdev)
 
 static void wmt_ge_rops_remove(struct platform_device *pdev)
 {
-	iounmap(regbase);
+	regbase = NULL;
 }
 
 static const struct of_device_id wmt_dt_ids[] = {

---
base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
change-id: 20260303-master-4dbb344c9a39

Best regards,

Signature · 1 line
Amin GATTOUT <[email protected]>
maintainer Applied
#1 lore raw
Quoted 11 lines · Amin GATTOUT

Replace the open-coded platform_get_resource() + ioremap() pair with devm_platform_ioremap_resource(), which requests the memory region and maps it in a single call, with automatic cleanup on device removal.

Also reset regbase to NULL in remove() so that the single-instance guard in probe() works correctly if the device is re-probed.

---
  drivers/video/fbdev/wmt_ge_rops.c | 18 ++++--------------
  1 file changed, 4 insertions(+), 14 deletions(-)

applied to fbdev git tree.

Thanks!
Helge