public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH RESEND] drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour
@ 2026-03-24  9:08 Luca Ceresoli
  2026-03-24 20:56 ` Claude review: " Claude Code Review Bot
  2026-03-24 20:56 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Luca Ceresoli @ 2026-03-24  9:08 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: Liu Ying, Hui Pu, Ian Ray, Thomas Petazzoni, dri-devel,
	linux-kernel, Luca Ceresoli

drm_bridge_get and drm_bridge_put() do nothing when they are passed a NULL
pointer, and they do so since their initial addition in commit 30d1b37d4c02
("drm/bridge: add support for refcounting").

This allows simpler code in various places when using these
functions. However it's not documented, so it's not clear whether it is
part of the API "contract" or just a current implementation detail that
might change in the future.

There is no visible reason to remove this NULL check, so document it,
making it part of the contract, letting users count on it.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Historical note: I thought this was documented from the beginning and
realized it's not the case when someone proposed adding a 'if (bridge)
drm_bridge_put(bridge)' to a driver [0]. Let's fix it now.

[0] https://lore.kernel.org/lkml/DG0CHD0TAH9A.27UW4KKY2O9V7@bootlin.com/
---
 drivers/gpu/drm/drm_bridge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 3b165a0d1e77..3108249a63cd 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -282,7 +282,7 @@ static void __drm_bridge_free(struct kref *kref)
 
 /**
  * drm_bridge_get - Acquire a bridge reference
- * @bridge: DRM bridge
+ * @bridge: DRM bridge; if NULL this function does nothing
  *
  * This function increments the bridge's refcount.
  *
@@ -300,7 +300,7 @@ EXPORT_SYMBOL(drm_bridge_get);
 
 /**
  * drm_bridge_put - Release a bridge reference
- * @bridge: DRM bridge
+ * @bridge: DRM bridge; if NULL this function does nothing
  *
  * This function decrements the bridge's reference count and frees the
  * object if the reference count drops to zero.

---
base-commit: a50007089e078a1b7a826559a02277b1601ee189
change-id: 20260129-drm-bridge-alloc-getput-document-null-check-a551e64b8fc1

Best regards,
-- 
Luca Ceresoli <luca.ceresoli@bootlin.com>


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

* Claude review: drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour
  2026-03-24  9:08 [PATCH RESEND] drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour Luca Ceresoli
@ 2026-03-24 20:56 ` Claude Code Review Bot
  2026-03-24 20:56 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-24 20:56 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour
Author: Luca Ceresoli <luca.ceresoli@bootlin.com>
Patches: 1
Reviewed: 2026-03-25T06:56:50.886574

---

This is a single, trivial documentation-only patch. It correctly documents the existing NULL-safe behavior of `drm_bridge_get()` and `drm_bridge_put()`. The change is accurate, useful, and well-motivated.

**Verdict: Looks good.**

---
Generated by Claude Code Patch Reviewer

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

* Claude review: drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour
  2026-03-24  9:08 [PATCH RESEND] drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour Luca Ceresoli
  2026-03-24 20:56 ` Claude review: " Claude Code Review Bot
@ 2026-03-24 20:56 ` Claude Code Review Bot
  1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-24 20:56 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

The patch updates the `@bridge` parameter documentation for both `drm_bridge_get()` and `drm_bridge_put()` from:

```
- * @bridge: DRM bridge
+ * @bridge: DRM bridge; if NULL this function does nothing
```

**Correctness:** Verified against the implementation. Both functions have an `if (bridge)` guard (lines 294 and 310 of `drm_bridge.c`), so the documentation accurately describes the behavior.

**Motivation:** Well explained in the commit message — there's existing code that relies on this (e.g., `__free(drm_bridge_put)` cleanup patterns at lines 1042, 1166, 1230), and callers should be able to depend on it without ambiguity.

**Nit:** For `drm_bridge_get()`, it might be worth also noting the return value in the NULL case (returns NULL), since the function has a documented `Returns: Pointer to @bridge` — but this is minor and the current wording is consistent with how similar kernel APIs (like `kfree`) document their NULL tolerance.

**Reviewed-by: No issues found.**

---
Generated by Claude Code Patch Reviewer

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

end of thread, other threads:[~2026-03-24 20:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24  9:08 [PATCH RESEND] drm/bridge: drm_bridge_get/put(): document NULL pointer behaviour Luca Ceresoli
2026-03-24 20:56 ` Claude review: " Claude Code Review Bot
2026-03-24 20:56 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox