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) {
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;
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;
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);
}
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);
dev_set_parent_priv(dev, NULL);
}
}
- dev->flags &= ~DM_FLAG_PLATDATA_VALID;
+ dev_bic_flags(dev, DM_FLAG_PLATDATA_VALID);
devres_release_probe(dev);
}
if (!dev)
return -EINVAL;
- if (!(dev->flags & DM_FLAG_ACTIVATED))
+ if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
return 0;
drv = dev->driver;
if (flags_remove(flags, drv->flags)) {
device_free(dev);
- dev->flags &= ~DM_FLAG_ACTIVATED;
+ dev_bic_flags(dev, DM_FLAG_ACTIVATED);
}
return ret;
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;
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;
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;
if (devp)
*devp = dev;
- dev->flags |= DM_FLAG_BOUND;
+ dev_or_flags(dev, DM_FLAG_BOUND);
return 0;
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);
}
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 */
* (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;
}
goto fail;
}
- dev->flags |= DM_FLAG_PLATDATA_VALID;
+ dev_or_flags(dev, DM_FLAG_PLATDATA_VALID);
return 0;
fail:
if (!dev)
return -EINVAL;
- if (dev->flags & DM_FLAG_ACTIVATED)
+ if (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
return 0;
drv = dev->driver;
* (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
__func__, dev->name);
}
fail:
- dev->flags &= ~DM_FLAG_ACTIVATED;
+ dev_bic_flags(dev, DM_FLAG_ACTIVATED);
device_free(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)
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;
{
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 " :
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));
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",
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;
#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;
}
/* 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);
*/
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);
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@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 */
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;
}
/* 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);
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
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);
}
/*
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));
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);
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);
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);
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;
}
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;