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_simple_probe return its panel

In order to fix the regession introduced by commit de04bb0089a9
("drm/panel/panel-simple: Use the new allocation in place of
devm_kzalloc()"), we need to move the panel_desc lookup into the common
panel_simple_probe() function.

There's two callers for that function, the probe implementations of the
platform and MIPI-DSI drivers panel-simple implements.

The MIPI-DSI driver's probe will need to access the current panel_desc
to initialize properly, which won't be possible anymore if we make that
lookup in panel_simple_probe().

However, we can make panel_simple_probe() return the initialized
panel_simple structure it allocated, which will contain a pointer to the
associated panel_desc in its desc field.

This doesn't fix de04bb0089a9 ("drm/panel/panel-simple: Use the new
allocation in place of devm_kzalloc()") still, but makes progress
towards that goal.

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-3-5afcaa608bdc@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+20 -13
+20 -13
drivers/gpu/drm/panel/panel-simple.c
··· 567 567 return 0; 568 568 } 569 569 570 - static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) 570 + static struct panel_simple *panel_simple_probe(struct device *dev, const struct panel_desc *desc) 571 571 { 572 572 struct panel_simple *panel; 573 573 struct display_timing dt; ··· 579 579 panel = devm_drm_panel_alloc(dev, struct panel_simple, base, 580 580 &panel_simple_funcs, desc->connector_type); 581 581 if (IS_ERR(panel)) 582 - return PTR_ERR(panel); 582 + return ERR_CAST(panel); 583 583 584 584 panel->desc = desc; 585 585 586 586 panel->supply = devm_regulator_get(dev, "power"); 587 587 if (IS_ERR(panel->supply)) 588 - return PTR_ERR(panel->supply); 588 + return ERR_CAST(panel->supply); 589 589 590 590 panel->enable_gpio = devm_gpiod_get_optional(dev, "enable", 591 591 GPIOD_OUT_LOW); 592 592 if (IS_ERR(panel->enable_gpio)) 593 - return dev_err_probe(dev, PTR_ERR(panel->enable_gpio), 594 - "failed to request GPIO\n"); 593 + return dev_err_cast_probe(dev, panel->enable_gpio, 594 + "failed to request GPIO\n"); 595 595 596 596 err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation); 597 597 if (err) { 598 598 dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err); 599 - return err; 599 + return ERR_PTR(err); 600 600 } 601 601 602 602 ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); ··· 605 605 of_node_put(ddc); 606 606 607 607 if (!panel->ddc) 608 - return -EPROBE_DEFER; 608 + return ERR_PTR(-EPROBE_DEFER); 609 609 } 610 610 611 611 if (desc == &panel_dpi) { ··· 703 703 704 704 drm_panel_add(&panel->base); 705 705 706 - return 0; 706 + return panel; 707 707 708 708 disable_pm_runtime: 709 709 pm_runtime_dont_use_autosuspend(dev); ··· 712 712 if (panel->ddc) 713 713 put_device(&panel->ddc->dev); 714 714 715 - return err; 715 + return ERR_PTR(err); 716 716 } 717 717 718 718 static void panel_simple_shutdown(struct device *dev) ··· 5377 5377 static int panel_simple_platform_probe(struct platform_device *pdev) 5378 5378 { 5379 5379 const struct panel_desc *desc; 5380 + struct panel_simple *panel; 5380 5381 5381 5382 desc = of_device_get_match_data(&pdev->dev); 5382 5383 if (!desc) 5383 5384 return -ENODEV; 5384 5385 5385 - return panel_simple_probe(&pdev->dev, desc); 5386 + panel = panel_simple_probe(&pdev->dev, desc); 5387 + if (IS_ERR(panel)) 5388 + return PTR_ERR(panel); 5389 + 5390 + return 0; 5386 5391 } 5387 5392 5388 5393 static void panel_simple_platform_remove(struct platform_device *pdev) ··· 5658 5653 static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi) 5659 5654 { 5660 5655 const struct panel_desc_dsi *desc; 5656 + struct panel_simple *panel; 5661 5657 int err; 5662 5658 5663 5659 desc = of_device_get_match_data(&dsi->dev); 5664 5660 if (!desc) 5665 5661 return -ENODEV; 5666 5662 5667 - err = panel_simple_probe(&dsi->dev, &desc->desc); 5668 - if (err < 0) 5669 - return err; 5663 + panel = panel_simple_probe(&dsi->dev, &desc->desc); 5664 + if (IS_ERR(panel)) 5665 + return PTR_ERR(panel); 5670 5666 5667 + desc = container_of(panel->desc, struct panel_desc_dsi, desc); 5671 5668 dsi->mode_flags = desc->flags; 5672 5669 dsi->format = desc->format; 5673 5670 dsi->lanes = desc->lanes;