
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?
4) This causes "ut dm autobind" to fail. I'll investigate that locally, but won't bother reposting until the questions above are considered.