aboutsummaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass2020-12-16 21:20:30 -0700
committerSimon Glass2020-12-18 20:32:21 -0700
commita133e2179a729036e7750b497c1c38f9f6a3a835 (patch)
treee8701370910c0a3c2db692051baef3c39455e3fa /drivers/core
parent991759196faa74b2e7df1cb8e87820f4ec7285f8 (diff)
dm: core: Update uclass_find_next_free_req_seq() for new scheme
This function current deals with req_seq which is deprecated. Update it to use the new sequence numbers, putting them above existing aliases. Rename the function to make this clear. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c8
-rw-r--r--drivers/core/uclass.c19
2 files changed, 15 insertions, 12 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index b878a4d4b69..4abb5be56a4 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -93,18 +93,14 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
}
if (CONFIG_IS_ENABLED(OF_PRIOR_STAGE)) {
if (dev->req_seq == -1) {
- auto_seq = true;
dev->req_seq =
- uclass_find_next_free_req_seq(
- uc);
+ uclass_find_next_free_seq(uc);
}
}
- } else {
- dev->req_seq = uclass_find_next_free_req_seq(uc);
}
}
if (auto_seq && !(uc->uc_drv->flags & DM_UC_FLAG_NO_AUTO_SEQ))
- dev->sqq = uclass_find_next_free_req_seq(uc);
+ dev->sqq = uclass_find_next_free_seq(uc);
if (drv->plat_auto) {
bool alloc = !plat;
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 42c9ba58281..6409457fa96 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -272,18 +272,25 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
return -ENODEV;
}
-int uclass_find_next_free_req_seq(struct uclass *uc)
+int uclass_find_next_free_seq(struct uclass *uc)
{
struct udevice *dev;
int max = -1;
+ /* If using aliases, start with the highest alias value */
+ if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
+ (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS))
+ max = dev_read_alias_highest_id(uc->uc_drv->name);
+
+ /* Avoid conflict with existing devices */
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
- if ((dev->req_seq != -1) && (dev->req_seq > max))
- max = dev->req_seq;
+ if (dev->sqq > max)
+ max = dev->sqq;
}
-
- if (max == -1)
- return 0;
+ /*
+ * At this point, max will be -1 if there are no existing aliases or
+ * devices
+ */
return max + 1;
}