Commit 43736546 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov

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: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/499652/
Link: https://lore.kernel.org/r/20220826093927.851597-6-dmitry.baryshkov@linaro.orgSigned-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
parent 248adb81
...@@ -68,14 +68,17 @@ static void msm_hdmi_destroy(struct hdmi *hdmi) ...@@ -68,14 +68,17 @@ static void msm_hdmi_destroy(struct hdmi *hdmi)
destroy_workqueue(hdmi->workq); destroy_workqueue(hdmi->workq);
msm_hdmi_hdcp_destroy(hdmi); msm_hdmi_hdcp_destroy(hdmi);
if (hdmi->i2c)
msm_hdmi_i2c_destroy(hdmi->i2c);
}
static void msm_hdmi_put_phy(struct hdmi *hdmi)
{
if (hdmi->phy_dev) { if (hdmi->phy_dev) {
put_device(hdmi->phy_dev); put_device(hdmi->phy_dev);
hdmi->phy = NULL; hdmi->phy = NULL;
hdmi->phy_dev = NULL; hdmi->phy_dev = NULL;
} }
if (hdmi->i2c)
msm_hdmi_i2c_destroy(hdmi->i2c);
} }
static int msm_hdmi_get_phy(struct hdmi *hdmi) static int msm_hdmi_get_phy(struct hdmi *hdmi)
...@@ -91,19 +94,15 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi) ...@@ -91,19 +94,15 @@ static int msm_hdmi_get_phy(struct hdmi *hdmi)
} }
phy_pdev = of_find_device_by_node(phy_node); phy_pdev = of_find_device_by_node(phy_node);
if (phy_pdev)
hdmi->phy = platform_get_drvdata(phy_pdev);
of_node_put(phy_node); of_node_put(phy_node);
if (!phy_pdev) { if (!phy_pdev)
DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n"); return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n");
return -EPROBE_DEFER;
} hdmi->phy = platform_get_drvdata(phy_pdev);
if (!hdmi->phy) { if (!hdmi->phy) {
DRM_DEV_ERROR(&pdev->dev, "phy driver is not ready\n");
put_device(&phy_pdev->dev); put_device(&phy_pdev->dev);
return -EPROBE_DEFER; return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "phy driver is not ready\n");
} }
hdmi->phy_dev = &phy_pdev->dev; hdmi->phy_dev = &phy_pdev->dev;
...@@ -130,12 +129,6 @@ static int msm_hdmi_init(struct hdmi *hdmi) ...@@ -130,12 +129,6 @@ static int msm_hdmi_init(struct hdmi *hdmi)
goto fail; goto fail;
} }
ret = msm_hdmi_get_phy(hdmi);
if (ret) {
DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n");
goto fail;
}
hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi); hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi);
if (IS_ERR(hdmi->hdcp_ctrl)) { if (IS_ERR(hdmi->hdcp_ctrl)) {
dev_warn(&pdev->dev, "failed to init hdcp: disabled\n"); dev_warn(&pdev->dev, "failed to init hdcp: disabled\n");
...@@ -532,6 +525,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) ...@@ -532,6 +525,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)
if (hdmi->hpd_gpiod) if (hdmi->hpd_gpiod)
gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD"); gpiod_set_consumer_name(hdmi->hpd_gpiod, "HDMI_HPD");
ret = msm_hdmi_get_phy(hdmi);
if (ret) {
DRM_DEV_ERROR(&pdev->dev, "failed to get phy\n");
return ret;
}
ret = devm_pm_runtime_enable(&pdev->dev); ret = devm_pm_runtime_enable(&pdev->dev);
if (ret) if (ret)
return ret; return ret;
...@@ -543,7 +542,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) ...@@ -543,7 +542,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)
static int msm_hdmi_dev_remove(struct platform_device *pdev) static int msm_hdmi_dev_remove(struct platform_device *pdev)
{ {
struct hdmi *hdmi = dev_get_drvdata(&pdev->dev);
component_del(&pdev->dev, &msm_hdmi_ops); component_del(&pdev->dev, &msm_hdmi_ops);
msm_hdmi_put_phy(hdmi);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment