dm: core: Fix handling of uclass pre_unbind method
authorSimon Glass <sjg@chromium.org>
Sat, 23 Oct 2021 23:26:05 +0000 (17:26 -0600)
committerSimon Glass <sjg@chromium.org>
Sun, 28 Nov 2021 23:51:51 +0000 (16:51 -0700)
commit804431830593820575158aa5c4b098aab59efc88
tree8baf7751a924db68b550a409276bde47f7a95ce4
parentfb933d070eb00274bb7e041cae98e858208961e2
dm: core: Fix handling of uclass pre_unbind method

This method is currently called after the platform data has been freed.
But the pre_unbind() method may wish to access this, e.g. to free some
data structures stored there.

Split the unbinding of devices into two pieces, as is done with removal.
This corrects the problem.

Also tidy a code-style issue in device_remove() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/core/device-remove.c
drivers/core/uclass.c
include/dm/uclass-internal.h