diff options
author | Simon Glass <sjg@chromium.org> | 2019-12-29 21:19:28 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-01-07 16:02:39 -0700 |
commit | 42a0ce576f33ad413662e7178f05db2f36de9896 (patch) | |
tree | af97557d5426841d06a5942688ed3621dfc2e514 /test/dm/devres.c | |
parent | af68411dd1e9ef69ada074963333a5a5b8e278a4 (diff) | |
download | u-boot-42a0ce576f33ad413662e7178f05db2f36de9896.tar.gz |
dm: devres: Add a new OFDATA phase
Since the ofdata_to_platdata() method can allocate resources, add it as a
new devres phase.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/devres.c')
-rw-r--r-- | test/dm/devres.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/dm/devres.c b/test/dm/devres.c index c351844db9..e7331897de 100644 --- a/test/dm/devres.c +++ b/test/dm/devres.c @@ -140,6 +140,7 @@ static int dm_test_devres_kcalloc(struct unit_test_state *uts) } DM_TEST(dm_test_devres_kcalloc, DM_TESTF_SCAN_PDATA); +/* Test devres releases resources automatically as expected */ static int dm_test_devres_phase(struct unit_test_state *uts) { struct devres_stats stats; @@ -154,14 +155,21 @@ static int dm_test_devres_phase(struct unit_test_state *uts) ut_asserteq(1, stats.allocs); ut_asserteq(TEST_DEVRES_SIZE, stats.total_size); + /* Getting platdata should add one allocation */ + ut_assertok(device_ofdata_to_platdata(dev)); + devres_get_stats(dev, &stats); + ut_asserteq(2, stats.allocs); + ut_asserteq(TEST_DEVRES_SIZE + TEST_DEVRES_SIZE3, stats.total_size); + /* Probing the device should add one allocation */ ut_assertok(uclass_first_device(UCLASS_TEST_DEVRES, &dev)); ut_assert(dev != NULL); devres_get_stats(dev, &stats); - ut_asserteq(2, stats.allocs); - ut_asserteq(TEST_DEVRES_SIZE + TEST_DEVRES_SIZE2, stats.total_size); + ut_asserteq(3, stats.allocs); + ut_asserteq(TEST_DEVRES_SIZE + TEST_DEVRES_SIZE2 + TEST_DEVRES_SIZE3, + stats.total_size); - /* Removing the device should drop one allocation */ + /* Removing the device should drop both those allocations */ device_remove(dev, DM_REMOVE_NORMAL); devres_get_stats(dev, &stats); ut_asserteq(1, stats.allocs); |