dm: core: Access device flags through functions

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>
This commit is contained in:
Simon Glass 2020-12-19 10:40:10 -07:00
parent 2462139fdd
commit 73466df3e2
16 changed files with 74 additions and 59 deletions

View File

@ -35,7 +35,7 @@ static int print_remoteproc_list(void)
uc_pdata = dev_get_uclass_plat(dev); uc_pdata = dev_get_uclass_plat(dev);
/* Do not print if rproc is not probed */ /* Do not print if rproc is not probed */
if (!(dev->flags & DM_FLAG_ACTIVATED)) if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
continue; continue;
switch (uc_pdata->mem_type) { switch (uc_pdata->mem_type) {

View File

@ -67,7 +67,7 @@ const char *clk_hw_get_name(const struct clk *hw)
bool clk_dev_binded(struct clk *clk) 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 true;
return false; return false;

View File

@ -69,10 +69,10 @@ int device_unbind(struct udevice *dev)
if (!dev) if (!dev)
return log_msg_ret("dev", -EINVAL); 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); 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); return log_msg_ret("not-bound", -EINVAL);
drv = dev->driver; drv = dev->driver;
@ -88,15 +88,15 @@ int device_unbind(struct udevice *dev)
if (ret) if (ret)
return log_msg_ret("child unbind", 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)); free(dev_get_plat(dev));
dev_set_plat(dev, NULL); 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)); free(dev_get_uclass_plat(dev));
dev_set_uclass_plat(dev, NULL); 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)); free(dev_get_parent_plat(dev));
dev_set_parent_plat(dev, NULL); dev_set_parent_plat(dev, NULL);
} }
@ -109,7 +109,7 @@ int device_unbind(struct udevice *dev)
devres_release_all(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((char *)dev->name);
free(dev); free(dev);
@ -144,7 +144,7 @@ void device_free(struct udevice *dev)
dev_set_parent_priv(dev, NULL); dev_set_parent_priv(dev, NULL);
} }
} }
dev->flags &= ~DM_FLAG_PLATDATA_VALID; dev_bic_flags(dev, DM_FLAG_PLATDATA_VALID);
devres_release_probe(dev); devres_release_probe(dev);
} }
@ -166,7 +166,7 @@ int device_remove(struct udevice *dev, uint flags)
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
if (!(dev->flags & DM_FLAG_ACTIVATED)) if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
return 0; return 0;
drv = dev->driver; drv = dev->driver;
@ -207,7 +207,7 @@ int device_remove(struct udevice *dev, uint flags)
if (flags_remove(flags, drv->flags)) { if (flags_remove(flags, drv->flags)) {
device_free(dev); device_free(dev);
dev->flags &= ~DM_FLAG_ACTIVATED; dev_bic_flags(dev, DM_FLAG_ACTIVATED);
} }
return ret; return ret;

View File

