From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] dt: check for devices already created fron DT scan
Date: Thu, 19 May 2011 13:54:13 -0600 [thread overview]
Message-ID: <20110519195413.GV5109@ponder.secretlab.ca> (raw)
In-Reply-To: <1305829704-11774-2-git-send-email-robherring2@gmail.com>
On Thu, May 19, 2011 at 01:28:23PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
>
> of_platform_bus_create may create duplicate devices if already
> added when scanning other buses like amba bus.
>
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> ---
> drivers/of/platform.c | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 9b785be..7bf74fb 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -234,6 +234,13 @@ static int of_platform_bus_create(struct device_node *bus,
> return 0;
> }
>
> + /* Has the device already been registered? */
> + if (of_find_device_by_node(bus)) {
> + pr_debug("%s() - skipping %s, already registered\n",
> + __func__, bus->full_name);
> + return 0;
> + }
> +
Intriguing, I hadn't though about doing it this way, and it would
hugely simplify the of_platform_prepare() logic that I posted a few
weeks back. I need to think about this...
However, there is a potential race condition with static device
registrations that also use of_platform_prepare(). If there every
exists a multi-threaded device registration scenario, then it could be
possible for this check to pass, the other thread register a
conflicting device, and then this finishes creating it. However,
since device registration is pretty much always a single threaded
affair, I'm probably just being paranoid.
Also, of_find_device_by_node() casts a rather wide net. There are a
few small use-cases where multiple devices will have the same node
pointer. It would be better to restrict it to devices with the same
parent, or devices on the same bus type.
> dev = of_platform_device_create(bus, NULL, parent);
> if (!dev || !of_match_node(matches, bus))
> return 0;
> @@ -326,4 +333,5 @@ int of_platform_populate(struct device_node *root,
> of_node_put(root);
> return rc;
> }
> +EXPORT_SYMBOL(of_platform_populate);
This is an unrelated change. Does it belong in this patch?
> #endif /* !CONFIG_SPARC */
> --
> 1.7.4.1
>
next prev parent reply other threads:[~2011-05-19 19:54 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-19 18:28 [PATCH v2 0/2] amba bus device tree probing Rob Herring
2011-05-19 18:28 ` [PATCH 1/2] dt: check for devices already created fron DT scan Rob Herring
2011-05-19 19:54 ` Grant Likely [this message]
2011-05-19 18:28 ` [PATCH 2/2] drivers/amba: probe via device tree Rob Herring
2011-05-19 20:01 ` Grant Likely
2011-05-19 23:30 ` Rob Herring
2011-05-19 23:39 ` Grant Likely
2011-05-20 13:24 ` Rob Herring
2011-05-20 14:21 ` Arnd Bergmann
2011-05-20 15:17 ` Rob Herring
2011-05-20 16:08 ` Stephen Neuendorffer
2011-05-21 17:42 ` Grant Likely
2011-05-21 23:47 ` Russell King - ARM Linux
2011-05-22 10:00 ` Rafael J. Wysocki
2011-05-22 15:46 ` Rob Herring
2011-05-23 15:23 ` Grant Likely
2011-05-22 10:03 ` Arnd Bergmann
2011-05-25 9:03 ` Linus Walleij
2011-05-23 9:37 ` Kristoffer Glembo
2011-05-23 9:58 ` Russell King - ARM Linux
2011-05-23 15:09 ` Grant Likely
2011-05-24 15:03 ` Rob Herring
2011-05-25 3:02 ` Shawn Guo
2011-05-25 9:07 ` Linus Walleij
2011-05-21 23:35 ` Russell King - ARM Linux
2011-05-23 15:00 ` Stephen Neuendorffer
2011-05-23 15:47 ` Russell King - ARM Linux
2011-05-21 4:00 ` Segher Boessenkool
2011-05-21 14:55 ` Rob Herring
2011-05-21 15:18 ` Segher Boessenkool
2011-05-21 17:43 ` Grant Likely
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=20110519195413.GV5109@ponder.secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).