summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-12-22 19:30:28 -0700
committerSimon Glass <sjg@chromium.org>2021-01-05 12:24:40 -0700
commit0fd3d91152df5bb6c5f7b9ee68f01a9a1c9a875d (patch)
tree1dbc5b936b98393e343cc99a40382b2734ac778e /test
parent12559f5bab3e43b603dccfa6c354ffd7da03249c (diff)
downloadu-boot-0fd3d91152df5bb6c5f7b9ee68f01a9a1c9a875d.tar.gz
u-boot-0fd3d91152df5bb6c5f7b9ee68f01a9a1c9a875d.tar.bz2
u-boot-0fd3d91152df5bb6c5f7b9ee68f01a9a1c9a875d.zip
dm: Use access methods for dev/uclass private data
Most drivers use these access methods but a few do not. Update them. In some cases the access is not permitted, so mark those with a FIXME tag for the maintainer to check. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pratyush Yadav <p.yadav@ti.com>
Diffstat (limited to 'test')
-rw-r--r--test/dm/core.c24
-rw-r--r--test/dm/test-driver.c7
-rw-r--r--test/dm/test-fdt.c4
-rw-r--r--test/dm/test-uclass.c4
4 files changed, 20 insertions, 19 deletions
diff --git a/test/dm/core.c b/test/dm/core.c
index a7c0f40b77..cf66e27db4 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -255,7 +255,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
ut_assert(priv);
ut_asserteq(expected_base_add, priv->base_add);
- pdata = dev->plat;
+ pdata = dev_get_plat(dev);
expected_base_add += pdata->ping_add;
}
@@ -273,7 +273,7 @@ static int dm_test_plat(struct unit_test_state *uts)
for (i = 0; i < 3; i++) {
ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
ut_assert(dev);
- pdata = dev->plat;
+ pdata = dev_get_plat(dev);
ut_assert(pdata->ping_add == test_pdata[i].ping_add);
}
@@ -297,7 +297,7 @@ static int dm_test_lifecycle(struct unit_test_state *uts)
ut_assert(dev);
ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND]
== op_count[DM_TEST_OP_BIND] + 1);
- ut_assert(!dev->priv);
+ ut_assert(!dev_get_priv(dev));
/* Probe the device - it should fail allocating private data */
dms->force_fail_alloc = 1;
@@ -305,14 +305,14 @@ static int dm_test_lifecycle(struct unit_test_state *uts)
ut_assert(ret == -ENOMEM);
ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE]
== op_count[DM_TEST_OP_PROBE] + 1);
- ut_assert(!dev->priv);
+ ut_assert(!dev_get_priv(dev));
/* Try again without the alloc failure */
dms->force_fail_alloc = 0;
ut_assertok(device_probe(dev));
ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE]
== op_count[DM_TEST_OP_PROBE] + 2);
- ut_assert(dev->priv);
+ ut_assert(dev_get_priv(dev));
/* This should be device 3 in the uclass */
ut_assertok(uclass_find_device(UCLASS_TEST, 3, &test_dev));
@@ -402,8 +402,8 @@ int dm_check_operations(struct unit_test_state *uts, struct udevice *dev,
/* Getting the child device should allocate plat / priv */
ut_assertok(testfdt_ping(dev, 10, &pingret));
- ut_assert(dev->priv);
- ut_assert(dev->plat);
+ ut_assert(dev_get_priv(dev));
+ ut_assert(dev_get_plat(dev));
expected = 10 + base;
ut_asserteq(expected, pingret);
@@ -414,7 +414,7 @@ int dm_check_operations(struct unit_test_state *uts, struct udevice *dev,
ut_asserteq(expected, pingret);
/* Now check the ping_total */
- priv = dev->priv;
+ priv = dev_get_priv(dev);
ut_asserteq(DM_TEST_START_TOTAL + 10 + 20 + base * 2,
priv->ping_total);
@@ -444,7 +444,7 @@ static int dm_test_operations(struct unit_test_state *uts)
base = test_pdata[i].ping_add;
debug("dev=%d, base=%d\n", i, base);
- ut_assert(!dm_check_operations(uts, dev, base, dev->priv));
+ ut_assert(!dm_check_operations(uts, dev, base, dev_get_priv(dev)));
}
return 0;
@@ -466,7 +466,7 @@ static int dm_test_remove(struct unit_test_state *uts)
ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
"Driver %d/%s should have deactivated", i,
dev->name);
- ut_assert(!dev->priv);
+ ut_assert(!dev_get_priv(dev));
}
return 0;
@@ -512,7 +512,7 @@ static int dm_test_uclass(struct unit_test_state *uts)
ut_assertok(uclass_get(UCLASS_TEST, &uc));
ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_DESTROY]);
- ut_assert(uc->priv);
+ ut_assert(uclass_get_priv(uc));
ut_assertok(uclass_destroy(uc));
ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
@@ -547,7 +547,7 @@ static int create_children(struct unit_test_state *uts, struct udevice *parent,
&driver_info_manual, &dev));
pdata = calloc(1, sizeof(*pdata));
pdata->ping_add = key + i;
- dev->plat = pdata;
+ dev_set_plat(dev, pdata);
if (child)
child[i] = dev;
}
diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
index b9f49de10a..a67f5d3f98 100644
--- a/test/dm/test-driver.c
+++ b/test/dm/test-driver.c
@@ -12,6 +12,7 @@
#include <log.h>
#include <malloc.h>
#include <asm/io.h>
+#include <dm/device-internal.h>
#include <dm/test.h>
#include <test/test.h>
#include <test/ut.h>
@@ -67,7 +68,7 @@ static int test_remove(struct udevice *dev)
static int test_unbind(struct udevice *dev)
{
/* Private data should not be allocated */
- ut_assert(!dev->priv);
+ ut_assert(!dev_get_priv(dev));
dm_testdrv_op_count[DM_TEST_OP_UNBIND]++;
return 0;
@@ -119,8 +120,8 @@ static int test_manual_probe(struct udevice *dev)
dm_testdrv_op_count[DM_TEST_OP_PROBE]++;
if (!dms->force_fail_alloc)
- dev->priv = calloc(1, sizeof(struct dm_test_priv));
- if (!dev->priv)
+ dev_set_priv(dev, calloc(1, sizeof(struct dm_test_priv)));
+ if (!dev_get_priv(dev))
return -ENOMEM;
return 0;
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index eb3c2cf161..9e8c2906e8 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int testfdt_drv_ping(struct udevice *dev, int pingval, int *pingret)
{
- const struct dm_test_pdata *pdata = dev->plat;
+ const struct dm_test_pdata *pdata = dev_get_plat(dev);
struct dm_test_priv *priv = dev_get_priv(dev);
*pingret = pingval + pdata->ping_add;
@@ -288,7 +288,7 @@ static int dm_test_fdt(struct unit_test_state *uts)
ret = uclass_find_device(UCLASS_TEST_FDT, i, &dev);
ut_assert(!ret);
ut_assert(!dev_get_priv(dev));
- ut_assert(dev->plat);
+ ut_assert(dev_get_plat(dev));
}
ut_assertok(dm_check_devices(uts, num_devices));
diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c
index 3ab4a23649..f1b7aaa727 100644
--- a/test/dm/test-uclass.c
+++ b/test/dm/test-uclass.c
@@ -82,7 +82,7 @@ static int test_post_probe(struct udevice *dev)
if (&prev->uclass_node != &uc->dev_head) {
struct dm_test_uclass_perdev_priv *prev_uc_priv
= dev_get_uclass_priv(prev);
- struct dm_test_pdata *pdata = prev->plat;
+ struct dm_test_pdata *pdata = dev_get_plat(prev);
ut_assert(pdata);
ut_assert(prev_uc_priv);
@@ -102,7 +102,7 @@ static int test_pre_remove(struct udevice *dev)
static int test_init(struct uclass *uc)
{
dm_testdrv_op_count[DM_TEST_OP_INIT]++;
- ut_assert(uc->priv);
+ ut_assert(uclass_get_priv(uc));
return 0;
}