All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 18/26] dm: core: Access device flags through functions
Date: Sat, 19 Dec 2020 10:40:10 -0700	[thread overview]
Message-ID: <20201219174018.1114146-17-sjg@chromium.org> (raw)
In-Reply-To: <20201219174018.1114146-1-sjg@chromium.org>

At present flags are stored as part of the device. In preparation for
storing them separately, change the access to go through inline functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/remoteproc.c                     |  2 +-
 drivers/clk/clk.c                    |  2 +-
 drivers/core/device-remove.c         | 18 ++++++++--------
 drivers/core/device.c                | 32 ++++++++++++++--------------
 drivers/core/devres.c                |  4 ++--
 drivers/core/dump.c                  |  4 ++--
 drivers/mtd/nand/raw/octeontx_nand.c |  2 +-
 drivers/remoteproc/rproc-uclass.c    |  2 +-
 drivers/serial/serial-uclass.c       |  2 +-
 include/dm/device.h                  | 15 +++++++++++++
 include/virtio.h                     |  2 +-
 test/dm/bus.c                        | 10 ++++-----
 test/dm/core.c                       | 14 ++++++------
 test/dm/cpu.c                        |  2 +-
 test/dm/test-fdt.c                   | 20 ++++++++---------
 test/dm/virtio.c                     |  2 +-
 16 files changed, 74 insertions(+), 59 deletions(-)

diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c
index 5f9ba925609..b3ddcebe314 100644
--- a/cmd/remoteproc.c
+++ b/cmd/remoteproc.c
@@ -35,7 +35,7 @@ static int print_remoteproc_list(void)
 		uc_pdata = dev_get_uclass_plat(dev);
 
 		/* Do not print if rproc is not probed */
-		if (!(dev->flags & DM_FLAG_ACTIVATED))
+		if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
 			continue;
 
 		switch (uc_pdata->mem_type) {
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index eb75132f27e..1efb7fe9f3e 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -67,7 +67,7 @@ const char *clk_hw_get_name(const struct clk *hw)
 
 bool clk_dev_binded(struct clk *clk)
 {
-	if (clk->dev && (clk->dev->flags & DM_FLAG_BOUND))
+	if (clk->dev && (dev_get_flags(clk->dev) & DM_FLAG_BOUND))
 		return true;
 
 	return false;
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index e15ab051be7..44eaa67d566 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -69,10 +69,10 @@ int device_unbind(struct udevice *dev)
 	if (!dev)
 		return log_msg_ret("dev", -EINVAL);
 
-	if (dev->flags & DM_FLAG_ACTIVATED)
+	if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 		return log_msg_ret("active", -EINVAL);
 
-	if (!(dev->flags & DM_FLAG_BOUND))
+	if (!(dev_get_flags(dev) & DM_FLAG_BOUND))
 		return log_msg_ret("not-bound", -EINVAL);
 
 	drv = dev->driver;
@@ -88,15 +88,15 @@ int device_unbind(struct udevice *dev)
 	if (ret)
 		return log_msg_ret("child unbind", ret);
 
-	if (dev->flags & DM_FLAG_ALLOC_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
 		free(dev_get_plat(dev));
 		dev_set_plat(dev, NULL);
 	}
-	if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
 		free(dev_get_uclass_plat(dev));
 		dev_set_uclass_plat(dev, NULL);
 	}
-	if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) {
 		free(dev_get_parent_plat(dev));
 		dev_set_parent_plat(dev, NULL);
 	}
@@ -109,7 +109,7 @@ int device_unbind(struct udevice *dev)
 
 	devres_release_all(dev);
 
-	if (dev->flags & DM_FLAG_NAME_ALLOCED)
+	if (dev_get_flags(dev) & DM_FLAG_NAME_ALLOCED)
 		free((char *)dev->name);
 	free(dev);
 
@@ -144,7 +144,7 @@ void device_free(struct udevice *dev)
 			dev_set_parent_priv(dev, NULL);
 		}
 	}
-	dev->flags &= ~DM_FLAG_PLATDATA_VALID;
+	dev_bic_flags(dev, DM_FLAG_PLATDATA_VALID);
 
 	devres_release_probe(dev);
 }
@@ -166,7 +166,7 @@ int device_remove(struct udevice *dev, uint flags)
 	if (!dev)
 		return -EINVAL;
 
-	if (!(dev->flags & DM_FLAG_ACTIVATED))
+	if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
 		return 0;
 
 	drv = dev->driver;
@@ -207,7 +207,7 @@ int device_remove(struct udevice *dev, uint flags)
 	if (flags_remove(flags, drv->flags)) {
 		device_free(dev);
 
-		dev->flags &= ~DM_FLAG_ACTIVATED;
+		dev_bic_flags(dev, DM_FLAG_ACTIVATED);
 	}
 
 	return ret;
diff --git a/drivers/core/device.c b/drivers/core/device.c
index f4ae7786ee9..ba50d46effe 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -96,13 +96,13 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 
 		if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
 			if (of_plat_size) {
-				dev->flags |= DM_FLAG_OF_PLATDATA;
+				dev_or_flags(dev, DM_FLAG_OF_PLATDATA);
 				if (of_plat_size < drv->plat_auto)
 					alloc = true;
 			}
 		}
 		if (alloc) {
-			dev->flags |= DM_FLAG_ALLOC_PDATA;
+			dev_or_flags(dev, DM_FLAG_ALLOC_PDATA);
 			ptr = calloc(1, drv->plat_auto);
 			if (!ptr) {
 				ret = -ENOMEM;
@@ -116,7 +116,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 
 	size = uc->uc_drv->per_device_plat_auto;
 	if (size) {
-		dev->flags |= DM_FLAG_ALLOC_UCLASS_PDATA;
+		dev_or_flags(dev, DM_FLAG_ALLOC_UCLASS_PDATA);
 		ptr = calloc(1, size);
 		if (!ptr) {
 			ret = -ENOMEM;
@@ -131,7 +131,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 			size = parent->uclass->uc_drv->per_child_plat_auto;
 		}
 		if (size) {
-			dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA;
+			dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA);
 			ptr = calloc(1, size);
 			if (!ptr) {
 				ret = -ENOMEM;
@@ -169,7 +169,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 	if (devp)
 		*devp = dev;
 
-	dev->flags |= DM_FLAG_BOUND;
+	dev_or_flags(dev, DM_FLAG_BOUND);
 
 	return 0;
 
@@ -193,18 +193,18 @@ fail_bind:
 fail_uclass_bind:
 	if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
 		list_del(&dev->sibling_node);
-		if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
+		if (dev_get_flags(dev) & DM_FLAG_ALLOC_PARENT_PDATA) {
 			free(dev_get_parent_plat(dev));
 			dev_set_parent_plat(dev, NULL);
 		}
 	}
 fail_alloc3:
-	if (dev->flags & DM_FLAG_ALLOC_UCLASS_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_UCLASS_PDATA) {
 		free(dev_get_uclass_plat(dev));
 		dev_set_uclass_plat(dev, NULL);
 	}
 fail_alloc2:
-	if (dev->flags & DM_FLAG_ALLOC_PDATA) {
+	if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
 		free(dev_get_plat(dev));
 		dev_set_plat(dev, NULL);
 	}
@@ -379,7 +379,7 @@ int device_of_to_plat(struct udevice *dev)
 	if (!dev)
 		return -EINVAL;
 
-	if (dev->flags & DM_FLAG_PLATDATA_VALID)
+	if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
 		return 0;
 
 	/* Ensure all parents have ofdata */
@@ -394,7 +394,7 @@ int device_of_to_plat(struct udevice *dev)
 		 * (e.g. PCI bridge devices). Test the flags again
 		 * so that we don't mess up the device.
 		 */
-		if (dev->flags & DM_FLAG_PLATDATA_VALID)
+		if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
 			return 0;
 	}
 
@@ -412,7 +412,7 @@ int device_of_to_plat(struct udevice *dev)
 			goto fail;
 	}
 
-	dev->flags |= DM_FLAG_PLATDATA_VALID;
+	dev_or_flags(dev, DM_FLAG_PLATDATA_VALID);
 
 	return 0;
 fail:
@@ -429,7 +429,7 @@ int device_probe(struct udevice *dev)
 	if (!dev)
 		return -EINVAL;
 
-	if (dev->flags & DM_FLAG_ACTIVATED)
+	if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 		return 0;
 
 	drv = dev->driver;
@@ -451,11 +451,11 @@ int device_probe(struct udevice *dev)
 		 * (e.g. PCI bridge devices). Test the flags again
 		 * so that we don't mess up the device.
 		 */
-		if (dev->flags & DM_FLAG_ACTIVATED)
+		if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 			return 0;
 	}
 
-	dev->flags |= DM_FLAG_ACTIVATED;
+	dev_or_flags(dev, DM_FLAG_ACTIVATED);
 
 	/*
 	 * Process pinctrl for everything except the root device, and
@@ -515,7 +515,7 @@ fail_uclass:
 			__func__, dev->name);
 	}
 fail:
-	dev->flags &= ~DM_FLAG_ACTIVATED;
+	dev_bic_flags(dev, DM_FLAG_ACTIVATED);
 
 	device_free(dev);
 
@@ -965,7 +965,7 @@ bool device_is_last_sibling(const struct udevice *dev)
 
 void device_set_name_alloced(struct udevice *dev)
 {
-	dev->flags |= DM_FLAG_NAME_ALLOCED;
+	dev_or_flags(dev, DM_FLAG_NAME_ALLOCED);
 }
 
 int device_set_name(struct udevice *dev, const char *name)
diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 522b07d613f..313ddc7089c 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -107,9 +107,9 @@ void devres_add(struct udevice *dev, void *res)
 
 	devres_log(dev, dr, "ADD");
 	assert_noisy(list_empty(&dr->entry));
-	if (dev->flags & DM_FLAG_PLATDATA_VALID)
+	if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
 		dr->phase = DEVRES_PHASE_PROBE;
-	else if (dev->flags & DM_FLAG_BOUND)
+	else if (dev_get_flags(dev) & DM_FLAG_BOUND)
 		dr->phase = DEVRES_PHASE_OFDATA;
 	else
 		dr->phase = DEVRES_PHASE_BIND;
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index 1d4628abc74..f8afea30a93 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -14,7 +14,7 @@ static void show_devices(struct udevice *dev, int depth, int last_flag)
 {
 	int i, is_last;
 	struct udevice *child;
-	u32 flags = dev->flags;
+	u32 flags = dev_get_flags(dev);
 
 	/* print the first 20 characters to not break the tree-format. */
 	printf(IS_ENABLED(CONFIG_SPL_BUILD) ? " %s  %d  [ %c ]   %s  " :
@@ -67,7 +67,7 @@ void dm_dump_all(void)
 static void dm_display_line(struct udevice *dev, int index)
 {
 	printf("%-3i %c %s @ %08lx", index,
-	       dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
+	       dev_get_flags(dev) & DM_FLAG_ACTIVATED ? '*' : ' ',
 	       dev->name, (ulong)map_to_sysmem(dev));
 	if (dev->seq_ != -1)
 		printf(", seq %d", dev_seq(dev));
diff --git a/drivers/mtd/nand/raw/octeontx_nand.c b/drivers/mtd/nand/raw/octeontx_nand.c
index b1ed4d910a7..96a5fe6592a 100644
--- a/drivers/mtd/nand/raw/octeontx_nand.c
+++ b/drivers/mtd/nand/raw/octeontx_nand.c
@@ -2187,7 +2187,7 @@ int octeontx_pci_nand_deferred_probe(void)
 	debug("%s: Performing deferred probing\n", __func__);
 	list_for_each_entry(pdev, &octeontx_pci_nand_deferred_devices, list) {
 		debug("%s: Probing %s\n", __func__, pdev->dev->name);
-		pdev->dev->flags &= ~DM_FLAG_ACTIVATED;
+		dev_get_flags(pdev->dev) &= ~DM_FLAG_ACTIVATED;
 		rc = device_probe(pdev->dev);
 		if (rc && rc != -ENODEV) {
 			printf("%s: Error %d with deferred probe of %s\n",
diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c
index 773b8119f4f..c2d6a4e0c17 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -247,7 +247,7 @@ static int _rproc_dev_is_probed(struct udevice *dev,
 			    struct dm_rproc_uclass_pdata *uc_pdata,
 			    const void *data)
 {
-	if (dev->flags & DM_FLAG_ACTIVATED)
+	if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 		return 0;
 
 	return -EAGAIN;
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index b6457242dea..58a6541d8cc 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -123,7 +123,7 @@ static void serial_find_console_or_panic(void)
 #ifdef CONFIG_SERIAL_SEARCH_ALL
 		if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
-			if (dev->flags & DM_FLAG_ACTIVATED) {
+			if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) {
 				gd->cur_serial_dev = dev;
 				return;
 			}
diff --git a/include/dm/device.h b/include/dm/device.h
index a063bbaa176..4ec423e9618 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -179,6 +179,21 @@ struct udevice {
 /* Returns non-zero if the device is active (probed and not removed) */
 #define device_active(dev)	((dev)->flags & DM_FLAG_ACTIVATED)
 
+static inline u32 dev_get_flags(const struct udevice *dev)
+{
+	return dev->flags;
+}
+
+static inline void dev_or_flags(struct udevice *dev, u32 or)
+{
+	dev->flags |= or;
+}
+
+static inline void dev_bic_flags(struct udevice *dev, u32 bic)
+{
+	dev->flags &= ~bic;
+}
+
 static inline int dev_of_offset(const struct udevice *dev)
 {
 	return ofnode_to_offset(dev->node);
diff --git a/include/virtio.h b/include/virtio.h
index 10a9c073ba1..a42bdad6b87 100644
--- a/include/virtio.h
+++ b/include/virtio.h
@@ -492,7 +492,7 @@ static inline void __virtio_clear_bit(struct udevice *udev, unsigned int fbit)
  */
 static inline bool virtio_has_feature(struct udevice *vdev, unsigned int fbit)
 {
-	if (!(vdev->flags & DM_FLAG_BOUND))
+	if (!(dev_get_flags(vdev) & DM_FLAG_BOUND))
 		WARN_ON(true);
 
 	return __virtio_test_bit(vdev->parent, fbit);
diff --git a/test/dm/bus.c b/test/dm/bus.c
index 785ccfc25d1..e768eab6957 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -55,16 +55,16 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)
 	ut_assertok(device_get_child(bus, 0, &dev));
 	ut_asserteq(-ENODEV, device_get_child(bus, 4, &dev));
 	ut_assertok(device_get_child_by_seq(bus, 5, &dev));
-	ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 	ut_asserteq_str("c-test at 5", dev->name);
 
 	/* Device with sequence number 0 should be accessible */
 	ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, &dev));
 	ut_assertok(device_find_child_by_seq(bus, 0, &dev));
-	ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 	ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
 	ut_assertok(device_get_child_by_seq(bus, 0, &dev));
-	ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 	ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
 
 	/* There is no device with sequence number 2 */
@@ -96,10 +96,10 @@ static int dm_test_bus_children_of_offset(struct unit_test_state *uts)
 	ut_assert(node > 0);
 	ut_assertok(device_find_child_by_of_offset(bus, node, &dev));
 	ut_assertnonnull(dev);
-	ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 	ut_assertok(device_get_child_by_of_offset(bus, node, &dev));
 	ut_assertnonnull(dev);
-	ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
 	return 0;
 }
diff --git a/test/dm/core.c b/test/dm/core.c
index b274b043882..565896ed504 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -131,7 +131,7 @@ static int dm_test_autobind(struct unit_test_state *uts)
 
 	/* No devices should be probed */
 	list_for_each_entry(dev, &gd->dm_root->child_head, sibling_node)
-		ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+		ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 
 	/* Our test driver should have been bound 3 times */
 	ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == 3);
@@ -212,7 +212,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
 	ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]);
 
 	/* The root device should not be activated until needed */
-	ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
+	ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED);
 
 	/*
 	 * We should be able to find the three test devices, and they should
@@ -222,17 +222,17 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
 	for (i = 0; i < 3; i++) {
 		ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
 		ut_assert(dev);
-		ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
+		ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED),
 			   "Driver %d/%s already activated", i, dev->name);
 
 		/* This should activate it */
 		ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev));
 		ut_assert(dev);
