Defining and registering the I2C driver
Driver on

Defining and registering the I2C driver

What we now have seen up to now doesn’t change. The additional factor we want is to outline struct of_device_id. struct of_device_id is outlined to match the corresponding node within the .dts file:

/* no additional information for this system */ 
static const struct of_device_id foobar_of_match[] = { 
        { .appropriate = "packtpub,foobar-device" }, 
MODULE_DEVICE_TABLE(of, foobar_of_match); 

Now, we outline i2c_driver as follows:

static struct i2c_driver foo_driver = { 
    .driver = { 
    .identify   = "foo", 
    .of_match_table = of_match_ptr(foobar_of_match), /* Solely this line is added */ 
    .probe  = foo_probe, 
    .id_table = foo_id, 

You may then enhance the probe perform this manner:

static int my_probe(struct i2c_client *shopper, const struct i2c_device_id ...

Leave a Reply

Your email address will not be published. Required fields are marked *