i3c: remove i2c board info from i2c_dev_desc
I2C board info is only required during adapter setup so there is no requirement to keeping a pointer to it once running. To support dynamic device addition we can't rely on board info - user-space creation through sysfs won't have a boardinfo. Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Jamie Iles <quic_jiles@quicinc.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220117174816.1963463-2-quic_jiles@quicinc.com
This commit is contained in:
parent
e783362eb5
commit
31b9887c72
@ -609,7 +609,7 @@ static void i3c_master_free_i2c_dev(struct i2c_dev_desc *dev)
|
|||||||
|
|
||||||
static struct i2c_dev_desc *
|
static struct i2c_dev_desc *
|
||||||
i3c_master_alloc_i2c_dev(struct i3c_master_controller *master,
|
i3c_master_alloc_i2c_dev(struct i3c_master_controller *master,
|
||||||
const struct i2c_dev_boardinfo *boardinfo)
|
u16 addr, u8 lvr)
|
||||||
{
|
{
|
||||||
struct i2c_dev_desc *dev;
|
struct i2c_dev_desc *dev;
|
||||||
|
|
||||||
@ -618,9 +618,8 @@ i3c_master_alloc_i2c_dev(struct i3c_master_controller *master,
|
|||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
dev->common.master = master;
|
dev->common.master = master;
|
||||||
dev->boardinfo = boardinfo;
|
dev->addr = addr;
|
||||||
dev->addr = boardinfo->base.addr;
|
dev->lvr = lvr;
|
||||||
dev->lvr = boardinfo->lvr;
|
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
@ -694,7 +693,7 @@ i3c_master_find_i2c_dev_by_addr(const struct i3c_master_controller *master,
|
|||||||
struct i2c_dev_desc *dev;
|
struct i2c_dev_desc *dev;
|
||||||
|
|
||||||
i3c_bus_for_each_i2cdev(&master->bus, dev) {
|
i3c_bus_for_each_i2cdev(&master->bus, dev) {
|
||||||
if (dev->boardinfo->base.addr == addr)
|
if (dev->addr == addr)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1689,7 +1688,9 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
|
|||||||
i2cboardinfo->base.addr,
|
i2cboardinfo->base.addr,
|
||||||
I3C_ADDR_SLOT_I2C_DEV);
|
I3C_ADDR_SLOT_I2C_DEV);
|
||||||
|
|
||||||
i2cdev = i3c_master_alloc_i2c_dev(master, i2cboardinfo);
|
i2cdev = i3c_master_alloc_i2c_dev(master,
|
||||||
|
i2cboardinfo->base.addr,
|
||||||
|
i2cboardinfo->lvr);
|
||||||
if (IS_ERR(i2cdev)) {
|
if (IS_ERR(i2cdev)) {
|
||||||
ret = PTR_ERR(i2cdev);
|
ret = PTR_ERR(i2cdev);
|
||||||
goto err_detach_devs;
|
goto err_detach_devs;
|
||||||
@ -2175,6 +2176,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_adapter *adap = i3c_master_to_i2c_adapter(master);
|
||||||
struct i2c_dev_desc *i2cdev;
|
struct i2c_dev_desc *i2cdev;
|
||||||
|
struct i2c_dev_boardinfo *i2cboardinfo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
adap->dev.parent = master->dev.parent;
|
adap->dev.parent = master->dev.parent;
|
||||||
@ -2194,8 +2196,8 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
|
|||||||
* We silently ignore failures here. The bus should keep working
|
* We silently ignore failures here. The bus should keep working
|
||||||
* correctly even if one or more i2c devices are not registered.
|
* correctly even if one or more i2c devices are not registered.
|
||||||
*/
|
*/
|
||||||
i3c_bus_for_each_i2cdev(&master->bus, i2cdev)
|
list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node)
|
||||||
i2cdev->dev = i2c_new_client_device(adap, &i2cdev->boardinfo->base);
|
i2cdev->dev = i2c_new_client_device(adap, &i2cboardinfo->base);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,6 @@ struct i2c_dev_boardinfo {
|
|||||||
*/
|
*/
|
||||||
struct i2c_dev_desc {
|
struct i2c_dev_desc {
|
||||||
struct i3c_i2c_dev_desc common;
|
struct i3c_i2c_dev_desc common;
|
||||||
const struct i2c_dev_boardinfo *boardinfo;
|
|
||||||
struct i2c_client *dev;
|
struct i2c_client *dev;
|
||||||
u16 addr;
|
u16 addr;
|
||||||
u8 lvr;
|
u8 lvr;
|
||||||
|
Loading…
Reference in New Issue
Block a user