| Electronic Components Datasheet Search |
|
UM0851 Datasheet(PDF) 81 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
UM0851 Datasheet(HTML) 81 Page - STMicroelectronics |
|
81 / 245 page ![]() UM0851 Communication device drivers Doc ID 16604 Rev 2 81/245 adapter gets a number, counting from 0. You can examine /sys/class/i2c-dev/ to see what number corresponds to which adapter. I2C device files are character device files with major device number 89 and a minor device number corresponding to the number assigned as explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ...,i2c-10, ...). All 256 minor device numbers are reserved for i2c. 4.5.4 Adding a new I2C client driver To add a new client driver, you should be familiar with struct i2c_driver.The struct i2c_driver describes an I2C chip driver. This structure is defined in the include/linux/i2c.h file. Only the following fields are necessary to create a working chip driver. /* set to a descriptive name of the I2C chip driver. This value shows up in the sysfs file name created for every I2C chip device */ char name[I2C_NAME_SIZE]; /* called whenever a new I2C bus driver is loaded in the system. This function is described in more detail below. */ int (*attach_adapter)(struct i2c_adapter *); /* called when the i2c_client device is to be removed from the system. */ int (*detach_client)(struct i2c_client *); static struct i2c_driver eeprom_driver = { .driver = { .name = "eeprom", }, .id = I2C_DRIVERID_eeprom, .attach_adapter = eeprom_attach_adapter, .detach_client = eeprom_detach_client, }; Registering a chip driver To register this I2C chip driver, the function i2c_add_driver() should be called with a pointer to the struct i2c_driver. static int __init eeprom_init(void) { return i2c_add_driver(&eeprom_driver); } Unregistering a chip driver To unregister the I2C chip driver, the i2c_del_driver() function should be called with the same pointer to the struct i2c_driver. I2c_del_driver() is defined in include/linux/i2c.h which will internally call i2c_unregister_driver() defined in drivers/i2c/i2c-core.c static void __exit eeprom_exit(void) { i2c_del_driver(&eeprom_driver); } |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |