mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: docg3: use devm_platform_ioremap_resource()
@ 2026-09-07  0:49 Rosen Penev
  2026-09-09  7:55 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-09-07  0:49 UTC (permalink / raw)
  To: linux-mtd
  Cc: Robert Jarzmik, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

Replace the open-coded platform_get_resource(IORESOURCE_MEM, 0) plus
devm_ioremap() sequence with devm_platform_ioremap_resource(), which folds
the resource lookup, region reservation and mapping into one step and
returns an ERR_PTR checked with IS_ERR()/PTR_ERR().

The canonical docg3 register window is DOC_IOSPACE_SIZE (0x2000), which is
the size any platform provides for this device, so mapping the full
resource is equivalent to the previous fixed-size devm_ioremap().

Built for ARM (multi_v7_defconfig + CONFIG_MTD_DOCG3) with LLVM=1;
drivers/mtd/devices/docg3.o compiles cleanly.

Assisted-by: opencode:hy3-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/mtd/devices/docg3.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index 603fd0efc2ea..bbdf3bfb0e70 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -1971,25 +1971,15 @@ static int __init docg3_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtd_info *mtd;
-	struct resource *ress;
 	void __iomem *base;
 	int ret, floor;
 	struct docg3_cascade *cascade;
 
-	ret = -ENXIO;
-	ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!ress) {
-		dev_err(dev, "No I/O memory resource defined\n");
-		return ret;
-	}
+	base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	ret = -ENOMEM;
-	base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
-	if (!base) {
-		dev_err(dev, "devm_ioremap dev failed\n");
-		return ret;
-	}
-
 	cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade),
 			       GFP_KERNEL);
 	if (!cascade)
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: docg3: use devm_platform_ioremap_resource()
  2026-09-07  0:49 [PATCH] mtd: docg3: use devm_platform_ioremap_resource() Rosen Penev
@ 2026-09-09  7:55 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2026-09-09  7:55 UTC (permalink / raw)
  To: linux-mtd, Rosen Penev
  Cc: Robert Jarzmik, Richard Weinberger, Vignesh Raghavendra,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	linux-kernel, llvm

On Sun, 06 Sep 2026 17:49:10 -0700, Rosen Penev wrote:
> Replace the open-coded platform_get_resource(IORESOURCE_MEM, 0) plus
> devm_ioremap() sequence with devm_platform_ioremap_resource(), which folds
> the resource lookup, region reservation and mapping into one step and
> returns an ERR_PTR checked with IS_ERR()/PTR_ERR().
> 
> The canonical docg3 register window is DOC_IOSPACE_SIZE (0x2000), which is
> the size any platform provides for this device, so mapping the full
> resource is equivalent to the previous fixed-size devm_ioremap().
> 
> [...]

Applied to mtd/next, thanks!

[1/1] mtd: docg3: use devm_platform_ioremap_resource()
      commit: 8fcbb04ee5152b303980b2b48d69c6f7f4094ca6

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-09  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-07  0:49 [PATCH] mtd: docg3: use devm_platform_ioremap_resource() Rosen Penev
2026-09-09  7:55 ` Miquel Raynal

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®