October 2017
Intermediate to advanced
586 pages
14h 8m
English
The I2C core offers you the possibility to store a pointer to any data structure of your choice as device-specific data. To store or retrieve data, use the following function provided by the I2C core:
/* set the data */ void i2c_set_clientdata(struct i2c_client *client, void *data); /* get the data */ void *i2c_get_clientdata(const struct i2c_client *client);
These functions internally call dev_set_drvdata and dev_get_drvdata to update or get the value of the void *driver_data field of the struct device substructure in the struct i2c_client structure.
This is an example of how to use extra client data, an excerpt from drivers/gpio/gpio-mc9s08dz60.c:
/* This is the device specific data structure */ struct mc9s08dz60 { struct ...