of/platform: Fix of_platform_device_destroy iteration of devices
authorGrant Likely <grant.likely@linaro.org>
Tue, 24 Jun 2014 15:13:47 +0000 (16:13 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 16 Feb 2015 16:12:53 +0000 (01:12 +0900)
commitf2d2cdb9c3bfe92ac575a540b4b3b04313485caa
tree6576e980556184872fa942df7a9b6af34825353d
parente0bc89c5e7542c36e90d74070ca6af79ff3ec0cf
of/platform: Fix of_platform_device_destroy iteration of devices

of_platform_destroy does not work properly, since the tree
population test was iterating on all devices having as its parent
the given platform device.

The check was intended to check whether any other platform or amba
devices created by of_platform_populate were still populated, but
instead checked for every kind of device. This is wrong, since platform
devices typically create a subsystem regular device and set themselves
as parents.

Instead, go ahead and call the unregister functions for any devices
created with of_platform_populate. The driver core will take care of
unbinding drivers, and drivers are responsible for getting rid of any
child devices that weren't created by of_platform_populate.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
(cherry picked from commit 75f353b61342b5847c7f6d8499fd6301dce09845)
Signed-off-by: Mark Brown <broonie@kernel.org>
Conflicts:
include/linux/of_platform.h
drivers/of/platform.c
include/linux/of.h
include/linux/of_platform.h