summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/Makefile2
-rw-r--r--drivers/core/device.c5
-rw-r--r--drivers/core/root.c8
3 files changed, 11 insertions, 4 deletions
diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index 3742e757452..7099073a533 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -4,7 +4,7 @@
obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o tag.o
obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o
-obj-$(CONFIG_DEVRES) += devres.o
+obj-$(CONFIG_$(SPL_TPL_)DEVRES) += devres.o
obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o
obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o
obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 1b356f12dd8..3ab2583df38 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
INIT_LIST_HEAD(&dev->sibling_node);
INIT_LIST_HEAD(&dev->child_head);
INIT_LIST_HEAD(&dev->uclass_node);
-#ifdef CONFIG_DEVRES
+#if CONFIG_IS_ENABLED(DEVRES)
INIT_LIST_HEAD(&dev->devres_head);
#endif
dev_set_plat(dev, plat);
@@ -1186,7 +1186,8 @@ int dev_enable_by_path(const char *path)
static struct udevice_rt *dev_get_rt(const struct udevice *dev)
{
struct udevice *base = ll_entry_start(struct udevice, udevice);
- int idx = dev - base;
+ uint each_size = dm_udevice_size();
+ int idx = ((void *)dev - (void *)base) / each_size;
struct udevice_rt *urt = gd_dm_udevice_rt() + idx;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 86b3884fc67..e09c12f4d6e 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -136,12 +136,18 @@ static int dm_setup_inst(void)
if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) {
struct udevice_rt *urt;
+ void *start, *end;
+ int each_size;
void *base;
int n_ents;
uint size;
/* Allocate the udevice_rt table */
- n_ents = ll_entry_count(struct udevice, udevice);
+ each_size = dm_udevice_size();
+ start = ll_entry_start(struct udevice, udevice);
+ end = ll_entry_end(struct udevice, udevice);
+ size = end - start;
+ n_ents = size / each_size;
urt = calloc(n_ents, sizeof(struct udevice_rt));
if (!urt)
return log_msg_ret("urt", -ENOMEM);