@ -96,13 +96,13 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
if (CONFIG_IS_ENABLED(OF_PLATDATA)) { if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
if (of_plat_size) { 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) if (of_plat_size < drv->plat_auto)
alloc = true; alloc = true;
} }
} }
if (alloc) { if (alloc) {
dev->flags |= DM_FLAG_ALLOC_PDATA; dev_or_flags(dev, DM_FLAG_ALLOC_PDATA);
ptr = calloc(1, drv->plat_auto); ptr = calloc(1, drv->plat_auto);
if (!ptr) { if (!ptr) {
ret = -ENOMEM; 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; size = uc->uc_drv->per_device_plat_auto;
if (size) { if (size) {
dev->flags |= DM_FLAG_ALLOC_UCLASS_PDATA; dev_or_flags(dev, DM_FLAG_ALLOC_UCLASS_PDATA);
ptr = calloc(1, size); ptr = calloc(1, size);
if (!ptr) { if (!ptr) {
ret = -ENOMEM; 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; size = parent->uclass->uc_drv->per_child_plat_auto;
} }
if (size) { if (size) {
dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA; dev_or_flags(dev, DM_FLAG_ALLOC_PARENT_PDATA);
ptr = calloc(1, size); ptr = calloc(1, size);
if (!ptr) { if (!ptr) {
ret = -ENOMEM; ret = -ENOMEM;
@ -169,7 +169,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
if (devp) if (devp)
*devp = dev; *devp = dev;
dev->flags |= DM_FLAG_BOUND; dev_or_flags(dev, DM_FLAG_BOUND);
return 0; return 0;
@ -193,18 +193,18 @@ fail_bind:
fail_uclass_bind: fail_uclass_bind:
if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) { if (CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)) {
list_del(&dev->sibling_node); 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)); free(dev_get_parent_plat(dev));
dev_set_parent_plat(dev, NULL); dev_set_parent_plat(dev, NULL);
} }
} }
fail_alloc3: 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)); free(dev_get_uclass_plat(dev));
dev_set_uclass_plat(dev, NULL); dev_set_uclass_plat(dev, NULL);
} }
fail_alloc2: fail_alloc2:
if (dev->flags & DM_FLAG_ALLOC_PDATA) { if (dev_get_flags(dev) & DM_FLAG_ALLOC_PDATA) {
free(dev_get_plat(dev)); free(dev_get_plat(dev));
dev_set_plat(dev, NULL); dev_set_plat(dev, NULL);
} }
@ -379,7 +379,7 @@ int device_of_to_plat(struct udevice *dev)
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
if (dev->flags & DM_FLAG_PLATDATA_VALID) if (dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID)
return 0; return 0;
/* Ensure all parents have ofdata */ /* 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 * (e.g. PCI bridge devices). Test the flags again
* so that we don't mess up the device. * 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; return 0;
} }
@ -412,7 +412,7 @@ int device_of_to_plat(struct udevice *dev)
goto fail; goto fail;
} }
dev->flags |= DM_FLAG_PLATDATA_VALID; dev_or_flags(dev, DM_FLAG_PLATDATA_VALID);
return 0; return 0;
fail: fail:
@ -429,7 +429,7 @@ int device_probe(struct udevice *dev)
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
if (dev->flags & DM_FLAG_ACTIVATED) if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
return 0; return 0;
drv = dev->driver; drv = dev->driver;
@ -451,11 +451,11 @@ int device_probe(struct udevice *dev)
* (e.g. PCI bridge devices). Test the flags again * (e.g. PCI bridge devices). Test the flags again
* so that we don't mess up the device. * 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; return 0;
} }
dev->flags |= DM_FLAG_ACTIVATED; dev_or_flags(dev, DM_FLAG_ACTIVATED);
/* /*
* Process pinctrl for everything except the root device, and * Process pinctrl for everything except the root device, and
@ -515,7 +515,7 @@ fail_uclass:
__func__, dev->name); __func__, dev->name);
} }
fail: fail:
dev->flags &= ~DM_FLAG_ACTIVATED; dev_bic_flags(dev, DM_FLAG_ACTIVATED);
device_free(dev); device_free(dev);
@ -965,7 +965,7 @@ bool device_is_last_sibling(const struct udevice *dev)
void device_set_name_alloced(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) int device_set_name(struct udevice *dev, const char *name)

View File

@ -107,9 +107,9 @@ void devres_add(struct udevice *dev, void *res)
devres_log(dev, dr, "ADD"); devres_log(dev, dr, "ADD");
assert_noisy(list_empty(&dr->entry)); 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; 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; dr->phase = DEVRES_PHASE_OFDATA;
else else
dr->phase = DEVRES_PHASE_BIND; dr->phase = DEVRES_PHASE_BIND;

View File

@ -14,7 +14,7 @@ static void show_devices(struct udevice *dev, int depth, int last_flag)
{ {
int i, is_last; int i, is_last;
struct udevice *child; struct udevice *child;
u32 flags = dev->flags; u32 flags = dev_get_flags(dev);
/* print the first 20 characters to not break the tree-format. */ /* print the first 20 characters to not break the tree-format. */
printf(IS_ENABLED(CONFIG_SPL_BUILD) ? " %s %d [ %c ] %s " : 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) static void dm_display_line(struct udevice *dev, int index)
{ {
printf("%-3i %c %s @ %08lx", 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)); dev->name, (ulong)map_to_sysmem(dev));
if (dev->seq_ != -1) if (dev->seq_ != -1)
printf(", seq %d", dev_seq(dev)); printf(", seq %d", dev_seq(dev));

View File

