This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

queations regarding i2c_add_device driver ?

I have two queations ,

 

 

//in linux kernel

 

// Que.1=============================================

static const struct i2c_device_id mt9v113_id[]=

{

 {"mt9v113",0},

{},

};

MODULE_DEVICE_TABLE(i2c,mt9v113_id); // what is the role of this  function ?

//=============================================

//Que.2========================================

static struct i2c_driver mt9v113_i2c_driver=

{ .driver= {

.name ="mt9v113",

.owner = THIS_MODULE,

},

.probe=mt9v113_probe,                                        //Here function call is without parameters?

.remove=__exist_p(mtpv113_remove),  

.id_table=mt9v113_id,

};

 

static int mt9v113_probe(struct i2c_client * client , const struct i2c_device_id * id)   //How these parameters are passed to this function ?

{

}

//===========================================

  • Nilesh Mane said:

    I have two queations ,

    //in linux kernel

    // Que.1=============================================

    static const struct i2c_device_id mt9v113_id[]=

    {

     {"mt9v113",0},

    {},

    };

    MODULE_DEVICE_TABLE(i2c,mt9v113_id); // what is the role of this  function ?

    Looks like its a macro letting kernel know about i2c device

    Nilesh Mane said:

    //=============================================

    //Que.2========================================

    static struct i2c_driver mt9v113_i2c_driver=

    { .driver= {

    .name ="mt9v113",

    .owner = THIS_MODULE,

    },

    .probe=mt9v113_probe,                                        //Here function call is without parameters?

    .remove=__exist_p(mtpv113_remove),

    .id_table=mt9v113_id,

    };

    It is just assigning function pointer. When Kernel wants to probe, it will call using that function pointer

    Nilesh Mane said:

    static int mt9v113_probe(struct i2c_client * client , const struct i2c_device_id * id)   //How these parameters are passed to this function ?

    {

    }

    //===========================================

    .

    Kernel knows about parameters as its defined by Kernel.