1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct i2c_driver</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux Device Drivers"><link rel="up" href="i2c.html" title="Chapter 10. I2C and SMBus Subsystem"><link rel="prev" href="i2c.html" title="Chapter 10. I2C and SMBus Subsystem"><link rel="next" href="API-struct-i2c-client.html" title="struct i2c_client"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct i2c_driver</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="i2c.html">Prev</a> </td><th width="60%" align="center">Chapter 10. I<sup>2</sup>C and SMBus Subsystem</th><td width="20%" align="right"> <a accesskey="n" href="API-struct-i2c-client.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-i2c-driver"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct i2c_driver — 2 represent an I2C device driver 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting"> 4struct i2c_driver { 5 unsigned int class; 6 int (* attach_adapter) (struct i2c_adapter *); 7 int (* probe) (struct i2c_client *, const struct i2c_device_id *); 8 int (* remove) (struct i2c_client *); 9 void (* shutdown) (struct i2c_client *); 10 void (* alert) (struct i2c_client *, unsigned int data); 11 int (* command) (struct i2c_client *client, unsigned int cmd, void *arg); 12 struct device_driver driver; 13 const struct i2c_device_id * id_table; 14 int (* detect) (struct i2c_client *, struct i2c_board_info *); 15 const unsigned short * address_list; 16 struct list_head clients; 17}; </pre></div><div class="refsect1"><a name="idp1115228500"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">class</span></dt><dd><p> 18What kind of i2c device we instantiate (for detect) 19 </p></dd><dt><span class="term">attach_adapter</span></dt><dd><p> 20Callback for bus addition (deprecated) 21 </p></dd><dt><span class="term">probe</span></dt><dd><p> 22Callback for device binding 23 </p></dd><dt><span class="term">remove</span></dt><dd><p> 24Callback for device unbinding 25 </p></dd><dt><span class="term">shutdown</span></dt><dd><p> 26Callback for device shutdown 27 </p></dd><dt><span class="term">alert</span></dt><dd><p> 28Alert callback, for example for the SMBus alert protocol 29 </p></dd><dt><span class="term">command</span></dt><dd><p> 30Callback for bus-wide signaling (optional) 31 </p></dd><dt><span class="term">driver</span></dt><dd><p> 32Device driver model driver 33 </p></dd><dt><span class="term">id_table</span></dt><dd><p> 34List of I2C devices supported by this driver 35 </p></dd><dt><span class="term">detect</span></dt><dd><p> 36Callback for device detection 37 </p></dd><dt><span class="term">address_list</span></dt><dd><p> 38The I2C addresses to probe (for detect) 39 </p></dd><dt><span class="term">clients</span></dt><dd><p> 40List of detected clients we created (for i2c-core use only) 41 </p></dd></dl></div></div><div class="refsect1"><a name="idp1115237644"></a><h2>Description</h2><p> 42 The driver.owner field should be set to the module owner of this driver. 43 The driver.name field should be set to the name of this driver. 44 </p><p> 45 46 For automatic device detection, both <em class="parameter"><code>detect</code></em> and <em class="parameter"><code>address_list</code></em> must 47 be defined. <em class="parameter"><code>class</code></em> should also be set, otherwise only devices forced 48 with module parameters will be created. The detect function must 49 fill at least the name field of the i2c_board_info structure it is 50 handed upon successful detection, and possibly also the flags field. 51 </p><p> 52 53 If <em class="parameter"><code>detect</code></em> is missing, the driver will still work fine for enumerated 54 devices. Detected devices simply won't be supported. This is expected 55 for the many I2C/SMBus devices which can't be detected reliably, and 56 the ones which can always be enumerated in practice. 57 </p><p> 58 59 The i2c_client structure which is handed to the <em class="parameter"><code>detect</code></em> callback is 60 not a real i2c_client. It is initialized just enough so that you can 61 call i2c_smbus_read_byte_data and friends on it. Don't do anything 62 else with it. In particular, calling dev_dbg and friends on it is 63 not allowed. 64</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="i2c.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="i2c.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-struct-i2c-client.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 10. I<sup>2</sup>C and SMBus Subsystem </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">struct i2c_client</span></td></tr></table></div></body></html> 65