Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

Per-device data

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content