Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panel: panel-simple: make panel_dpi_probe return a panel_desc

If the panel-simple driver is probed from a panel-dpi compatible, the
driver will use an empty panel_desc structure as a descriminant. It
will then allocate and fill another panel_desc as part of its probe.

However, that allocation needs to happen after the panel_simple
structure has been allocated, since panel_dpi_probe(), the function
doing the panel_desc allocation and initialization, takes a panel_simple
pointer as an argument.

This pointer is used to fill the panel_simple->desc pointer that is
still initialized with the empty panel_desc when panel_dpi_probe() is
called.

Since commit de04bb0089a9 ("drm/panel/panel-simple: Use the new
allocation in place of devm_kzalloc()"), we will need the panel
connector type found in panel_desc to allocate panel_simple. This
creates a circular dependency where we need panel_desc to create
panel_simple, and need panel_simple to create panel_desc.

Let's break that dependency by making panel_dpi_probe simply return the
panel_desc it initialized and move the panel_simple->desc assignment to
the caller.

This will not fix the breaking commit entirely, but will move us towards
the right direction.

Fixes: de04bb0089a9 ("drm/panel/panel-simple: Use the new allocation in place of devm_kzalloc()")
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Francesco Dolcini <francesco.dolcini@toradex.com> # Toradex Colibri iMX6
Link: https://lore.kernel.org/r/20250626-drm-panel-simple-fixes-v2-2-5afcaa608bdc@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+11 -11
+11 -11
drivers/gpu/drm/panel/panel-simple.c
··· 432 432 433 433 static struct panel_desc panel_dpi; 434 434 435 - static int panel_dpi_probe(struct device *dev, 436 - struct panel_simple *panel) 435 + static struct panel_desc *panel_dpi_probe(struct device *dev) 437 436 { 438 437 struct display_timing *timing; 439 438 const struct device_node *np; ··· 444 445 np = dev->of_node; 445 446 desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); 446 447 if (!desc) 447 - return -ENOMEM; 448 + return ERR_PTR(-ENOMEM); 448 449 449 450 timing = devm_kzalloc(dev, sizeof(*timing), GFP_KERNEL); 450 451 if (!timing) 451 - return -ENOMEM; 452 + return ERR_PTR(-ENOMEM); 452 453 453 454 ret = of_get_display_timing(np, "panel-timing", timing); 454 455 if (ret < 0) { 455 456 dev_err(dev, "%pOF: no panel-timing node found for \"panel-dpi\" binding\n", 456 457 np); 457 - return ret; 458 + return ERR_PTR(ret); 458 459 } 459 460 460 461 desc->timings = timing; ··· 472 473 /* We do not know the connector for the DT node, so guess it */ 473 474 desc->connector_type = DRM_MODE_CONNECTOR_DPI; 474 475 475 - panel->desc = desc; 476 - 477 - return 0; 476 + return desc; 478 477 } 479 478 480 479 #define PANEL_SIMPLE_BOUNDS_CHECK(to_check, bounds, field) \ ··· 610 613 611 614 if (desc == &panel_dpi) { 612 615 /* Handle the generic panel-dpi binding */ 613 - err = panel_dpi_probe(dev, panel); 614 - if (err) 616 + desc = panel_dpi_probe(dev); 617 + if (IS_ERR(desc)) { 618 + err = PTR_ERR(desc); 615 619 goto free_ddc; 616 - desc = panel->desc; 620 + } 621 + 622 + panel->desc = desc; 617 623 } else { 618 624 if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) 619 625 panel_simple_parse_panel_timing_node(dev, panel, &dt);