Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] i2c: Fallback to of_node of parent

1 view
Skip to first unread message

Florian Meier

unread,
Nov 16, 2013, 10:50:02 AM11/16/13
to
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 <floria...@koalo.de>
Suggested-by: Stephen Warren <swa...@wwwdotorg.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Wolfram Sang

unread,
Nov 16, 2013, 11:10:02 AM11/16/13
to

> + 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

signature.asc

Florian Meier

unread,
Nov 16, 2013, 11:20:02 AM11/16/13
to
Ok, I will try to find all relevant lines.
Where is the best place to document this?

Greetings,
Florian

2013/11/16 Wolfram Sang <w...@the-dreams.de>:

Florian Meier

unread,
Nov 16, 2013, 12:00:01 PM11/16/13
to
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

Wolfram Sang

unread,
Nov 25, 2013, 3:50:01 AM11/25/13
to
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.

signature.asc
0 new messages