
On Wed, Apr 27, 2016 at 1:40 PM, Stephen Warren swarren@wwwdotorg.org wrote:
On 04/26/2016 03:36 PM, Stephen Warren wrote:
On 04/26/2016 03:30 PM, Stephen Warren wrote:
From: Stephen Warren swarren@nvidia.com
It is possible for HW to contain multiple instances of the same device. In this case, the name passed to device_bind() may not be unique across all devices within its uclass. One example is a system with multiple identical PCI Ethernet devices. Another might be a system with multiple identical I2C GPIO expanders, each connected to a separate I2C bus, yet using the same I2C address on that bus and hence having the same DT node name.
Enhance the code to detect this situation, and append a sequence number so the device name to ensure uniqueness.
Signed-off-by: Stephen Warren swarren@nvidia.com
Some possible issues with this patch:
- Doing this in bind() rather than probe() means dev->seq isn't
available, so can't be used to generate the unique name. This process should be done during bind() rather than probe() though, since devices can be seen (e.g. by running "dm tree") before they're probed. Perhaps the uclass_resolve_seq() should be called by bind() not probe().
- uclass_find_device_by_name() needs to look up the uclass pointer again
even though device_bind() already knows it.
- Iterating over the list to find the count of devices in the uclass
is a bit annoying. Should the uclass maintain this count so it doesn't need to be re-calculated each time?
- This causes "ut dm autobind" to fail. I'll investigate that locally,
but won't bother reposting until the questions above are considered.
It looks like that's because I need to add "gd->dm_root && " to the start of the following condition:
@@ -62,6 +62,23 @@ int device_bind(struct udevice *parent, const struct driver *drv, dev->driver = drv; dev->uclass = uc;
if (!uclass_find_device_by_name(uc->uc_drv->id, dev->name, &dev2))
{
... otherwise, the uc_class_get/find() nested inside that end up creating a second root uclass.
Makes sense.
I can fold that into v2, pending any other comments.
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot