[PATCH v2 3/6] drm/mcde: dsi: mcde_dsi_bind: break when a panel or bridge is found

Luca Ceresoli posted 6 patches 1 week, 2 days ago
[PATCH v2 3/6] drm/mcde: dsi: mcde_dsi_bind: break when a panel or bridge is found
Posted by Luca Ceresoli 1 week, 2 days ago
mcde_dsi_bind() has a loop over all subnodes looking for a panel, but does
not exit when a match is found and only stores the last match. However this
will be problematic when introducing refcounting on the struct drm_device
pointer in a following commit, because of_drm_find_and_get_bridge() would
get a reference to multiple bridges.

There seem to be no real reason for looking for multiple panels, so just
break as soon as a match is found.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

---

Changes in v2:
- break instead of warning as suggested by Linus Walleij:
  https://lore.kernel.org/r/CAD++jLm_Va+7c_usgoPDhsDiCr4NQMZWsQ3iJW5-a1ETP4EaJQ@mail.gmail.com
---
 drivers/gpu/drm/mcde/mcde_dsi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index a3423459dd7a..5893fd2681b3 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -1116,6 +1116,11 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
 				return -EINVAL;
 			}
 		}
+
+		if (panel || bridge) {
+			of_node_put(child);
+			break;
+		}
 	}
 	if (panel) {
 		bridge = drm_panel_bridge_add_typed(panel,

-- 
2.52.0
Re: [PATCH v2 3/6] drm/mcde: dsi: mcde_dsi_bind: break when a panel or bridge is found
Posted by Linus Walleij 1 week ago
On Sat, Jan 31, 2026 at 4:58 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:

> mcde_dsi_bind() has a loop over all subnodes looking for a panel, but does
> not exit when a match is found and only stores the last match. However this
> will be problematic when introducing refcounting on the struct drm_device
> pointer in a following commit, because of_drm_find_and_get_bridge() would
> get a reference to multiple bridges.
>
> There seem to be no real reason for looking for multiple panels, so just
> break as soon as a match is found.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij