From: Vaibhav Hiremath Date: Mon, 28 Dec 2015 14:36:32 +0000 (+0530) Subject: greybus: arche_platform: Remove child's platform device as part of _remove() fn X-Git-Tag: Ubuntu-4.9.0-1.2~749^2~378^2~21^2~885 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=bc142bbb4ceba0891db6bf36cfb7be13c9a2dd72;p=mirror_ubuntu-zesty-kernel.git greybus: arche_platform: Remove child's platform device as part of _remove() fn It seems we need to delete platform_dev of all childs explicitly, in _remove() fn callback of parent driver. There were some discussions about having of_platform_unpopulate(), but it never made it to mainline. https://lkml.org/lkml/2013/7/19/615 There are some drivers which are removing platform_dev explicitly, as done in this patch. Note that, without this, multiple insmod-rmmod won't work, as I see driver probe gets invoked twice and leads to failure of probe. Signed-off-by: Vaibhav Hiremath Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c index 7d90f5dee1d3..697180d36acc 100644 --- a/drivers/staging/greybus/arche-platform.c +++ b/drivers/staging/greybus/arche-platform.c @@ -149,10 +149,21 @@ 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 int arche_platform_remove(struct platform_device *pdev) { struct arche_platform_drvdata *arche_pdata = platform_get_drvdata(pdev); + device_for_each_child(&pdev->dev, NULL, arche_remove_child); + if (arche_pdata) arche_platform_cleanup(arche_pdata);