soc: qcom: smp2p: use scoped device node handling to simplify error paths

Obtain the device node reference with scoped/cleanup.h to reduce error
handling and make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240813-b4-cleanup-h-of-node-put-other-v1-6-cfb67323a95c@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
This commit is contained in:
Krzysztof Kozlowski 2024-08-13 15:09:52 +02:00 committed by Bjorn Andersson
parent a29e97bdc1
commit f728778272

View File

@ -539,7 +539,6 @@ static int smp2p_parse_ipc(struct qcom_smp2p *smp2p)
static int qcom_smp2p_probe(struct platform_device *pdev)
{
struct smp2p_entry *entry;
struct device_node *node;
struct qcom_smp2p *smp2p;
const char *key;
int irq;
@ -593,11 +592,10 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
if (ret < 0)
goto release_mbox;
for_each_available_child_of_node(pdev->dev.of_node, node) {
for_each_available_child_of_node_scoped(pdev->dev.of_node, node) {
entry = devm_kzalloc(&pdev->dev, sizeof(*entry), GFP_KERNEL);
if (!entry) {
ret = -ENOMEM;
of_node_put(node);
goto unwind_interfaces;
}
@ -605,25 +603,19 @@ static int qcom_smp2p_probe(struct platform_device *pdev)
spin_lock_init(&entry->lock);
ret = of_property_read_string(node, "qcom,entry-name", &entry->name);
if (ret < 0) {
of_node_put(node);
if (ret < 0)
goto unwind_interfaces;
}
if (of_property_read_bool(node, "interrupt-controller")) {
ret = qcom_smp2p_inbound_entry(smp2p, entry, node);
if (ret < 0) {
of_node_put(node);
if (ret < 0)
goto unwind_interfaces;
}
list_add(&entry->node, &smp2p->inbound);
} else {
ret = qcom_smp2p_outbound_entry(smp2p, entry, node);
if (ret < 0) {
of_node_put(node);
if (ret < 0)
goto unwind_interfaces;
}
list_add(&entry->node, &smp2p->outbound);
}