drm/msm: use compatible lists to find mdp node
authorKrishna Manikandan <quic_mkrishn@quicinc.com>
Wed, 10 Nov 2021 10:51:47 +0000 (16:21 +0530)
committerRob Clark <robdclark@chromium.org>
Tue, 30 Nov 2021 00:19:58 +0000 (16:19 -0800)
In the current implementation, substring comparison
using device node name is used to find mdp node
during driver probe. Use compatible string list instead
of node name to get mdp node from the parent mdss node.

Signed-off-by: Krishna Manikandan <quic_mkrishn@quicinc.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Changes in v2:
  - Use compatible lists instead of duplicate string
    check (Stephen Boyd)

Changes in v3:
  - Use match tables to find the mdp node (Stephen Boyd)

Changes in v4:
  - Drop EXPORT_SYMBOL (Dmitry Baryshkov)
Link: https://lore.kernel.org/r/1636541507-5144-1-git-send-email-quic_mkrishn@quicinc.com
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_kms.h

index a15b264282809545d757b984841231c2991d3eb7..6c457c4194121a0d41e742045676b0e3f3076e88 100644 (file)
@@ -1285,7 +1285,7 @@ static const struct dev_pm_ops dpu_pm_ops = {
                                pm_runtime_force_resume)
 };
 
-static const struct of_device_id dpu_dt_match[] = {
+const struct of_device_id dpu_dt_match[] = {
        { .compatible = "qcom,sdm845-dpu", },
        { .compatible = "qcom,sc7180-dpu", },
        { .compatible = "qcom,sc7280-dpu", },
index ec022657b9ad9ee9bbb0bcd1cd216d7823f96f12..f78a6eec0dddcd4420057d2a71aa246c071d9445 100644 (file)
@@ -1016,7 +1016,7 @@ static const struct dev_pm_ops mdp5_pm_ops = {
        SET_RUNTIME_PM_OPS(mdp5_runtime_suspend, mdp5_runtime_resume, NULL)
 };
 
-static const struct of_device_id mdp5_dt_match[] = {
+const struct of_device_id mdp5_dt_match[] = {
        { .compatible = "qcom,mdp5", },
        /* to support downstream DT files */
        { .compatible = "qcom,mdss_mdp", },
index 91cc4512bafbbcbac155fd6609e6754837622990..f81cf70974945e4c378f3adab291948005fb2af2 100644 (file)
@@ -1286,9 +1286,10 @@ static int add_components_mdp(struct device *mdp_dev,
        return 0;
 }
 
-static int compare_name_mdp(struct device *dev, void *data)
+static int find_mdp_node(struct device *dev, void *data)
 {
-       return (strstr(dev_name(dev), "mdp") != NULL);
+       return of_match_node(dpu_dt_match, dev->of_node) ||
+               of_match_node(mdp5_dt_match, dev->of_node);
 }
 
 static int add_display_components(struct platform_device *pdev,
@@ -1313,7 +1314,7 @@ static int add_display_components(struct platform_device *pdev,
                        return ret;
                }
 
-               mdp_dev = device_find_child(dev, NULL, compare_name_mdp);
+               mdp_dev = device_find_child(dev, NULL, find_mdp_node);
                if (!mdp_dev) {
                        DRM_DEV_ERROR(dev, "failed to find MDSS MDP node\n");
                        of_platform_depopulate(dev);
index 6a42b819abc4c2ba57a80b64f13d7d3ad582e762..8b132c8b15131417b8e2f4de8a6e289628c51bfb 100644 (file)
@@ -198,6 +198,9 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev);
 struct msm_kms *mdp5_kms_init(struct drm_device *dev);
 struct msm_kms *dpu_kms_init(struct drm_device *dev);
 
+extern const struct of_device_id dpu_dt_match[];
+extern const struct of_device_id mdp5_dt_match[];
+
 struct msm_mdss_funcs {
        int (*enable)(struct msm_mdss *mdss);
        int (*disable)(struct msm_mdss *mdss);