@ -2187,7 +2187,7 @@ int octeontx_pci_nand_deferred_probe(void)
debug("%s: Performing deferred probing\n", __func__); debug("%s: Performing deferred probing\n", __func__);
list_for_each_entry(pdev, &octeontx_pci_nand_deferred_devices, list) { list_for_each_entry(pdev, &octeontx_pci_nand_deferred_devices, list) {
debug("%s: Probing %s\n", __func__, pdev->dev->name); 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); rc = device_probe(pdev->dev);
if (rc && rc != -ENODEV) { if (rc && rc != -ENODEV) {
printf("%s: Error %d with deferred probe of %s\n", printf("%s: Error %d with deferred probe of %s\n",

View File

@ -247,7 +247,7 @@ static int _rproc_dev_is_probed(struct udevice *dev,
struct dm_rproc_uclass_pdata *uc_pdata, struct dm_rproc_uclass_pdata *uc_pdata,
const void *data) const void *data)
{ {
if (dev->flags & DM_FLAG_ACTIVATED) if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
return 0; return 0;
return -EAGAIN; return -EAGAIN;

View File

@ -123,7 +123,7 @@ static void serial_find_console_or_panic(void)
#ifdef CONFIG_SERIAL_SEARCH_ALL #ifdef CONFIG_SERIAL_SEARCH_ALL
if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) || if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
!uclass_get_device(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; gd->cur_serial_dev = dev;
return; return;
} }

View File

@ -179,6 +179,21 @@ struct udevice {
/* Returns non-zero if the device is active (probed and not removed) */ /* Returns non-zero if the device is active (probed and not removed) */
#define device_active(dev) ((dev)->flags & DM_FLAG_ACTIVATED) #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) static inline int dev_of_offset(const struct udevice *dev)
{ {
return ofnode_to_offset(dev->node); return ofnode_to_offset(dev->node);

View File

@ -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) 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); WARN_ON(true);
return __virtio_test_bit(vdev->parent, fbit); return __virtio_test_bit(vdev->parent, fbit);

View File

@ -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_assertok(device_get_child(bus, 0, &dev));
ut_asserteq(-ENODEV, device_get_child(bus, 4, &dev)); ut_asserteq(-ENODEV, device_get_child(bus, 4, &dev));
ut_assertok(device_get_child_by_seq(bus, 5, &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@5", dev->name); ut_asserteq_str("c-test@5", dev->name);
/* Device with sequence number 0 should be accessible */ /* Device with sequence number 0 should be accessible */
ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, &dev)); ut_asserteq(-ENODEV, device_find_child_by_seq(bus, -1, &dev));
ut_assertok(device_find_child_by_seq(bus, 0, &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_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
ut_assertok(device_get_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)); ut_asserteq(0, device_find_child_by_seq(bus, 0, &dev));
/* There is no device with sequence number 2 */ /* 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_assert(node > 0);
ut_assertok(device_find_child_by_of_offset(bus, node, &dev)); ut_assertok(device_find_child_by_of_offset(bus, node, &dev));
ut_assertnonnull(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_assertok(device_get_child_by_of_offset(bus, node, &dev));
ut_assertnonnull(dev); ut_assertnonnull(dev);
ut_assert(dev->flags & DM_FLAG_ACTIVATED); ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
return 0; return 0;
} }

View File

@ -131,7 +131,7 @@ static int dm_test_autobind(struct unit_test_state *uts)
/* No devices should be probed */ /* No devices should be probed */
list_for_each_entry(dev, &gd->dm_root->child_head, sibling_node) 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 */ /* Our test driver should have been bound 3 times */
ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == 3); 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]); ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]);
/* The root device should not be activated until needed */ /* 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 * 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++) { for (i = 0; i < 3; i++) {
ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev)); ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
ut_assert(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); "Driver %d/%s already activated", i, dev->name);
/* This should activate it */ /* This should activate it */
ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev)); ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev));
ut_assert(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 */ /* Activating a device should activate the root device */
if (!i) 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++) { for (i = 0; i < 3; i++) {
ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev)); ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
ut_assert(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); "Driver %d/%s not activated", i, dev->name);
ut_assertok(device_remove(dev, DM_REMOVE_NORMAL)); 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, "Driver %d/%s should have deactivated", i,
dev->name); dev->name);
ut_assert(!dev_get_priv(dev)); ut_assert(!dev_get_priv(dev));

View File

@ -25,7 +25,7 @@ static int dm_test_cpu(struct unit_test_state *uts)
for (uclass_find_first_device(UCLASS_CPU, &dev); for (uclass_find_first_device(UCLASS_CPU, &dev);
dev; dev;
uclass_find_next_device(&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_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev));
ut_asserteq_ptr(cpu_get_current_dev(), dev); ut_asserteq_ptr(cpu_get_current_dev(), dev);

View File

@ -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)); ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
count = 0; count = 0;
device_foreach_child_of_to_plat(dev, bus) { device_foreach_child_of_to_plat(dev, bus) {
ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID); ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
count++; count++;
} }
ut_asserteq(3, 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)); ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
count = 0; count = 0;
device_foreach_child_probe(dev, bus) { device_foreach_child_probe(dev, bus) {
ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID); ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
ut_assert(dev->flags & DM_FLAG_ACTIVATED); ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
count++; count++;
} }
ut_asserteq(3, 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_assertok(uclass_find_first_device(UCLASS_I2C, &bus));
ut_assertnonnull(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_assertok(device_find_first_child(bus, &dev));
ut_assertnonnull(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 */ /* read the child's ofdata which should cause the parent's to be read */
ut_assertok(device_of_to_plat(dev)); ut_assertok(device_of_to_plat(dev));
ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID); ut_assert(dev_get_flags(dev) & DM_FLAG_PLATDATA_VALID);
ut_assert(bus->flags & DM_FLAG_PLATDATA_VALID); ut_assert(dev_get_flags(bus) & DM_FLAG_PLATDATA_VALID);
ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED));
ut_assert(!(bus->flags & DM_FLAG_ACTIVATED)); ut_assert(!(dev_get_flags(bus) & DM_FLAG_ACTIVATED));
return 0; return 0;
} }

View File

@ -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)); ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK));
/* check the device can be successfully removed */ /* 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)); ut_assertok(device_remove(bus, DM_REMOVE_ACTIVE_ALL));
return 0; return 0;