staging: greybus: arche-platform: fix probe issues
Subsystems (3)
Johan Hovold
maintainercover staging: greybus: arche-platform: fix probe issues
This series fixes some issues with the arche platform drivers probe function.
A fix for the first issue was sent to the list two months ago, but there has been no reply to the review feedback given then.
Non of these are tagged for stable backport as very few people should have the hardware in question and be bothered by this.
Johan
Johan Hovold (3):
staging: greybus: arche-platform: fix coldboot probe error path
staging: greybus: arche-platform: fix memleak on probe failure
staging: greybus: arche-platform: fix OF populate on driver rebind
drivers/staging/greybus/arche-platform.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
Signature · 1 line
2.51.2
Johan Hovold
maintainerPATCH 1/3 staging: greybus: arche-platform: fix coldboot probe error path
Make sure to deregister the PM notifier in case the coldboot sequence fails during probe.
--- drivers/staging/greybus/arche-platform.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/greybus/arche-platform.c +4 -3
@@ -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;
Signature · 1 line
2.51.2
Johan Hovold
maintainerPATCH 2/3 staging: greybus: arche-platform: fix memleak on probe failure
In reply to Johan HovoldMake sure to depopulate the child devices in case of late probe failures to avoid leaking the corresponding resources.
--- drivers/staging/greybus/arche-platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/greybus/arche-platform.c +3 -2
@@ -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;
Signature · 1 line
2.51.2
Johan Hovold
maintainerPATCH 3/3 staging: greybus: arche-platform: fix OF populate on driver rebind
In reply to Johan HovoldSince 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.
--- drivers/staging/greybus/arche-platform.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/staging/greybus/arche-platform.c +1 -10
@@ -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))
Signature · 1 line
2.51.2