Commit 78da7027 authored by Johan Hovold's avatar Johan Hovold Committed by Krzysztof Kozlowski
Browse files

memory: mtk-smi: clean up device link creation



Clean up device link creation by bailing out early in case the SMI
platform device lookup fails.

Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20251121164624.13685-4-johan@kernel.org


Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
parent 9dae6591
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -595,12 +595,17 @@ static int mtk_smi_device_link_common(struct device *dev, struct device **com_de

	smi_com_pdev = of_find_device_by_node(smi_com_node);
	of_node_put(smi_com_node);
	if (smi_com_pdev) {
	if (!smi_com_pdev) {
		dev_err(dev, "Failed to get the smi_common device\n");
		return -EINVAL;
	}

	/* smi common is the supplier, Make sure it is ready before */
	if (!platform_get_drvdata(smi_com_pdev)) {
		put_device(&smi_com_pdev->dev);
		return -EPROBE_DEFER;
	}

	smi_com_dev = &smi_com_pdev->dev;
	link = device_link_add(dev, smi_com_dev,
			       DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
@@ -609,11 +614,9 @@ static int mtk_smi_device_link_common(struct device *dev, struct device **com_de
		put_device(&smi_com_pdev->dev);
		return -ENODEV;
	}

	*com_dev = smi_com_dev;
	} else {
		dev_err(dev, "Failed to get the smi_common device\n");
		return -EINVAL;
	}

	return 0;
}