i3c: master: Improve initialization of numbered I2C adapters
Subsystems (2)
PATCH 1/1 i3c: master: Improve initialization of numbered I2C adapters
Add logic to initialize I2C adapters with a specific ID if available, improving device identification and configuration.
Signed-off-by Defa Li <[email protected]>
--- drivers/i3c/master.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/i3c/master.c +9 -2
@@ -2486,7 +2486,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)struct i2c_adapter *adap =i3c_master_to_i2c_adapter (master);struct i2c_dev_desc *i2cdev;struct i2c_dev_boardinfo *i2cboardinfo; -int ret; +int ret, id = -ENODEV ; adap->dev.parent = master->dev.parent; adap->owner = master->dev.parent->driver->owner;
@@ -2497,7 +2497,14 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master) adap->timeout =1000 ; adap->retries =3 ; - ret =i2c_add_adapter (adap); +if (master->dev.of_node) + id =of_alias_get_id (master->dev.of_node,"i2c" ); + +if (id >=0 ) { + adap->nr = id; + ret =i2c_add_numbered_adapter (adap); + }else + ret =i2c_add_adapter (adap);if (ret)return ret;
Signature · 1 line
2.45.2
Quoted 3 lines · Defa Li
Add logic to initialize I2C adapters with a specific ID if available, improving device identification and configuration.
Could you also provide how exactly to define this into DT to have numbering while registering the adapter ? Kind of sample to which can be defined in DTSI.
Quoted 21 lines
Signed-off-by Defa Li <[email protected]>--- drivers/i3c/master.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/i3c/master.c +1
-1@@ -2486,7 +2486,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)struct i2c_adapter *adap =i3c_master_to_i2c_adapter (master);struct i2c_dev_desc *i2cdev;struct i2c_dev_boardinfo *i2cboardinfo; -int ret; +int ret, id = -ENODEV ; adap->dev.parent = master->dev.parent; adap->owner = master->dev.parent->driver->owner;@@ -2497,7 +2497,14 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master) adap->timeout =1000 ; adap->retries =3 ;
drivers/i3c/master.c static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master) · line 2507
Quoted 10 lines
drivers/i3c/master.c +8
-1- ret =i2c_add_adapter (adap); +if (master->dev.of_node) + id =of_alias_get_id (master->dev.of_node,"i2c" ); + +if (id >=0 ) { + adap->nr = id; + ret =i2c_add_numbered_adapter (adap); + }else + ret =i2c_add_adapter (adap);
Please provide braces for else too.
Quoted 3 lines
drivers/i3c/master.c +0
-0if (ret)return ret;
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c