From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Tue, 26 Apr 2016 15:36:38 -0600 Subject: [U-Boot] [RFC PATCH] dm: ensure device names are unique In-Reply-To: <1461706228-3092-1-git-send-email-swarren@wwwdotorg.org> References: <1461706228-3092-1-git-send-email-swarren@wwwdotorg.org> Message-ID: <571FDF66.8020607@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 04/26/2016 03:30 PM, Stephen Warren wrote: > From: Stephen Warren > > 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 > --- > Some possible issues with this patch: > > 1) 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(). > > 2) uclass_find_device_by_name() needs to look up the uclass pointer again > even though device_bind() already knows it. > > 3) 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.