public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: fbdev: goldfishfb: use devm_platform_ioremap_resource()
Date: Wed, 04 Mar 2026 07:21:04 +1000	[thread overview]
Message-ID: <review-patch1-20260303-master-v1-1-85eb5ff584b0@gmail.com> (raw)
In-Reply-To: <20260303-master-v1-1-85eb5ff584b0@gmail.com>

Patch Review

**Correctness of the core transformation: OK**

The replacement of `platform_get_resource()` + `ioremap()` with `devm_platform_ioremap_resource()`, and the corresponding `IS_ERR()` / `PTR_ERR()` error check, is textbook correct:

```c
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL) {
-		ret = -ENODEV;
-		goto err_no_io_base;
-	}
-	fb->reg_base = ioremap(r->start, PAGE_SIZE);
-	if (fb->reg_base == NULL) {
-		ret = -ENOMEM;
+	fb->reg_base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(fb->reg_base)) {
+		ret = PTR_ERR(fb->reg_base);
 		goto err_no_io_base;
 	}
```

**Removal of `iounmap()` calls: OK**

Both the error-path and remove-path `iounmap()` removals are correct since the devm infrastructure handles cleanup automatically — on both probe failure and device removal:

```c
 err_no_irq:
-	iounmap(fb->reg_base);
 err_no_io_base:
```

```c
-	iounmap(fb->reg_base);
 	kfree(fb);
```

**Subtle behavioral change #1 — mapping size**: The original code maps exactly `PAGE_SIZE`:
```c
fb->reg_base = ioremap(r->start, PAGE_SIZE);
```
`devm_platform_ioremap_resource()` maps `resource_size(r)`, i.e. the full resource region as described in the device tree / platform data. Since the highest register offset used is `FB_GET_PHYS_HEIGHT = 0x20`, both PAGE_SIZE and any reasonably-defined resource region will cover this — so this is fine in practice, but it's a behavioral change worth being aware of.

**Subtle behavioral change #2 — `request_mem_region()` is now called**: The original code never calls `request_mem_region()`. `devm_platform_ioremap_resource()` internally calls `devm_request_mem_region()` before mapping. This is actually an improvement (the original was technically sloppy), but it could theoretically cause probe to fail if another driver has already claimed the region. For goldfish, this is extremely unlikely.

**Mixed devm / manual allocation**: The `fb` struct is still allocated with `kzalloc()` and freed with `kfree()`, while the ioremap is now devm-managed. This mixed pattern works correctly here — the devm unmap happens after `goldfish_fb_remove()` returns, but the devm infrastructure stores the mapped address in its own devres entry rather than reading it back from `fb->reg_base`, so the `kfree(fb)` preceding the devm cleanup is safe. However, a follow-up patch converting `kzalloc`/`kfree` to `devm_kzalloc` would make the lifecycle management more consistent.

**Overall**: The patch is correct and a net improvement. No blocking issues.

---
Generated by Claude Code Patch Reviewer

      parent reply	other threads:[~2026-03-03 21:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 12:22 [PATCH] fbdev: goldfishfb: use devm_platform_ioremap_resource() Amin GATTOUT
2026-03-03 12:51 ` Thomas Zimmermann
2026-03-03 14:07   ` Helge Deller
2026-03-03 21:21 ` Claude review: " Claude Code Review Bot
2026-03-03 21:21 ` Claude Code Review Bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=review-patch1-20260303-master-v1-1-85eb5ff584b0@gmail.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox