dm: core: Avoid partially removing devices

At present if device_remove() decides that the device should not actually
be removed, it still calls the uclass pre_remove() method and powers the
device down.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2021-01-24 14:32:45 -07:00
parent b1f25fcfef
commit c51d2e704a
3 changed files with 52 additions and 22 deletions

View File

@@ -123,7 +123,9 @@ static int dm_test_virtio_remove(struct unit_test_state *uts)
/* check the device can be successfully removed */
dev_or_flags(dev, DM_FLAG_ACTIVATED);
ut_assertok(device_remove(bus, DM_REMOVE_ACTIVE_ALL));
ut_asserteq(-EKEYREJECTED, device_remove(bus, DM_REMOVE_ACTIVE_ALL));
ut_asserteq(false, device_active(dev));
return 0;
}