From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
To: devicetree@vger.kernel.org, Grant Likely <grant.likely@secretlab.ca>
Cc: "Guido Martínez" <guido@vanguardiasur.com.ar>,
linux-kernel@vger.kernel.org
Subject: Why do we assign a unique (and non-deterministic) name in of_device_make_bus_id()
Date: Sat, 10 May 2014 12:32:28 -0300 [thread overview]
Message-ID: <20140510153227.GA18722@arch.cereza> (raw)
I have a devicetree for a custom board with several nodes with no
applicable reg property, such as:
/ {
backlight {
compatible = "pwm-backlight";
};
gpio-keys {
compatible = "gpio-keys";
};
rotary-encoder {
compatible = "rotary-encoder";
};
};
These nodes are then registered as devices with unique names:
$ ls /sys/devices
gpio_keys.8/ rotary_encoder.9/ backlight.6/
... among others.
The uniqueness is guaranteed by of_device_make_bus_id() which uses a global
counter for all nodes with no reg property. The relevant snippet is:
[..]
/*
* No BusID, use the node name and add a globally incremented
* counter (and pray...)
*/
magic = atomic_add_return(1, &bus_no_reg_magic);
dev_set_name(dev, "%s.%d", node->name, magic - 1);
Two nodes can't have the same name and get registered, hence my confusion:
Is the unique number addition absolutely necessary? What am I missing here?
Isn't a bit problematic to register devices with names that depend solely
on probe order (i.e. non-deterministic)?
For instance, hotplug event listeners matching the device name may fail if
the device suddenly change for whatever reason.
Regards,
--
Ezequiel Garcia, VanguardiaSur
www.vanguardiasur.com.ar
reply other threads:[~2014-05-10 15:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20140510153227.GA18722@arch.cereza \
--to=ezequiel@vanguardiasur.com.ar \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@secretlab.ca \
--cc=guido@vanguardiasur.com.ar \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox