From: Osama Abdelkader <osama.abdelkader@gmail.com>
To: luca.ceresoli@bootlin.com,
Alain Volmat <alain.volmat@foss.st.com>,
Raphael Gallais-Pou <rgallaispou@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: Osama Abdelkader <osama.abdelkader@gmail.com>
Subject: [PATCH v2] drm/sti: hdmi: simplify probe with devm DDC and bridge
Date: Tue, 14 Apr 2026 20:17:25 +0200 [thread overview]
Message-ID: <20260414181726.177168-1-osama.abdelkader@gmail.com> (raw)
Use devm_add_action_or_reset() to release the DDC I2C adapter from
of_get_i2c_adapter_by_node(), eliminating the release_adapter goto path.
Switch to devm_drm_bridge_add() so the bridge is released on probe failure
without manual drm_bridge_remove() in remove().
v2: devm_add_action_or_reset for DDC + devm_drm_bridge_add (reviewer)
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
drivers/gpu/drm/sti/sti_hdmi.c | 48 ++++++++++++++--------------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index 839c80a7d954..19beaede8501 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -1373,6 +1373,11 @@ static const struct of_device_id hdmi_of_match[] = {
};
MODULE_DEVICE_TABLE(of, hdmi_of_match);
+static void sti_hdmi_i2c_put(void *ptr)
+{
+ i2c_put_adapter(ptr);
+}
+
static int sti_hdmi_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -1393,14 +1398,15 @@ static int sti_hdmi_probe(struct platform_device *pdev)
of_node_put(ddc);
if (!hdmi->ddc_adapt)
return -EPROBE_DEFER;
+ ret = devm_add_action_or_reset(dev, sti_hdmi_i2c_put, hdmi->ddc_adapt);
+ if (ret)
+ return ret;
}
hdmi->dev = pdev->dev;
hdmi->regs = devm_platform_ioremap_resource_byname(pdev, "hdmi-reg");
- if (IS_ERR(hdmi->regs)) {
- ret = PTR_ERR(hdmi->regs);
- goto release_adapter;
- }
+ if (IS_ERR(hdmi->regs))
+ return PTR_ERR(hdmi->regs);
hdmi->phy_ops = (struct hdmi_phy_ops *)
of_match_node(hdmi_of_match, np)->data;
@@ -1409,29 +1415,25 @@ static int sti_hdmi_probe(struct platform_device *pdev)
hdmi->clk_pix = devm_clk_get(dev, "pix");
if (IS_ERR(hdmi->clk_pix)) {
DRM_ERROR("Cannot get hdmi_pix clock\n");
- ret = PTR_ERR(hdmi->clk_pix);
- goto release_adapter;
+ return PTR_ERR(hdmi->clk_pix);
}
hdmi->clk_tmds = devm_clk_get(dev, "tmds");
if (IS_ERR(hdmi->clk_tmds)) {
DRM_ERROR("Cannot get hdmi_tmds clock\n");
- ret = PTR_ERR(hdmi->clk_tmds);
- goto release_adapter;
+ return PTR_ERR(hdmi->clk_tmds);
}
hdmi->clk_phy = devm_clk_get(dev, "phy");
if (IS_ERR(hdmi->clk_phy)) {
DRM_ERROR("Cannot get hdmi_phy clock\n");
- ret = PTR_ERR(hdmi->clk_phy);
- goto release_adapter;
+ return PTR_ERR(hdmi->clk_phy);
}
hdmi->clk_audio = devm_clk_get(dev, "audio");
if (IS_ERR(hdmi->clk_audio)) {
DRM_ERROR("Cannot get hdmi_audio clock\n");
- ret = PTR_ERR(hdmi->clk_audio);
- goto release_adapter;
+ return PTR_ERR(hdmi->clk_audio);
}
hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG;
@@ -1441,15 +1443,14 @@ static int sti_hdmi_probe(struct platform_device *pdev)
hdmi->irq = platform_get_irq_byname(pdev, "irq");
if (hdmi->irq < 0) {
DRM_ERROR("Cannot get HDMI irq\n");
- ret = hdmi->irq;
- goto release_adapter;
+ return hdmi->irq;
}
ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq,
- hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi);
+ hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi);
if (ret) {
DRM_ERROR("Failed to register HDMI interrupt\n");
- goto release_adapter;
+ return ret;
}
hdmi->reset = devm_reset_control_get(dev, "hdmi");
@@ -1459,29 +1460,20 @@ static int sti_hdmi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, hdmi);
- drm_bridge_add(&hdmi->bridge);
- ret = component_add(&pdev->dev, &sti_hdmi_ops);
+ ret = devm_drm_bridge_add(dev, &hdmi->bridge);
if (ret)
- goto remove_bridge;
- return 0;
-
- remove_bridge:
- drm_bridge_remove(&hdmi->bridge);
- release_adapter:
- i2c_put_adapter(hdmi->ddc_adapt);
+ return ret;
- return ret;
+ return component_add(&pdev->dev, &sti_hdmi_ops);
}
static void sti_hdmi_remove(struct platform_device *pdev)
{
struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev);
- i2c_put_adapter(hdmi->ddc_adapt);
if (hdmi->audio_pdev)
platform_device_unregister(hdmi->audio_pdev);
component_del(&pdev->dev, &sti_hdmi_ops);
- drm_bridge_remove(&hdmi->bridge);
}
struct platform_driver sti_hdmi_driver = {
--
2.43.0
reply other threads:[~2026-04-14 18:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260414181726.177168-1-osama.abdelkader@gmail.com \
--to=osama.abdelkader@gmail.com \
--cc=airlied@gmail.com \
--cc=alain.volmat@foss.st.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=rgallaispou@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®