mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
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: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251121164624.13685-4-johan@kernel.org Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
This commit is contained in:
parent
9dae65913b
commit
78da7027e2
1 changed files with 19 additions and 16 deletions
|
|
@ -595,25 +595,28 @@ 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) {
|
||||
/* 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);
|
||||
if (!link) {
|
||||
dev_err(dev, "Unable to link smi-common dev\n");
|
||||
put_device(&smi_com_pdev->dev);
|
||||
return -ENODEV;
|
||||
}
|
||||
*com_dev = smi_com_dev;
|
||||
} else {
|
||||
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);
|
||||
if (!link) {
|
||||
dev_err(dev, "Unable to link smi-common dev\n");
|
||||
put_device(&smi_com_pdev->dev);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
*com_dev = smi_com_dev;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue