All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH] dm: ensure device names are unique
Date: Wed, 27 Apr 2016 12:40:37 -0600	[thread overview]
Message-ID: <572107A5.40807@wwwdotorg.org> (raw)
In-Reply-To: <571FDF66.8020607@wwwdotorg.org>

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:
>>
>> 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.

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.

I can fold that into v2, pending any other comments.

  reply	other threads:[~2016-04-27 18:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26 21:30 [U-Boot] [RFC PATCH] dm: ensure device names are unique Stephen Warren
2016-04-26 21:36 ` Stephen Warren
2016-04-27 18:40   ` Stephen Warren [this message]
2016-04-28  4:44     ` Joe Hershberger
2016-04-28  4:42 ` Joe Hershberger
2016-04-28 16:00   ` Stephen Warren
2016-04-29 13:24     ` Simon Glass
2016-04-28  4:50 ` Simon Glass
2016-04-28 15:55   ` Stephen Warren
2016-04-29 13:23     ` Simon Glass
2016-04-29 16:23       ` Stephen Warren
2016-04-29 16:28         ` Simon Glass
2016-04-29 16:30           ` Stephen Warren
2016-04-29 17:22             ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=572107A5.40807@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.