Skip to content

Commit 4373654

Browse files
committed
drm/msm/hdmi: move msm_hdmi_get_phy() to msm_hdmi_dev_probe()
To continue the idea of failing the probe() rather than failing the bind(), move the call to msm_hdmi_get_phy() function to msm_hdmi_dev_probe(), so that the driver fails the probe if PHY is not yet available rather than succeeding the probe and then failing the bind() with -EPROBE_DEFER. Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Abhinav Kumar <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/499652/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 248adb8 commit 4373654

File tree

1 file changed

+22
-18
lines changed
  • drivers/gpu/drm/msm/hdmi

1 file changed

+22
-18
lines changed

drivers/gpu/drm/msm/hdmi/hdmi.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,17 @@ static void msm_hdmi_destroy(struct hdmi *hdmi)
6868
destroy_workqueue(hdmi->workq);
6969
msm_hdmi_hdcp_destroy(hdmi);
7070

71+
if (hdmi->i2c)
72+
msm_hdmi_i2c_destroy(hdmi->i2c);
73+
}
74+
75+
static void msm_hdmi_put_phy(struct hdmi *hdmi)
76+
{
7177
if (hdmi->phy_dev) {
7278
put_device(hdmi->phy_dev);
7379
hdmi->phy = NULL;
7480
hdmi->phy_dev = NULL;
7581
}
76-
77-
if (hdmi->i2c)
78-
msm_hdmi_i2c_destroy(hdmi->i2c);
7982
}
8083

8184
static int msm_hdmi_get_phy(struct hdmi *hdmi)
@@ -91,19 +94,15 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi)
9194
}
9295

9396
phy_pdev = of_find_device_by_node(phy_node);
94-
if (phy_pdev)
95-
hdmi->phy = platform_get_drvdata(phy_pdev);
96-
9797
of_node_put(phy_node);
9898

99-
if (!phy_pdev) {
100-
DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n");
101-
return -EPROBE_DEFER;
102-
}
99+
if (!phy_pdev)
100+
return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n");
101+
102+
hdmi->phy = platform_get_drvdata(phy_pdev);
103103
if (!hdmi->phy) {
104-
DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n");
105104
put_device(&phy_pdev->dev);
106-
return -EPROBE_DEFER;
105+
return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n");
107106
}
108107

109108
hdmi->phy_dev = &phy_pdev->dev;
@@ -130,12 +129,6 @@ static int msm_hdmi_init(struct hdmi *hdmi)
130129
goto fail;
131130
}
132131

133-
ret = msm_hdmi_get_phy(hdmi);
134-
if (ret) {
135-
DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n");
136-
goto fail;
137-
}
138-
139132
hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi);
140133
if (IS_ERR(hdmi->hdcp_ctrl)) {
141134
dev_warn(&pdev->dev, "failed to init hdcp: disabled\n");
@@ -532,6 +525,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)
532525
if (hdmi->hpd_gpiod)
533526
gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD");
534527

528+
ret = msm_hdmi_get_phy(hdmi);
529+
if (ret) {
530+
DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n");
531+
return ret;
532+
}
533+
535534
ret = devm_pm_runtime_enable(&pdev->dev);
536535
if (ret)
537536
return ret;
@@ -543,7 +542,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)
543542

544543
static int msm_hdmi_dev_remove(struct platform_device *pdev)
545544
{
545+
struct hdmi *hdmi = dev_get_drvdata(&pdev->dev);
546+
546547
component_del(&pdev->dev, &msm_hdmi_ops);
548+
549+
msm_hdmi_put_phy(hdmi);
550+
547551
return 0;
548552
}
549553

0 commit comments

Comments
 (0)