Skip to content

Commit 073667f

Browse files
committed
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 de04bb0 ("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: de04bb0 ("drm/panel/panel-simple: Use the new allocation in place of devm_kzalloc()") Reviewed-by: Javier Martinez Canillas <[email protected]> Tested-by: Francesco Dolcini <[email protected]> # Toradex Colibri iMX6 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Maxime Ripard <[email protected]>
1 parent 2d22b63 commit 073667f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

drivers/gpu/drm/panel/panel-simple.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ static const struct drm_panel_funcs panel_simple_funcs = {
432432

433433
static struct panel_desc panel_dpi;
434434

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)
437436
{
438437
struct display_timing *timing;
439438
const struct device_node *np;
@@ -445,17 +444,17 @@ static int panel_dpi_probe(struct device *dev,
445444
np = dev->of_node;
446445
desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
447446
if (!desc)
448-
return -ENOMEM;
447+
return ERR_PTR(-ENOMEM);
449448

450449
timing = devm_kzalloc(dev, sizeof(*timing), GFP_KERNEL);
451450
if (!timing)
452-
return -ENOMEM;
451+
return ERR_PTR(-ENOMEM);
453452

454453
ret = of_get_display_timing(np, "panel-timing", timing);
455454
if (ret < 0) {
456455
dev_err(dev, "%pOF: no panel-timing node found for \"panel-dpi\" binding\n",
457456
np);
458-
return ret;
457+
return ERR_PTR(ret);
459458
}
460459

461460
desc->timings = timing;
@@ -473,9 +472,7 @@ static int panel_dpi_probe(struct device *dev,
473472
/* We do not know the connector for the DT node, so guess it */
474473
desc->connector_type = DRM_MODE_CONNECTOR_DPI;
475474

476-
panel->desc = desc;
477-
478-
return 0;
475+
return desc;
479476
}
480477

481478
#define PANEL_SIMPLE_BOUNDS_CHECK(to_check, bounds, field) \
@@ -613,10 +610,13 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
613610

614611
if (desc == &panel_dpi) {
615612
/* Handle the generic panel-dpi binding */
616-
err = panel_dpi_probe(dev, panel);
617-
if (err)
613+
desc = panel_dpi_probe(dev);
614+
if (IS_ERR(desc)) {
615+
err = PTR_ERR(desc);
618616
goto free_ddc;
619-
desc = panel->desc;
617+
}
618+
619+
panel->desc = desc;
620620
} else {
621621
if (!of_get_display_timing(dev->of_node, "panel-timing", &dt))
622622
panel_simple_parse_panel_timing_node(dev, panel, &dt);

0 commit comments

Comments
 (0)