i2c: Fallback to of_node of parent
Subsystems (2)
PATCH 1/1 i2c: Fallback to of_node of parent
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
--- drivers/i2c/i2c-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/i2c-core.c +3 -0
@@ -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 ) {
Signature · 1 line
1.7.9.5
drivers/i2c/i2c-core.c int i2c_add_adapter(struct i2c_adapter *adapter) · line 1315
Quoted 4 lines
drivers/i2c/i2c-core.c +3
-0+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
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/[email protected]>:
Quoted 12 lines
drivers/i2c/i2c-core.c int i2c_add_adapter(struct i2c_adapter *adapter) · line 1315
Quoted 4 lines
drivers/i2c/i2c-core.c +3
-0+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
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
Quoted 19 lines · Florian Meier
Ok, I will try to find all relevant lines.
Where is the best place to document this?Greetings,
Florian2013/11/16 Wolfram Sang <wsa-z923LK4zBo2bacvFa/[email protected]>:
Quoted 12 lines
drivers/i2c/i2c-core.c int i2c_add_adapter(struct i2c_adapter *adapter) · line 1315
Quoted 4 lines
drivers/i2c/i2c-core.c +3
-0+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
Quoted 7 lines · Florian Meier
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_nodestays 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.