drm/msm: use compatible lists to find mdp node
PATCH v3 1/1 drm/msm: use compatible lists to find mdp node
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.
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)
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 ++- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 3 ++- drivers/gpu/drm/msm/msm_drv.c | 7 ++++--- drivers/gpu/drm/msm/msm_kms.h | 3 +++ 4 files changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +2 -1
@@ -1273,7 +1273,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" , },
@@ -1282,6 +1282,7 @@ static const struct of_device_id dpu_dt_match[] = { {} };MODULE_DEVICE_TABLE (of, dpu_dt_match); +EXPORT_SYMBOL (dpu_dt_match);static struct platform_driver dpu_driver = { .probe = dpu_dev_probe,
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +2 -1
@@ -1031,13 +1031,14 @@ 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" , }, {} };MODULE_DEVICE_TABLE (of, mdp5_dt_match); +EXPORT_SYMBOL (mdp5_dt_match);static struct platform_driver mdp5_driver = { .probe = mdp5_dev_probe,
drivers/gpu/drm/msm/msm_drv.c +4 -3
@@ -1277,9 +1277,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,
@@ -1304,7 +1305,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);
drivers/gpu/drm/msm/msm_kms.h +3 -0
@@ -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);
Signature · 1 line
2.7.4
Quoted 35 lines · Krishna Manikandan
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 <[email protected]>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)--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 3 ++- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 3 ++- drivers/gpu/drm/msm/msm_drv.c | 7 ++++--- drivers/gpu/drm/msm/msm_kms.h | 3 +++ 4 files changed, 11 insertions(+), 5 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1
-1@@ -1273,7 +1273,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" , },
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c static const struct of_device_id dpu_dt_match[] = { · line 1285
Quoted 4 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1
-0@@ -1282,6 +1282,7 @@ static const struct of_device_id dpu_dt_match[] = { {} };MODULE_DEVICE_TABLE (of, dpu_dt_match); +EXPORT_SYMBOL (dpu_dt_match);
There is no need to export these symbols, as they will be used within the module.
Quoted 66 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0
-0static struct platform_driver dpu_driver = { .probe = dpu_dev_probe,drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +2
-1@@ -1031,13 +1031,14 @@ 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" , }, {} };MODULE_DEVICE_TABLE (of, mdp5_dt_match); +EXPORT_SYMBOL (mdp5_dt_match);static struct platform_driver mdp5_driver = { .probe = mdp5_dev_probe,drivers/gpu/drm/msm/msm_drv.c +4
-3@@ -1277,9 +1277,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,@@ -1304,7 +1305,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);drivers/gpu/drm/msm/msm_kms.h +3
-1@@ -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); --2.7.4
Signature · 2 lines
With best wishes Dmitry
Quoting Krishna Manikandan (2021-11-09 01:47:28)
Quoted 7 lines
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 <[email protected]>
Quoted 7 lines
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)
---
With the export symbol dropped