-		ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
 		/* Activating a device should activate the root device */
 		if (!i)
-			ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
+			ut_assert(dev_get_flags(dms->root) & DM_FLAG_ACTIVATED);
 	}
 
 	/*
@@ -460,10 +460,10 @@ static int dm_test_remove(struct unit_test_state *uts)
 	for (i = 0; i < 3; i++) {
 		ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
 		ut_assert(dev);
-		ut_assertf(dev->flags & DM_FLAG_ACTIVATED,
+		ut_assertf(dev_get_flags(dev) & DM_FLAG_ACTIVATED,
 			   "Driver %d/%s not activated", i, dev->name);
 		ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
-		ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
+		ut_assertf(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED),
 			   "Driver %d/%s should have deactivated", i,
 			   dev->name);
 		ut_assert(!dev_get_priv(dev));
diff --git a/test/dm/cpu.c b/test/dm/cpu.c
index 28869c1d6ff..ed12cafee2b 100644
--- a/test/dm/cpu.c
+++ b/test/dm/cpu.c
@@ -25,7 +25,7 @@ static int dm_test_cpu(struct unit_test_state *uts)
 	for (uclass_find_first_device(UCLASS_CPU, &dev);
 	     dev;
 	     uclass_find_next_device(&dev))
-		ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 
 	ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev));
 	ut_asserteq_ptr(cpu_get_current_dev(), dev);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 633256821c2..711bf20a9c5 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -1031,8 +1031,8 @@ static int dm_test_child_ofdata(struct unit_test_state *uts)
 	ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
 	count = 0;
 	device_foreach_child_of_to_plat(dev, bus) {
-		ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-		ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
+		ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+		ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
 		count++;
 	}
 	ut_asserteq(3, count);
@@ -1050,8 +1050,8 @@ static int dm_test_first_child_probe(struct unit_test_state *uts)
 	ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
 	count = 0;
 	device_foreach_child_probe(dev, bus) {
-		ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-		ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+		ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
 		count++;
 	}
 	ut_asserteq(3, count);
@@ -1067,19 +1067,19 @@ static int dm_test_ofdata_order(struct unit_test_state *uts)
 
 	ut_assertok(uclass_find_first_device(UCLASS_I2C, &bus));
 	ut_assertnonnull(bus);
-	ut_assert(!(bus->flags & DM_FLAG_PLATDATA_VALID));
+	ut_assert(!(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID));
 
 	ut_assertok(device_find_first_child(bus, &dev));
 	ut_assertnonnull(dev);
-	ut_assert(!(dev->flags & DM_FLAG_PLATDATA_VALID));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID));
 
 	/* read the child's ofdata which should cause the parent's to be read */
 	ut_assertok(device_of_to_plat(dev));
