The dw-hdmi I2C controller binding doesn't support listing I2C slaves
as child nodes in the device tree. This is fine as the EDID I2C address
is well-known, but trying to parse the dw-hdmi device tree node as if it
were a normal I2C controller will fail:

  ERROR: i2c11: of_i2c: invalid reg on /hdmi@fe0a0000/ports

Fix this by only use the device tree node to find the alias if any and
not passing it alone to the I2C core.

Fixes: 474b6cb42ea5 ("video: dw-hdmi: populate missing I2C adapter device node")
Reported-by: Alexander Shiyan <[email protected]>
Signed-off-by: Ahmad Fatoum <[email protected]>
---
 drivers/video/dw-hdmi.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/video/dw-hdmi.c b/drivers/video/dw-hdmi.c
index cd5de17e9bd7..b86f3c7366c1 100644
--- a/drivers/video/dw-hdmi.c
+++ b/drivers/video/dw-hdmi.c
@@ -433,9 +433,15 @@ static struct i2c_adapter *dw_hdmi_i2c_adapter(struct 
dw_hdmi *hdmi)
 
        adap = &i2c->adap;
        adap->dev.parent = hdmi->dev;
-       adap->dev.of_node = hdmi->dev->of_node;
        adap->master_xfer = dw_hdmi_i2c_xfer;
-       adap->nr = -1;
+
+       /*
+        * The binding doesn't support listing slaves as OF child nodes,
+        * therefore we use the device tree node only to check if
+        * there is an alias.
+        */
+       adap->dev.of_node = NULL;
+       adap->nr = of_alias_get_id(hdmi->dev->of_node, "i2c");
 
        i2c->rinfo.sda_gpio = of_get_named_gpio_flags(hdmi->dev->of_node,
                                                          "sda-gpios", 0,
-- 
2.39.5


Reply via email to