Skip to contentSkip to conversation

drm/msm: use compatible lists to find mdp node

PATCH In review Krishna Manikandan 2 participants 2 messages Oct 19, 2021 – Oct 20, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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)

---
 drivers/gpu/drm/msm/msm_drv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +7 -3
index 2e6fc18..451d667 100644
@@ -1241,9 +1241,13 @@ 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);
+	if (!dev->driver)
+		return 0;
+
+	return (of_match_node(dev->driver->of_match_table,
+				dev->of_node) != NULL);
 }
 
 static int add_display_components(struct platform_device *pdev,
@@ -1268,7 +1272,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);
Signature · 1 line
2.7.4
#1 lore raw

Quoting Krishna Manikandan (2021-10-18 22:30:28)

Quoted 19 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.

Changes in v2:
- Use compatible lists instead of duplicate string check (Stephen Boyd)

---
 drivers/gpu/drm/msm/msm_drv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +0 -0
index 2e6fc18..451d667 100644

drivers/gpu/drm/msm/msm_drv.c static int add_components_mdp(struct device *mdp_dev, · line 1246

Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.c +2 -2
@@ -1241,9 +1241,13 @@ 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);
+       if (!dev->driver)

I don't think we want to wait for the device to have an attached driver. That could be far later than when we're trying to add all the components here. Can you reference the match tables directly?

drivers/gpu/drm/msm/msm_drv.c static int add_components_mdp(struct device *mdp_dev, · line 1250

Quoted 4 lines
drivers/gpu/drm/msm/msm_drv.c +4 -0
+               return 0;
+
+       return (of_match_node(dev->driver->of_match_table,
+                               dev->of_node) != NULL);

Drop useless parenthesis.

Quoted 12 lines
drivers/gpu/drm/msm/msm_drv.c +1 -1
 }
 
 static int add_display_components(struct platform_device *pdev,
@@ -1268,7 +1272,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);