From: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux Kernel list
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Josh Cartwright <joshc-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Courtney Cavin
<courtney.cavin-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
Cc: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
Subject: [RFC PATCH 1/3] devicetree: set bus type same as parent
Date: Tue, 06 May 2014 17:51:12 -0700 [thread overview]
Message-ID: <53698380.1060006@gmail.com> (raw)
In-Reply-To: <536982E3.10303-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Frank Rowand <frank.rowand-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
This is a somewhat scary patch since it touches a path that is central to
device creation based on the device tree. It should not be applied without
careful consideration.
I am not sure if this patch is a good idea, even if it does not break
anything.
An issue with the path of SPMI nodes under /sys/bus/... was reported in
https://lkml.org/lkml/2014/4/23/312. The symptom is that two different
grandchild nodes of the spmi with the same node-name@unit-address will
result in attempting to create duplicate links at
/sys/bus/platform/devices/unit-address.node-name. It turns out that the
specific example provided might not be an expected configuration for
current hardware, but the reported trap remains an issue.
The common pattern exposed is a driver probe function calling
of_platform_populate() to create child devices. As the reporting
email noted, the devices are created with dev.bus set to
platform_bus_type. Thus all devices created via this pattern will
result in a link in /sys/bus/platform/devices/, with the risk that
a name collision will occur.
This patch reduces the scope of possible name collisions to devices
on the same bus type. This is still not ideal, because a legal
device tree source file can result in run time errors. In the case
of SPMI nodes, the collisions will occur in /bus/spmi/devices/.
I have not investigated whether other drivers would be negatively impacted
by this change - there are 26 drivers in tree that call of_platform_populate().
Signed-off-by: Frank Rowand <frank.rowand-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
---
drivers/of/platform.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: b/drivers/of/platform.c
===================================================================
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -217,7 +217,10 @@ static struct platform_device *of_platfo
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
if (!dev->dev.dma_mask)
dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
- dev->dev.bus = &platform_bus_type;
+ if (parent && parent->bus)
+ dev->dev.bus = parent->bus;
+ else
+ dev->dev.bus = &platform_bus_type;
dev->dev.platform_data = platform_data;
/* We do not fill the DMA ops for platform devices by default.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Frank Rowand <frowand.list@gmail.com>
To: Grant Likely <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Linux Kernel list <linux-kernel@vger.kernel.org>,
Josh Cartwright <joshc@codeaurora.org>,
Courtney Cavin <courtney.cavin@sonymobile.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
Lee Jones <lee.jones@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [RFC PATCH 1/3] devicetree: set bus type same as parent
Date: Tue, 06 May 2014 17:51:12 -0700 [thread overview]
Message-ID: <53698380.1060006@gmail.com> (raw)
In-Reply-To: <536982E3.10303@gmail.com>
From: Frank Rowand <frank.rowand@sonymobile.com>
This is a somewhat scary patch since it touches a path that is central to
device creation based on the device tree. It should not be applied without
careful consideration.
I am not sure if this patch is a good idea, even if it does not break
anything.
An issue with the path of SPMI nodes under /sys/bus/... was reported in
https://lkml.org/lkml/2014/4/23/312. The symptom is that two different
grandchild nodes of the spmi with the same node-name@unit-address will
result in attempting to create duplicate links at
/sys/bus/platform/devices/unit-address.node-name. It turns out that the
specific example provided might not be an expected configuration for
current hardware, but the reported trap remains an issue.
The common pattern exposed is a driver probe function calling
of_platform_populate() to create child devices. As the reporting
email noted, the devices are created with dev.bus set to
platform_bus_type. Thus all devices created via this pattern will
result in a link in /sys/bus/platform/devices/, with the risk that
a name collision will occur.
This patch reduces the scope of possible name collisions to devices
on the same bus type. This is still not ideal, because a legal
device tree source file can result in run time errors. In the case
of SPMI nodes, the collisions will occur in /bus/spmi/devices/.
I have not investigated whether other drivers would be negatively impacted
by this change - there are 26 drivers in tree that call of_platform_populate().
Signed-off-by: Frank Rowand <frank.rowand@sonymobile.com>
---
drivers/of/platform.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Index: b/drivers/of/platform.c
===================================================================
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -217,7 +217,10 @@ static struct platform_device *of_platfo
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
if (!dev->dev.dma_mask)
dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
- dev->dev.bus = &platform_bus_type;
+ if (parent && parent->bus)
+ dev->dev.bus = parent->bus;
+ else
+ dev->dev.bus = &platform_bus_type;
dev->dev.platform_data = platform_data;
/* We do not fill the DMA ops for platform devices by default.
next prev parent reply other threads:[~2014-05-07 0:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 0:48 [RFC PATCH 0/3] devicetree, qcomm PMIC: fix node name conflict Frank Rowand
2014-05-07 0:48 ` Frank Rowand
[not found] ` <536982E3.10303-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-07 0:51 ` Frank Rowand [this message]
2014-05-07 0:51 ` [RFC PATCH 1/3] devicetree: set bus type same as parent Frank Rowand
[not found] ` <53698380.1060006-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-07 15:17 ` Grant Likely
2014-05-07 15:17 ` Grant Likely
2014-05-07 1:32 ` [RFC PATCH 0/3] devicetree, qcomm PMIC: fix node name conflict Rob Herring
2014-05-07 1:32 ` Rob Herring
[not found] ` <CAL_JsqL6+i_ED+s6kODsadszefaZUcA7VHCfZ4k4yj62iXsarQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-07 2:49 ` Frank Rowand
2014-05-07 2:49 ` Frank Rowand
2014-05-07 14:51 ` Grant Likely
2014-05-07 15:12 ` Bjorn Andersson
[not found] ` <CAJAp7OiyjefyPMu2p8jTkbfQWYUKeYV62pVTtJ2JOP-6YOOGKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-07 16:08 ` Rob Herring
2014-05-07 16:08 ` Rob Herring
2014-05-07 0:52 ` [RFC PATCH 2/3] devicetree: provide hook to allow setting devicetree device name Frank Rowand
[not found] ` <536983D0.8090307-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-07 15:21 ` Grant Likely
2014-05-07 15:21 ` Grant Likely
2014-05-07 0:53 ` [RFC PATCH 3/3] devicetree, qcomm PMIC: use new hook to make PMIC device names unique Frank Rowand
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=53698380.1060006@gmail.com \
--to=frowand.list-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=courtney.cavin-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=joshc-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.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 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.