From: Maxime Ripard <mripard@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>,
Jessica Zhang <quic_jesszhan@quicinc.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Anusha Srivatsa <asrivats@redhat.com>,
Francesco Dolcini <francesco@dolcini.it>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Maxime Ripard <mripard@kernel.org>
Subject: [PATCH v2 3/5] drm/panel: panel-simple: Make panel_simple_probe return its panel
Date: Thu, 26 Jun 2025 12:05:01 +0200 [thread overview]
Message-ID: <20250626-drm-panel-simple-fixes-v2-3-5afcaa608bdc@kernel.org> (raw)
In-Reply-To: <20250626-drm-panel-simple-fixes-v2-0-5afcaa608bdc@kernel.org>
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()")
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/panel/panel-simple.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
index 89188e683822f9202ec580c9a294e42083b9704a..e70ee2d4a538caaae673507b93e02b444a2e1640 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -565,11 +565,11 @@ static int panel_simple_override_nondefault_lvds_datamapping(struct device *dev,
}
return 0;
}
-static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
+static struct panel_simple *panel_simple_probe(struct device *dev, const struct panel_desc *desc)
{
struct panel_simple *panel;
struct display_timing dt;
struct device_node *ddc;
int connector_type;
@@ -577,37 +577,37 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
int err;
panel = devm_drm_panel_alloc(dev, struct panel_simple, base,
&panel_simple_funcs, desc->connector_type);
if (IS_ERR(panel))
- return PTR_ERR(panel);
+ return ERR_CAST(panel);
panel->desc = desc;
panel->supply = devm_regulator_get(dev, "power");
if (IS_ERR(panel->supply))
- return PTR_ERR(panel->supply);
+ return ERR_CAST(panel->supply);
panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
GPIOD_OUT_LOW);
if (IS_ERR(panel->enable_gpio))
- return dev_err_probe(dev, PTR_ERR(panel->enable_gpio),
- "failed to request GPIO\n");
+ return dev_err_cast_probe(dev, panel->enable_gpio,
+ "failed to request GPIO\n");
err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
if (err) {
dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err);
- return err;
+ return ERR_PTR(err);
}
ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
if (ddc) {
panel->ddc = of_find_i2c_adapter_by_node(ddc);
of_node_put(ddc);
if (!panel->ddc)
- return -EPROBE_DEFER;
+ return ERR_PTR(-EPROBE_DEFER);
}
if (desc == &panel_dpi) {
/* Handle the generic panel-dpi binding */
desc = panel_dpi_probe(dev);
@@ -701,20 +701,20 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
goto disable_pm_runtime;
}
drm_panel_add(&panel->base);
- return 0;
+ return panel;
disable_pm_runtime:
pm_runtime_dont_use_autosuspend(dev);
pm_runtime_disable(dev);
free_ddc:
if (panel->ddc)
put_device(&panel->ddc->dev);
- return err;
+ return ERR_PTR(err);
}
static void panel_simple_shutdown(struct device *dev)
{
struct panel_simple *panel = dev_get_drvdata(dev);
@@ -5375,16 +5375,21 @@ static const struct of_device_id platform_of_match[] = {
MODULE_DEVICE_TABLE(of, platform_of_match);
static int panel_simple_platform_probe(struct platform_device *pdev)
{
const struct panel_desc *desc;
+ struct panel_simple *panel;
desc = of_device_get_match_data(&pdev->dev);
if (!desc)
return -ENODEV;
- return panel_simple_probe(&pdev->dev, desc);
+ panel = panel_simple_probe(&pdev->dev, desc);
+ if (IS_ERR(panel))
+ return PTR_ERR(panel);
+
+ return 0;
}
static void panel_simple_platform_remove(struct platform_device *pdev)
{
panel_simple_remove(&pdev->dev);
@@ -5651,20 +5656,22 @@ static const struct of_device_id dsi_of_match[] = {
MODULE_DEVICE_TABLE(of, dsi_of_match);
static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
{
const struct panel_desc_dsi *desc;
+ struct panel_simple *panel;
int err;
desc = of_device_get_match_data(&dsi->dev);
if (!desc)
return -ENODEV;
- err = panel_simple_probe(&dsi->dev, &desc->desc);
- if (err < 0)
- return err;
+ panel = panel_simple_probe(&dsi->dev, &desc->desc);
+ if (IS_ERR(panel))
+ return PTR_ERR(panel);
+ desc = container_of(panel->desc, struct panel_desc_dsi, desc);
dsi->mode_flags = desc->flags;
dsi->format = desc->format;
dsi->lanes = desc->lanes;
err = mipi_dsi_attach(dsi);
--
2.49.0
next prev parent reply other threads:[~2025-06-26 10:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 10:04 [PATCH v2 0/5] drm/panel: panel-simple: Fix panel-dpi probe error Maxime Ripard
2025-06-26 10:04 ` [PATCH v2 1/5] drm/mipi-dsi: Add dev_is_mipi_dsi function Maxime Ripard
2025-06-27 9:04 ` Javier Martinez Canillas
2025-06-27 9:25 ` Maxime Ripard
2025-06-27 9:34 ` Javier Martinez Canillas
2025-06-26 10:05 ` [PATCH v2 2/5] drm/panel: panel-simple: make panel_dpi_probe return a panel_desc Maxime Ripard
2025-06-27 9:06 ` Javier Martinez Canillas
2025-06-26 10:05 ` Maxime Ripard [this message]
2025-06-27 9:10 ` [PATCH v2 3/5] drm/panel: panel-simple: Make panel_simple_probe return its panel Javier Martinez Canillas
2025-06-26 10:05 ` [PATCH v2 4/5] drm/panel: panel-simple: Add function to look panel data up Maxime Ripard
2025-06-27 9:12 ` Javier Martinez Canillas
2025-06-26 10:05 ` [PATCH v2 5/5] drm/panel: panel-simple: get rid of panel_dpi hack Maxime Ripard
2025-06-27 9:13 ` Javier Martinez Canillas
2025-06-26 10:21 ` [PATCH v2 0/5] drm/panel: panel-simple: Fix panel-dpi probe error Francesco Dolcini
2025-06-27 9:24 ` Maxime Ripard
2025-06-27 9:24 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250626-drm-panel-simple-fixes-v2-3-5afcaa608bdc@kernel.org \
--to=mripard@kernel.org \
--cc=airlied@gmail.com \
--cc=asrivats@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=francesco@dolcini.it \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=neil.armstrong@linaro.org \
--cc=quic_jesszhan@quicinc.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.