* [PATCH] i2c: Fallback to of_node of parent
@ 2013-11-16 15:40 Florian Meier
[not found] ` <528791EF.9060505-oZ8rN/sblLk@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Florian Meier @ 2013-11-16 15:40 UTC (permalink / raw)
To: Wolfram Sang, Stephen Warren
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Many busses (e.g. tegra, omap, bcm2835)
need to set the of_node of the adapter
device to the one of the parent device, i.e.
adap->dev.of_node = pdev->dev.of_node;
As suggested by Stephen Warren, this could also
be done in the i2c core and it is a common mistake
to forget this line:
I2C: BCM2835: Linking platform nodes to adapter nodes
i2c: Fix device tree binding for i2c-cbus-gpio
Signed-off-by: Florian Meier <florian.meier-oZ8rN/sblLk@public.gmane.org>
Suggested-by: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
---
drivers/i2c/i2c-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 430c001..c8e33a5 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1310,6 +1310,9 @@ int i2c_add_adapter(struct i2c_adapter *adapter)
struct device *dev = &adapter->dev;
int id;
+ if (!dev->of_node && dev->parent)
+ dev->of_node = dev->parent->of_node;
+
if (dev->of_node) {
id = of_alias_get_id(dev->of_node, "i2c");
if (id >= 0) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <528791EF.9060505-oZ8rN/sblLk@public.gmane.org>]
* Re: [PATCH] i2c: Fallback to of_node of parent [not found] ` <528791EF.9060505-oZ8rN/sblLk@public.gmane.org> @ 2013-11-16 16:06 ` Wolfram Sang 2013-11-16 16:11 ` Florian Meier 0 siblings, 1 reply; 5+ messages in thread From: Wolfram Sang @ 2013-11-16 16:06 UTC (permalink / raw) To: Florian Meier Cc: Stephen Warren, linux-i2c-u79uwXL29TY76Z2rM5mHXA, linux-rpi-kernel, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 246 bytes --] > + if (!dev->of_node && dev->parent) > + dev->of_node = dev->parent->of_node; > + That is not enough. Current drivers could then have the assignment removed and even more important, this behaviour should be documented. Regards, Wolfram [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: Fallback to of_node of parent 2013-11-16 16:06 ` Wolfram Sang @ 2013-11-16 16:11 ` Florian Meier [not found] ` <CABDT8WzUoPmPzDnjD3w+Oj=jUVcMf91+toWDS+hK6CrXLveCFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Florian Meier @ 2013-11-16 16:11 UTC (permalink / raw) To: Wolfram Sang Cc: Stephen Warren, linux-i2c, linux-rpi-kernel, linux-kernel-u79uwXL29TY76Z2rM5mHXA Ok, I will try to find all relevant lines. Where is the best place to document this? Greetings, Florian 2013/11/16 Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>: > >> + if (!dev->of_node && dev->parent) >> + dev->of_node = dev->parent->of_node; >> + > > That is not enough. Current drivers could then have the assignment > removed and even more important, this behaviour should be documented. > > Regards, > > Wolfram > ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CABDT8WzUoPmPzDnjD3w+Oj=jUVcMf91+toWDS+hK6CrXLveCFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] i2c: Fallback to of_node of parent [not found] ` <CABDT8WzUoPmPzDnjD3w+Oj=jUVcMf91+toWDS+hK6CrXLveCFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2013-11-16 16:59 ` Florian Meier 2013-11-25 8:46 ` Wolfram Sang 0 siblings, 1 reply; 5+ messages in thread From: Florian Meier @ 2013-11-16 16:59 UTC (permalink / raw) To: Wolfram Sang Cc: Stephen Warren, linux-i2c, linux-rpi-kernel, linux-kernel-u79uwXL29TY76Z2rM5mHXA I have looked through all bus drivers and in most cases they have a corresponding line that could be removed. Although, this patch would break i2c-powermac, because it relies on the fact that of_node stays NULL. Any idea how to handle that? Greetings, Florian On 16.11.2013 17:11, Florian Meier wrote: > Ok, I will try to find all relevant lines. > Where is the best place to document this? > > Greetings, > Florian > > 2013/11/16 Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>: >> >>> + if (!dev->of_node && dev->parent) >>> + dev->of_node = dev->parent->of_node; >>> + >> >> That is not enough. Current drivers could then have the assignment >> removed and even more important, this behaviour should be documented. >> >> Regards, >> >> Wolfram >> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: Fallback to of_node of parent 2013-11-16 16:59 ` Florian Meier @ 2013-11-25 8:46 ` Wolfram Sang 0 siblings, 0 replies; 5+ messages in thread From: Wolfram Sang @ 2013-11-25 8:46 UTC (permalink / raw) To: Florian Meier; +Cc: Stephen Warren, linux-i2c, linux-rpi-kernel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 432 bytes --] On Sat, Nov 16, 2013 at 05:59:15PM +0100, Florian Meier wrote: > I have looked through all bus drivers and in most > cases they have a corresponding line that could be removed. > > Although, this patch would break i2c-powermac, because it > relies on the fact that of_node stays NULL. > > Any idea how to handle that? You are right, yet I don't have the time to look into that. If you have an idea, please go ahead. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-25 8:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-16 15:40 [PATCH] i2c: Fallback to of_node of parent Florian Meier
[not found] ` <528791EF.9060505-oZ8rN/sblLk@public.gmane.org>
2013-11-16 16:06 ` Wolfram Sang
2013-11-16 16:11 ` Florian Meier
[not found] ` <CABDT8WzUoPmPzDnjD3w+Oj=jUVcMf91+toWDS+hK6CrXLveCFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-16 16:59 ` Florian Meier
2013-11-25 8:46 ` Wolfram Sang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox