[i2c] Question about i2c new style modle

Wen Wang sickdoctor at gmail.com
Sun Oct 12 13:52:08 CEST 2008


 Hi Wolfram,

Thank you for your quick response, really appreciate.

You're saying "You supply i2c_board_info in your board init code and when
the
i2c adapter is initialized", but I'm quite sure there won't be a such
static i2c_board_info in the board init code.

And I'm just wonder if there is a dynamic detect method to go?

Here is my proposed code, can you please help to correct it if I'm wrong?

static const unsigned short normal_i2c[] = { DEVICE_ADDRESS, I2C_CLIENT_END
};
I2C_CLIENT_INSMOD(foo);

static int foo_detect(struct i2c_client *client, int kind,
                             struct i2c_board_info *info)
{
         /* Things here */
         return 0;
}

static int foo_probe(struct i2c_client *client,
                            const struct i2c_device_id *id)
{
          /* Things here */
         return 0;
}

static int foo_remove(struct i2c_client *client)
{
         /* Things here */
         return 0;
}

static const struct i2c_device_id foo_id[] = {
         { "foo", 0 },
         { }
};

static struct i2c_driver foo_driver = {
         .driver = {
                 .name = "foo",
         },
         .probe  = foo_probe,
         .remove  = foo_remove,
         .id_table = foo_id,
         .class  = I2C_CLASS_CAM_DIGITAL,
         .detect  = foo_detect,
         .address_data = &addr_data,
};

Best Regards
Wen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.lm-sensors.org/pipermail/i2c/attachments/20081012/9d9c161a/attachment.html 


More information about the i2c mailing list