2
votes

I have problem concerning about my module it it installed/initialized correctly but the other parts of the driver is not installed or showing up in the output.

   static struct i2c_driver qt2120_dev {
       .probe = qt2120_probe,
       .remove = qt2120_remove,
       .owner = {
           .name = qt2120,
           .module = THIS_MODULE, 
       }
       ....           
   }

  static __init qt2120_init(){
       prink("********init******");
       .......
  }
  module_init(qt2120_init)

  static int qt2120_probe(){
       prink("********probe******");
       .......     
  }

  static __devinit qt2120_remove(){
       prink("********probe******");
       .......     
  }    

Only "/**init*" appeared in the output. The module has been installed to the i2c according to the output.

  "bus: i2c. qt2120 as qt2120/input" 

Something is wrong with module because the printk's in probe and remove never at all.

I also changed in the MAKEFILE @CONFIG_AT2120 += qt2160.o with qt2120.o as the module

Is there something wrong with my configuration? qt2120.c is very similar to qt2160.c in code aurora.

2
Well, prink is not valid, so maybe your latest compile attempt failed and you actually installed an earlier version. And no, you should not have changed .o to .c in the Makefile either.Chris Stratton
I mean printk and in the make file, qt2120.oFranz Mationg

2 Answers

2
votes

Probe and remove function is not calling because you have not registered your driver with i2c subsystem. Register your driver using i2c_add_driver() API. In your case,

static int __init qt2120_init(void)
{
    return i2c_add_driver(&qt2120_dev);
}

static void __exit qt2120_remove(void)
{
    return i2c_del_driver(&qt2120_dev);
}
2
votes
  • First you need to make ,I2C driver registering the 'struct i2c_driver' structure with the I2C core using i2c_add_driver(addr_of_struct i2c_driver).

    static const struct i2c_device_id sample_i2c_id[] = {
      { "qt2120", 0 },
      { }
    };
    static struct i2c_driver qt2120_dev = {
       .probe = qt2120_probe,
       .remove = qt2120_remove,
       .id_table = sample_i2c_id,
       .driver   = {
            .name = "qt2120",
        },
     ....           
    };
    
    • You need to add .id_table entry . The id_table member allows us to tell the framework which I2C slaves chips we support.

After matching .id_table entry.Driver calls probe function.