dm: test: bus: Use a local variable to simplify code
Adjust this test to avoid repeating the same code too often. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
This commit is contained in:
parent
887bd4164d
commit
e23eb614a4
|
|
@ -273,20 +273,22 @@ DM_TEST(dm_test_bus_parent_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||||
/* As above but the size is controlled by the uclass */
|
/* As above but the size is controlled by the uclass */
|
||||||
static int dm_test_bus_parent_data_uclass(struct dm_test_state *dms)
|
static int dm_test_bus_parent_data_uclass(struct dm_test_state *dms)
|
||||||
{
|
{
|
||||||
|
struct driver *drv;
|
||||||
struct udevice *bus;
|
struct udevice *bus;
|
||||||
int size;
|
int size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Set the driver size to 0 so that the uclass size is used */
|
/* Set the driver size to 0 so that the uclass size is used */
|
||||||
ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
|
ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
|
||||||
size = bus->driver->per_child_auto_alloc_size;
|
drv = (struct driver *)bus->driver;
|
||||||
|
size = drv->per_child_auto_alloc_size;
|
||||||
bus->uclass->uc_drv->per_child_auto_alloc_size = size;
|
bus->uclass->uc_drv->per_child_auto_alloc_size = size;
|
||||||
bus->driver->per_child_auto_alloc_size = 0;
|
drv->per_child_auto_alloc_size = 0;
|
||||||
ret = test_bus_parent_data(dms);
|
ret = test_bus_parent_data(dms);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
bus->uclass->uc_drv->per_child_auto_alloc_size = 0;
|
bus->uclass->uc_drv->per_child_auto_alloc_size = 0;
|
||||||
bus->driver->per_child_auto_alloc_size = size;
|
drv->per_child_auto_alloc_size = size;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -414,19 +416,21 @@ DM_TEST(dm_test_bus_parent_platdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||||
static int dm_test_bus_parent_platdata_uclass(struct dm_test_state *dms)
|
static int dm_test_bus_parent_platdata_uclass(struct dm_test_state *dms)
|
||||||
{
|
{
|
||||||
struct udevice *bus;
|
struct udevice *bus;
|
||||||
|
struct driver *drv;
|
||||||
int size;
|
int size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Set the driver size to 0 so that the uclass size is used */
|
/* Set the driver size to 0 so that the uclass size is used */
|
||||||
ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
|
ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
|
||||||
size = bus->driver->per_child_platdata_auto_alloc_size;
|
drv = (struct driver *)bus->driver;
|
||||||
|
size = drv->per_child_platdata_auto_alloc_size;
|
||||||
bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size;
|
bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size;
|
||||||
bus->driver->per_child_platdata_auto_alloc_size = 0;
|
drv->per_child_platdata_auto_alloc_size = 0;
|
||||||
ret = test_bus_parent_platdata(dms);
|
ret = test_bus_parent_platdata(dms);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = 0;
|
bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = 0;
|
||||||
bus->driver->per_child_platdata_auto_alloc_size = size;
|
drv->per_child_platdata_auto_alloc_size = size;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue