My scenario is the following: From an out-of-tree kernel module A, I want to create a new I²C device B when some event happens in A.
From what I understand from the kernel I²C documentation, I would then expect that ->probe()
function of the driver associated with the newly created I²C B to be called by the kernel, but that does not happen.
Module A code snippet:
static struct i2c_board_info board_info[] = {
{
I2C_BOARD_INFO("device_B", 0x70),
},
};
// Create new I2C device when event happens
i2c_client = i2c_new_client_device(client->adapter, (struct i2c_board_info const *)&board_info);
Module B code snippet:
static int device_B_probe(struct i2c_client *client)
{
pr_info("Probe called");
return 0;
}
static const struct of_device_id device_B_of_match[] = {
{ .compatible = "device_B", },
{ }
};
MODULE_DEVICE_TABLE(of, device_B_of_match);
static const struct i2c_device_id device_B_id[] = {
{ "device_B", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, device_B_id);
static struct i2c_driver device_B_driver = {
.driver = {
.name = "device_B_name",
.of_match_table = device_B_of_match,
},
.probe_new = device_B_probe,
.id_table = device_B_id,
};
module_i2c_driver(device_B_driver);
Any ideas what could be wrong? There are no entries for device B in the device tree. I tried changing modules to in-tree modules but it makes no difference.