soc: apple: sart: require device link for consumers

devm_apple_sart_get() obtains the supplier platform device and attempts
to create a runtime-PM device link to it, but it ignores device_link_add()
failure.  A consumer can then continue without the dependency that keeps
the SART supplier ordered and runtime-PM reachable.

Treat a failed device link as an error and drop the supplier device
reference before returning.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Joshua Peisach <jpeisach@ubuntu.com>
Link: https://patch.msgid.link/20260616005346.7862-1-pengpeng@iscas.ac.cn
Signed-off-by: Sven Peter <sven@kernel.org>
This commit is contained in:
Pengpeng Hou 2026-06-16 08:53:46 +08:00 committed by Sven Peter
parent dc59e4fea9
commit 36887b488b

View File

@ -218,6 +218,7 @@ struct apple_sart *devm_apple_sart_get(struct device *dev)
{
struct device_node *sart_node;
struct platform_device *sart_pdev;
struct device_link *link;
struct apple_sart *sart;
sart_node = of_parse_phandle(dev->of_node, "apple,sart", 0);
@ -236,8 +237,12 @@ struct apple_sart *devm_apple_sart_get(struct device *dev)
return ERR_PTR(-EPROBE_DEFER);
}
device_link_add(dev, &sart_pdev->dev,
DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER);
link = device_link_add(dev, &sart_pdev->dev,
DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER);
if (!link) {
put_device(&sart_pdev->dev);
return ERR_PTR(-ENODEV);
}
put_device(&sart_pdev->dev);