mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-10-01 02:31:27 +02:00
test: Use a simple variable to record removed device
At present the entire test state is effective passed into a test driver just to record which device was removed. This is unnecessary and makes it harder to track what is going on. Use a simple boolean instead. Also drop the unused 'removed' member while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
6d1a8ebefb
commit
3f8760824e
@ -134,14 +134,12 @@ extern struct unit_test_state global_dm_test_state;
|
|||||||
* @testdev: Test device
|
* @testdev: Test device
|
||||||
* @force_fail_alloc: Force all memory allocs to fail
|
* @force_fail_alloc: Force all memory allocs to fail
|
||||||
* @skip_post_probe: Skip uclass post-probe processing
|
* @skip_post_probe: Skip uclass post-probe processing
|
||||||
* @removed: Used to keep track of a device that was removed
|
|
||||||
*/
|
*/
|
||||||
struct dm_test_state {
|
struct dm_test_state {
|
||||||
struct udevice *root;
|
struct udevice *root;
|
||||||
struct udevice *testdev;
|
struct udevice *testdev;
|
||||||
int force_fail_alloc;
|
int force_fail_alloc;
|
||||||
int skip_post_probe;
|
int skip_post_probe;
|
||||||
struct udevice *removed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Declare a new driver model test */
|
/* Declare a new driver model test */
|
||||||
|
@ -30,7 +30,8 @@ enum {
|
|||||||
FLAG_CHILD_REMOVED = -7,
|
FLAG_CHILD_REMOVED = -7,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct dm_test_state *test_state;
|
/* Records the last testbus device that was removed */
|
||||||
|
static struct udevice *testbus_removed;
|
||||||
|
|
||||||
static int testbus_drv_probe(struct udevice *dev)
|
static int testbus_drv_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
@ -78,11 +79,9 @@ static int testbus_child_post_probe_uclass(struct udevice *dev)
|
|||||||
static int testbus_child_post_remove(struct udevice *dev)
|
static int testbus_child_post_remove(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
|
struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
|
||||||
struct dm_test_state *dms = test_state;
|
|
||||||
|
|
||||||
parent_data->flag += FLAG_CHILD_REMOVED;
|
parent_data->flag += FLAG_CHILD_REMOVED;
|
||||||
if (dms)
|
testbus_removed = dev;
|
||||||
dms->removed = dev;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -335,11 +334,10 @@ DM_TEST(dm_test_bus_parent_data_uclass,
|
|||||||
static int dm_test_bus_parent_ops(struct unit_test_state *uts)
|
static int dm_test_bus_parent_ops(struct unit_test_state *uts)
|
||||||
{
|
{
|
||||||
struct dm_test_parent_data *parent_data;
|
struct dm_test_parent_data *parent_data;
|
||||||
struct dm_test_state *dms = uts->priv;
|
|
||||||
struct udevice *bus, *dev;
|
struct udevice *bus, *dev;
|
||||||
struct uclass *uc;
|
struct uclass *uc;
|
||||||
|
|
||||||
test_state = dms;
|
testbus_removed = NULL;
|
||||||
ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
|
ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
|
||||||
ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
|
ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
|
||||||
|
|
||||||
@ -362,9 +360,9 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
|
|||||||
ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
|
ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
|
||||||
ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
|
ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
|
||||||
ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
|
ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
|
||||||
ut_asserteq_ptr(dms->removed, dev);
|
ut_asserteq_ptr(testbus_removed, dev);
|
||||||
}
|
}
|
||||||
test_state = NULL;
|
testbus_removed = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user