-	ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
-	ut_assert(bus->flags & DM_FLAG_PLATDATA_VALID);
+	ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
+	ut_assert(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID);
 
-	ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
-	ut_assert(!(bus->flags & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
+	ut_assert(!(dev_get_flags(bus) & DM_FLAG_ACTIVATED));
 
 	return 0;
 }
diff --git a/test/dm/virtio.c b/test/dm/virtio.c
index 2e876c36e43..ad355981cf4 100644
--- a/test/dm/virtio.c
+++ b/test/dm/virtio.c
@@ -122,7 +122,7 @@ static int dm_test_virtio_remove(struct unit_test_state *uts)
 	ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK));
 
 	/* check the device can be successfully removed */
-	dev->flags |= DM_FLAG_ACTIVATED;
+	dev_or_flags(dev, DM_FLAG_ACTIVATED);
 	ut_assertok(device_remove(bus, DM_REMOVE_ACTIVE_ALL));
 
 	return 0;
-- 
2.29.2.684.gfbc64c5ab5-goog

  parent reply	other threads:[~2020-12-19 17:40 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-19 17:39 [PATCH 00/26] dm: Preparation for enhanced of-platdata (part C) Simon Glass
2020-12-19 17:39 ` Simon Glass
2020-12-19 17:39 ` [PATCH 01/26] sandbox: serial: Move priv into a header file Simon Glass
2020-12-21 11:38   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2020-12-19 17:39 ` [PATCH 02/26] sandbox: i2c: " Simon Glass
2020-12-19 17:39 ` [PATCH 03/26] sandbox: Add a compatible string for spltest Simon Glass
2020-12-19 17:39 ` [PATCH 04/26] sandbox: Update dts files to reduce SPL size Simon Glass
2020-12-19 17:39 ` [PATCH 05/26] x86: apl: Move priv/plat structs to headers Simon Glass
2020-12-19 17:39 ` [PATCH 06/26] x86: Move priv/plat structs for intel_common " Simon Glass
2020-12-19 17:39 ` [PATCH 07/26] x86: spl: Move priv/plat structs " Simon Glass
2020-12-19 17:40 ` [PATCH 08/26] spi: Tidy up get/set of device node Simon Glass
2020-12-19 17:40 ` [PATCH 09/26] spi: Tweak a few strange SPI NOR features for of-platdata Simon Glass
2020-12-19 17:40 ` [PATCH 10/26] x86: apl: Use struct spi_nor instead of struct spi_flash Simon Glass
2020-12-19 17:40 ` [PATCH 11/26] dm: core: Move priv/plat structs for simple_bus to headers Simon Glass
2020-12-19 17:40 ` [PATCH 12/26] x86: sysreset: Move priv/plat structs " Simon Glass
2020-12-21 11:38   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2020-12-19 17:40 ` [PATCH 13/26] x86: apl: Adjust how the UART gets its platform data Simon Glass
2020-12-19 17:40 ` [PATCH 14/26] x86: coral: Remove unwanted nodes from SPL/TPL Simon Glass
2020-12-19 17:40 ` [PATCH 15/26] x86: Drop rtc from SPL Simon Glass
2020-12-19 17:40 ` [PATCH 16/26] dm: core: Split out alloc code into a new function Simon Glass
2020-12-19 17:40 ` [PATCH 17/26] dm: core: Rename sqq to seq_ Simon Glass
2020-12-21 11:41   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2020-12-19 17:40 ` Simon Glass [this message]
2020-12-19 17:40 ` [PATCH 19/26] dm: core: Rename device flags to indicate it is private Simon Glass
2020-12-19 17:40 ` [PATCH 20/26] dm: core: Rename dev_has_of_node() to dev_has_ofnode() Simon Glass
2020-12-19 17:40 ` [PATCH 21/26] dm: core: Use dev_has_ofnode() instead of dev_of_valid() Simon Glass
2020-12-21 11:41   ` Andy Shevchenko
2020-12-28 16:26   ` Simon Glass
2021-01-04 11:01   ` Patrick DELAUNAY
2020-12-19 17:40 ` [PATCH 22/26] dm: core: Access device ofnode through functions Simon Glass
2020-12-19 17:40   ` Simon Glass
2021-01-04 13:02   ` Patrick DELAUNAY
2021-01-04 13:02     ` Patrick DELAUNAY
2021-01-07 12:36     ` Simon Glass
2021-01-07 12:36       ` Simon Glass
2020-12-19 17:40 ` [PATCH 23/26] dm: core: Rename device node to indicate it is private Simon Glass
2020-12-19 17:40 ` [PATCH 24/26] dm: core: Split out scanning code to dm_scan() Simon Glass
2020-12-19 17:40 ` [PATCH 25/26] dm: core: Allow the uclass list to move Simon Glass
2020-12-19 17:40 ` [PATCH 26/26] dm: core: Add logging when lists_bind_fdt() fails Simon Glass
2020-12-28 16:26 ` [PATCH 25/26] dm: core: Allow the uclass list to move Simon Glass
2020-12-28 16:26 ` [PATCH 26/26] dm: core: Add logging when lists_bind_fdt() fails Simon Glass
2020-12-28 16:26 ` [PATCH 24/26] dm: core: Split out scanning code to dm_scan() Simon Glass
2020-12-28 16:26 ` [PATCH 23/26] dm: core: Rename device node to indicate it is private Simon Glass
2020-12-28 16:26 ` [PATCH 22/26] dm: core: Access device ofnode through functions Simon Glass
2020-12-28 16:26   ` Simon Glass
2020-12-28 16:26 ` [PATCH 20/26] dm: core: Rename dev_has_of_node() to dev_has_ofnode() Simon Glass
2020-12-28 16:26 ` [PATCH 19/26] dm: core: Rename device flags to indicate it is private Simon Glass
2020-12-28 16:26 ` [PATCH 18/26] dm: core: Access device flags through functions Simon Glass
2020-12-28 16:26 ` [PATCH 16/26] dm: core: Split out alloc code into a new function Simon Glass
2020-12-28 16:26 ` [PATCH 15/26] x86: Drop rtc from SPL Simon Glass
2020-12-28 16:26 ` [PATCH 14/26] x86: coral: Remove unwanted nodes from SPL/TPL Simon Glass
2020-12-28 16:26 ` [PATCH 13/26] x86: apl: Adjust how the UART gets its platform data Simon Glass
2020-12-28 16:26 ` [PATCH 11/26] dm: core: Move priv/plat structs for simple_bus to headers Simon Glass
2020-12-28 16:26 ` [PATCH 09/26] spi: Tweak a few strange SPI NOR features for of-platdata Simon Glass
2020-12-28 16:26 ` [PATCH 10/26] x86: apl: Use struct spi_nor instead of struct spi_flash Simon Glass
2020-12-28 16:26 ` [PATCH 08/26] spi: Tidy up get/set of device node Simon Glass
2020-12-28 16:26 ` [PATCH 07/26] x86: spl: Move priv/plat structs to headers Simon Glass
2020-12-28 16:26 ` [PATCH 06/26] x86: Move priv/plat structs for intel_common " Simon Glass
2020-12-28 16:26 ` [PATCH 05/26] x86: apl: Move priv/plat structs " Simon Glass
2020-12-28 16:26 ` [PATCH 04/26] sandbox: Update dts files to reduce SPL size Simon Glass
2020-12-28 16:26 ` [PATCH 03/26] sandbox: Add a compatible string for spltest Simon Glass
2020-12-28 16:26 ` [PATCH 02/26] sandbox: i2c: Move priv into a header file Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201219174018.1114146-17-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.