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>
diff --git a/test/dm/core.c b/test/dm/core.c
index a7c0f40..cf66e27 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -255,7 +255,7 @@
 		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 @@
 	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 @@
 	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 @@
 	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 @@
 
 	/* 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 @@
 	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 @@
 		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 @@
 		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 @@
 	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 @@
 						&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 b9f49de..a67f5d3 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_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 @@
 
 	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 eb3c2cf..9e8c290 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -25,7 +25,7 @@
 
 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 @@
 		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 3ab4a23..f1b7aaa 100644
--- a/test/dm/test-uclass.c
+++ b/test/dm/test-uclass.c
@@ -82,7 +82,7 @@
 	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_init(struct uclass *uc)
 {
 	dm_testdrv_op_count[DM_TEST_OP_INIT]++;
-	ut_assert(uc->priv);
+	ut_assert(uclass_get_priv(uc));
 
 	return 0;
 }