soc: apple: sart: require device link for consumers
PATCH 1/1 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.
--- drivers/soc/apple/sart.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/soc/apple/sart.c +7 -2
@@ -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);
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 30 lines · Pengpeng Hou
devm_apple_sart_get()obtains the supplier platform device and attempts to create a runtime-PM device link to it, but it ignoresdevice_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 <[email protected]>--- drivers/soc/apple/sart.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/soc/apple/sart.c +1
-1@@ -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,
drivers/soc/apple/sart.c struct apple_sart *devm_apple_sart_get(struct device *dev) · line 248
Quoted 10 lines
drivers/soc/apple/sart.c +6
-1- 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);
I *think* this is okay...
Quoted 9 lines · Pengpeng Hou
devm_apple_sart_get()obtains the supplier platform device and attempts to create a runtime-PM device link to it, but it ignoresdevice_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.
[...]
Applied to sven/linux (apple-soc/fixes-7.2), thanks!
[1/1] soc: apple: sart: require device link for consumers
https://github.com/AsahiLinux/linux/commit/36887b488b253
Best regards,
Signature · 1 line
Sven Peter <[email protected]>