mirror of
https://xff.cz/git/u-boot/
synced 2025-09-30 06:51:28 +02:00
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>
This commit is contained in:
@@ -93,18 +93,14 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
|
|||||||
}
|
}
|
||||||
if (CONFIG_IS_ENABLED(OF_PRIOR_STAGE)) {
|
if (CONFIG_IS_ENABLED(OF_PRIOR_STAGE)) {
|
||||||
if (dev->req_seq == -1) {
|
if (dev->req_seq == -1) {
|
||||||
auto_seq = true;
|
|
||||||
dev->req_seq =
|
dev->req_seq =
|
||||||
uclass_find_next_free_req_seq(
|
uclass_find_next_free_seq(uc);
|
||||||
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))
|
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) {
|
if (drv->plat_auto) {
|
||||||
bool alloc = !plat;
|
bool alloc = !plat;
|
||||||
|
@@ -272,18 +272,25 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
int uclass_find_next_free_req_seq(struct uclass *uc)
|
int uclass_find_next_free_seq(struct uclass *uc)
|
||||||
{
|
{
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int max = -1;
|
int max = -1;
|
||||||
|
|
||||||
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
|
/* If using aliases, start with the highest alias value */
|
||||||
if ((dev->req_seq != -1) && (dev->req_seq > max))
|
if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
|
||||||
max = dev->req_seq;
|
(uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS))
|
||||||
}
|
max = dev_read_alias_highest_id(uc->uc_drv->name);
|
||||||
|
|
||||||
if (max == -1)
|
/* Avoid conflict with existing devices */
|
||||||
return 0;
|
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
|
||||||
|
if (dev->sqq > max)
|
||||||
|
max = dev->sqq;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* At this point, max will be -1 if there are no existing aliases or
|
||||||
|
* devices
|
||||||
|
*/
|
||||||
|
|
||||||
return max + 1;
|
return max + 1;
|
||||||
}
|
}
|
||||||
|
@@ -1019,7 +1019,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
|
|||||||
ret = uclass_get(UCLASS_PCI, &uc);
|
ret = uclass_get(UCLASS_PCI, &uc);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
bus->sqq = uclass_find_next_free_req_seq(uc);
|
bus->sqq = uclass_find_next_free_seq(uc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For bridges, use the top-level PCI controller */
|
/* For bridges, use the top-level PCI controller */
|
||||||
|
@@ -12,17 +12,20 @@
|
|||||||
#include <dm/ofnode.h>
|
#include <dm/ofnode.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uclass_find_next_free_req_seq() - Get the next free req_seq number
|
* uclass_find_next_free_seq() - Get the next free sequence number
|
||||||
*
|
*
|
||||||
* This returns the next free req_seq number. This is useful only if
|
* This returns the next free sequence number. This is useful only if
|
||||||
* OF_CONTROL is not used. The next free req_seq number is simply the
|
* OF_CONTROL is not used. The next free sequence number is simply the
|
||||||
* maximum req_seq of the uclass + 1.
|
* maximum sequence number used by all devices in the uclass + 1. The value
|
||||||
* This allows assiging req_seq number in the binding order.
|
* returned is always greater than the largest alias, if DM_SEQ_ALIAS is enabled
|
||||||
|
* and the uclass has the DM_UC_FLAG_SEQ_ALIAS flag.
|
||||||
|
*
|
||||||
|
* This allows assigning the sequence number in the binding order.
|
||||||
*
|
*
|
||||||
* @uc: uclass to check
|
* @uc: uclass to check
|
||||||
* @return The next free req_seq number
|
* @return The next free sequence number
|
||||||
*/
|
*/
|
||||||
int uclass_find_next_free_req_seq(struct uclass *uc);
|
int uclass_find_next_free_seq(struct uclass *uc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uclass_get_device_tail() - handle the end of a get_device call
|
* uclass_get_device_tail() - handle the end of a get_device call
|
||||||
|
Reference in New Issue
Block a user