Skip to contentSkip to conversation

soc: qcom: smsm: fix child-node lookup

PATCH In review Johan Hovold 2 participants 2 messages Nov 15, 2017 – Nov 16, 2017

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

PATCH 1/1 soc: qcom: smsm: fix child-node lookup

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

Note that the original premature free of the parent node has already been fixed separately.

Also note that this pattern of looking up the first child node with a given property is rare enough that a generic helper is probably not warranted.

Fixes c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM")
Fixes 3e8b55411468 ("soc: qcom: smsm: fix of_node refcnting problem")
Cc Bjorn Andersson <[email protected]>
Cc Rob Clark <[email protected]>
---
 drivers/soc/qcom/smsm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/soc/qcom/smsm.c +4 -2
index 403bea9d546b..50214b620865 100644
@@ -496,8 +496,10 @@ static int qcom_smsm_probe(struct platform_device *pdev)
 	if (!smsm->hosts)
 		return -ENOMEM;
 
-	local_node = of_find_node_with_property(of_node_get(pdev->dev.of_node),
-						"#qcom,smem-state-cells");
+	for_each_child_of_node(pdev->dev.of_node, local_node) {
+		if (of_find_property(local_node, "#qcom,smem-state-cells", NULL))
+			break;
+	}
 	if (!local_node) {
 		dev_err(&pdev->dev, "no state entry\n");
 		return -EINVAL;
Signature · 1 line
2.15.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Johan Hovold

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

Note that the original premature free of the parent node has already been fixed separately.

Also note that this pattern of looking up the first child node with a given property is rare enough that a generic helper is probably not warranted.

I agree.

Quoted 5 lines
Fixes c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM")
Fixes 3e8b55411468 ("soc: qcom: smsm: fix of_node refcnting problem")
Cc Bjorn Andersson <[email protected]>
Cc Rob Clark <[email protected]>

Thanks,
Bjorn

Quoted 24 lines
---
 drivers/soc/qcom/smsm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/soc/qcom/smsm.c +4 -2
index 403bea9d546b..50214b620865 100644
@@ -496,8 +496,10 @@ static int qcom_smsm_probe(struct platform_device *pdev)
 	if (!smsm->hosts)
 		return -ENOMEM;
 
-	local_node = of_find_node_with_property(of_node_get(pdev->dev.of_node),
-						"#qcom,smem-state-cells");
+	for_each_child_of_node(pdev->dev.of_node, local_node) {
+		if (of_find_property(local_node, "#qcom,smem-state-cells", NULL))
+			break;
+	}
 	if (!local_node) {
 		dev_err(&pdev->dev, "no state entry\n");
 		return -EINVAL;
Signature · 1 line
2.15.0