My philosophy: simple and practical. Don't get a bunch of source code. The result is that people don't know how to use it after reading it. view me:
1. Add I2C information to the ARCH/ARM/Mach-xxx/platform file, which is named i2c_board_info.
For example:
Static struct i2c_board_info _ initdata xxxi2c_board_info [] = {
{
I2c_board_info ("ABCD1", 0x20),/* string to match with the following, 0x20 is from the device address */
. Platform_data = 0,
},
{
I2c_board_info ("abcd2", 0x21 ),
. Platform_data = 0,
},
};
Then call i2c_register_board_info (1, xxxi2c_board_info, array_size (xxxi2c_board_info ));
The first parameter is 0 or 1. I do not know yet :-(
2. Call i2c_add_driver () in the form of module_init (func_init () in another device driver file, there are several definitions:
Static const struct i2c_device_id xxx_led_id [] = {
{"ABCD1", 0},/* The name must match board_info to call the probe function */
{"Abcd2", 0 },
{}
};
Module_device_table (I2C, xxx_led_id );
Static struct i2c_driver xxx_led_driver = {
. Driver = {
. Name = "yourname",/* This name does not need to match any other name */
. Owner = this_module,
},
. Probe = xxx_led_probe,
. Remove = xxx_remove,
. Id_table = xxx_led_id,
};
See it. After the string in struct i2c_device_id matches the string in i2c_board_info, xxx_led_probe will be called.
If you do not want to use the same probe, write a struct i2c_device_id and struct i2c_driver.
How do I know what the process and each struct are?