Skip to content
Snippets Groups Projects
Commit 95e82052 authored by Peng Fan's avatar Peng Fan Committed by Dong Aisheng
Browse files

MLK-20993 i2c: rpmsg: add a BUG_ON to catch alias id issue


The alias ID must be defined in device tree, because
that will be used as BUS ID to Cortex M4. If the alias ID
not defined, linux kernel will automatically allocate one
ID which might not be the same number used in Cortex M4 and
Cortex M4 will not send msg to I2C controller.

So let's add BUG_ON to catch issue as earlier as possible to avoid
wasting efforts.

Signed-off-by: default avatarPeng Fan <peng.fan@nxp.com>
Reviewed-by: default avatarClark Wang <xiaoning.wang@nxp.com>
(cherry picked from commit b9ff2035)
(cherry picked from commit 8e509705)
parent 17e1e79e
No related branches found
No related tags found
No related merge requests found
......@@ -369,6 +369,16 @@ static int i2c_rpbus_probe(struct platform_device *pdev)
adapter->dev.parent = dev;
adapter->dev.of_node = np;
adapter->nr = of_alias_get_id(np, "i2c");
/*
* The driver will send the adapter->nr as BUS ID to the other
* side, and the other side will check the BUS ID to see whether
* the BUS has been registered. If there is alias id for this
* virtual adapter, linux kernel will automatically allocate one
* id which might be not the same number used in the other side,
* cause i2c slave probe failure under this virtual I2C bus.
* So let's add a BUG_ON to catch this issue earlier.
*/
BUG_ON(adapter->nr < 0);
adapter->quirks = &i2c_rpbus_quirks;
snprintf(rdata->adapter.name, sizeof(rdata->adapter.name), "%s",
"i2c-rpmsg-adapter");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment