mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
dm: device: Allow using uclass_find_device_by_seq() without OF_CONTROL
If OF_CONTROL is not enabled and DM_SEQ_ALIAS is enabled, we must assign an alias (requested sequence number) to devices that belongs to a class with the DM_UC_FLAG_SEQ_ALIAS flag. Otherwise uclass_find_device_by_seq() cannot be used to get/probe a device. In particular i2c_get_chip_for_busnum() cannot be used. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
f32a8007ef
commit
3542ff29e4
3 changed files with 43 additions and 4 deletions
|
@ -269,6 +269,30 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
#if !CONFIG_IS_ENABLED(OF_CONTROL) || CONFIG_IS_ENABLED(OF_PLATDATA)
|
||||
int uclass_find_next_free_req_seq(enum uclass_id id)
|
||||
{
|
||||
struct uclass *uc;
|
||||
struct udevice *dev;
|
||||
int ret;
|
||||
int max = -1;
|
||||
|
||||
ret = uclass_get(id, &uc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
list_for_each_entry(dev, &uc->dev_head, uclass_node) {
|
||||
if ((dev->req_seq != -1) && (dev->req_seq > max))
|
||||
max = dev->req_seq;
|
||||
}
|
||||
|
||||
if (max == -1)
|
||||
return 0;
|
||||
|
||||
return max + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq,
|
||||
bool find_req_seq, struct udevice **devp)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue