Skip to content

Commit 78da702

Browse files
jhovoldkrzk
authored andcommitted
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>
1 parent 9dae659 commit 78da702

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

drivers/memory/mtk-smi.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -595,25 +595,28 @@ static int mtk_smi_device_link_common(struct device *dev, struct device **com_de
595595

596596
smi_com_pdev = of_find_device_by_node(smi_com_node);
597597
of_node_put(smi_com_node);
598-
if (smi_com_pdev) {
599-
/* smi common is the supplier, Make sure it is ready before */
600-
if (!platform_get_drvdata(smi_com_pdev)) {
601-
put_device(&smi_com_pdev->dev);
602-
return -EPROBE_DEFER;
603-
}
604-
smi_com_dev = &smi_com_pdev->dev;
605-
link = device_link_add(dev, smi_com_dev,
606-
DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
607-
if (!link) {
608-
dev_err(dev, "Unable to link smi-common dev\n");
609-
put_device(&smi_com_pdev->dev);
610-
return -ENODEV;
611-
}
612-
*com_dev = smi_com_dev;
613-
} else {
598+
if (!smi_com_pdev) {
614599
dev_err(dev, "Failed to get the smi_common device\n");
615600
return -EINVAL;
616601
}
602+
603+
/* smi common is the supplier, Make sure it is ready before */
604+
if (!platform_get_drvdata(smi_com_pdev)) {
605+
put_device(&smi_com_pdev->dev);
606+
return -EPROBE_DEFER;
607+
}
608+
609+
smi_com_dev = &smi_com_pdev->dev;
610+
link = device_link_add(dev, smi_com_dev,
611+
DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
612+
if (!link) {
613+
dev_err(dev, "Unable to link smi-common dev\n");
614+
put_device(&smi_com_pdev->dev);
615+
return -ENODEV;
616+
}
617+
618+
*com_dev = smi_com_dev;
619+
617620
return 0;
618621
}
619622

0 commit comments

Comments
 (0)