* [PATCH 1/3] staging: greybus: arche-platform: fix coldboot probe error path
2025-12-19 10:59 [PATCH 0/3] staging: greybus: arche-platform: fix probe issues Johan Hovold
@ 2025-12-19 10:59 ` Johan Hovold
2025-12-19 10:59 ` [PATCH 2/3] staging: greybus: arche-platform: fix memleak on probe failure Johan Hovold
2025-12-19 10:59 ` [PATCH 3/3] staging: greybus: arche-platform: fix OF populate on driver rebind Johan Hovold
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2025-12-19 10:59 UTC (permalink / raw)
To: Johan Hovold, Alex Elder, Greg Kroah-Hartman, Vaibhav Hiremath
Cc: greybus-dev, linux-staging, linux-kernel, Haotian Zhang
Make sure to deregister the PM notifier in case the coldboot sequence
fails during probe.
Fixes: d29b67d44a7c ("greybus: arche-platform: Add support for init-off feature")
Reported-by: Haotian Zhang <vulab@iscas.ac.cn>
Link: https://lore.kernel.org/lkml/20251104090825.224-1-vulab@iscas.ac.cn/
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/staging/greybus/arche-platform.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index d48464390f58..bd069d75391b 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -534,8 +534,9 @@ static int arche_platform_probe(struct platform_device *pdev)
mutex_lock(&arche_pdata->platform_state_mutex);
ret = arche_platform_coldboot_seq(arche_pdata);
if (ret) {
+ mutex_unlock(&arche_pdata->platform_state_mutex);
dev_err(dev, "Failed to cold boot svc %d\n", ret);
- goto err_coldboot;
+ goto err_unregister_pm_notifier;
}
arche_platform_wd_irq_en(arche_pdata);
mutex_unlock(&arche_pdata->platform_state_mutex);
@@ -544,8 +545,8 @@ static int arche_platform_probe(struct platform_device *pdev)
dev_info(dev, "Device registered successfully\n");
return 0;
-err_coldboot:
- mutex_unlock(&arche_pdata->platform_state_mutex);
+err_unregister_pm_notifier:
+ unregister_pm_notifier(&arche_pdata->pm_notifier);
err_device_remove:
device_remove_file(&pdev->dev, &dev_attr_state);
return ret;
--
2.51.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] staging: greybus: arche-platform: fix memleak on probe failure
2025-12-19 10:59 [PATCH 0/3] staging: greybus: arche-platform: fix probe issues Johan Hovold
2025-12-19 10:59 ` [PATCH 1/3] staging: greybus: arche-platform: fix coldboot probe error path Johan Hovold
@ 2025-12-19 10:59 ` Johan Hovold
2025-12-19 10:59 ` [PATCH 3/3] staging: greybus: arche-platform: fix OF populate on driver rebind Johan Hovold
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2025-12-19 10:59 UTC (permalink / raw)
To: Johan Hovold, Alex Elder, Greg Kroah-Hartman, Vaibhav Hiremath
Cc: greybus-dev, linux-staging, linux-kernel
Make sure to depopulate the child devices in case of late probe
failures to avoid leaking the corresponding resources.
Fixes: fd60ac585607 ("greybus: arche-platform: Fix boot, poweroff and fw_flashing seq with APBs")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/staging/greybus/arche-platform.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index bd069d75391b..7dcb33a6f2e3 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -523,10 +523,9 @@ static int arche_platform_probe(struct platform_device *pdev)
arche_pdata->pm_notifier.notifier_call = arche_platform_pm_notifier;
ret = register_pm_notifier(&arche_pdata->pm_notifier);
-
if (ret) {
dev_err(dev, "failed to register pm notifier %d\n", ret);
- goto err_device_remove;
+ goto err_depopulate;
}
/* Explicitly power off if requested */
@@ -547,6 +546,8 @@ static int arche_platform_probe(struct platform_device *pdev)
err_unregister_pm_notifier:
unregister_pm_notifier(&arche_pdata->pm_notifier);
+err_depopulate:
+ of_platform_depopulate(dev);
err_device_remove:
device_remove_file(&pdev->dev, &dev_attr_state);
return ret;
--
2.51.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] staging: greybus: arche-platform: fix OF populate on driver rebind
2025-12-19 10:59 [PATCH 0/3] staging: greybus: arche-platform: fix probe issues Johan Hovold
2025-12-19 10:59 ` [PATCH 1/3] staging: greybus: arche-platform: fix coldboot probe error path Johan Hovold
2025-12-19 10:59 ` [PATCH 2/3] staging: greybus: arche-platform: fix memleak on probe failure Johan Hovold
@ 2025-12-19 10:59 ` Johan Hovold
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2025-12-19 10:59 UTC (permalink / raw)
To: Johan Hovold, Alex Elder, Greg Kroah-Hartman, Vaibhav Hiremath
Cc: greybus-dev, linux-staging, linux-kernel
Since commit c6e126de43e7 ("of: Keep track of populated platform
devices") child devices will not be created by of_platform_populate()
if the devices had previously been deregistered individually so that the
OF_POPULATED flag is still set in the corresponding OF nodes.
Switch to using of_platform_depopulate() instead of open coding so that
the child devices are created if the driver is rebound.
Fixes: bc142bbb4ceb ("greybus: arche_platform: Remove child's platform device as part of _remove() fn")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/staging/greybus/arche-platform.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
index 7dcb33a6f2e3..8aaff4e45660 100644
--- a/drivers/staging/greybus/arche-platform.c
+++ b/drivers/staging/greybus/arche-platform.c
@@ -553,22 +553,13 @@ static int arche_platform_probe(struct platform_device *pdev)
return ret;
}
-static int arche_remove_child(struct device *dev, void *unused)
-{
- struct platform_device *pdev = to_platform_device(dev);
-
- platform_device_unregister(pdev);
-
- return 0;
-}
-
static void arche_platform_remove(struct platform_device *pdev)
{
struct arche_platform_drvdata *arche_pdata = platform_get_drvdata(pdev);
unregister_pm_notifier(&arche_pdata->pm_notifier);
device_remove_file(&pdev->dev, &dev_attr_state);
- device_for_each_child(&pdev->dev, NULL, arche_remove_child);
+ of_platform_depopulate(&pdev->dev);
arche_platform_poweroff_seq(arche_pdata);
if (usb3613_hub_mode_ctrl(false))
--
2.51.2
^ permalink raw reply related [flat|nested] 4+ messages in thread