1. 關注unreg_slave接口spa
1.1 這個接口在哪裏被調用呢?code
在drivers/i2c/i2c-core-slave.c中 blog
int i2c_slave_unregister(struct i2c_client *client)
{
int ret;接口
if (!client->adapter->algo->unreg_slave) { dev_err(&client->dev, "%s: not supported by adapter\n", __func__); return -EOPNOTSUPP; } i2c_lock_bus(client->adapter, I2C_LOCK_ROOT_ADAPTER); ret = client->adapter->algo->unreg_slave(client); i2c_unlock_bus(client->adapter, I2C_LOCK_ROOT_ADAPTER); if (ret == 0) client->slave_cb = NULL; else dev_err(&client->dev, "%s: adapter returned error %d\n", __func__, ret); return ret;
}
1.2 那麼i2c_slave_unregister又是在哪裏被調用的呢?rem
在drivers/i2c/i2c-slave-eeprom.c中被調用get
static int i2c_slave_eeprom_remove(struct i2c_client *client) { struct eeprom_data *eeprom = i2c_get_clientdata(client); i2c_slave_unregister(client); sysfs_remove_bin_file(&client->dev.kobj, &eeprom->bin); return 0; }