linux/Documentation/i2c
Jean Delvare 4735c98f84 i2c: Add detection capability to new-style drivers
Add a mechanism to let new-style i2c drivers optionally autodetect
devices they would support on selected buses and ask i2c-core to
instantiate them. This is a replacement for legacy i2c drivers, much
cleaner.

Where drivers had to implement both a legacy i2c_driver and a
new-style i2c_driver so far, this mechanism makes it possible to get
rid of the legacy i2c_driver and implement both enumerated and
detected device support with just one (new-style) i2c_driver.

Here is a quick conversion guide for these drivers, step by step:

* Delete the legacy driver definition, registration and removal.
  Delete the attach_adapter and detach_client methods of the legacy
  driver.

* Change the prototype of the legacy detect function from
    static int foo_detect(struct i2c_adapter *adapter, int address, int kind);
  to
    static int foo_detect(struct i2c_client *client, int kind,
    			  struct i2c_board_info *info);

* Set the new-style driver detect callback to this new function, and
  set its address_data to &addr_data (addr_data is generally provided
  by I2C_CLIENT_INSMOD.)

* Add the appropriate class to the new-style driver. This is
  typically the class the legacy attach_adapter method was checking
  for. Class checking is now mandatory (done by i2c-core.) See
  <linux/i2c.h> for the list of available classes.

* Remove the i2c_client allocation and freeing from the detect
  function. A pre-allocated client is now handed to you by i2c-core,
  and is freed automatically.

* Make the detect function fill the type field of the i2c_board_info
  structure it was passed as a parameter, and return 0, on success. If
  the detection fails, return -ENODEV.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:36 +02:00
..
busses i2c: Remove 3 deprecated bus drivers 2008-07-14 22:38:22 +02:00
chips deprecate obsolete pca9539 driver 2008-02-05 09:44:13 -08:00
dev-interface i2c: Rename the PEC functionality bit 2007-10-13 23:56:33 +02:00
fault-codes i2c: Document standard fault codes 2008-07-14 22:38:22 +02:00
functionality i2c: Improve the functionality documentation 2008-05-11 20:37:05 +02:00
i2c-protocol more UTF-8 conversions 2007-10-19 23:22:11 +02:00
i2c-stub i2c-stub: Use a single array for byte and word operations 2008-01-27 18:14:45 +01:00
porting-clients i2c: Documentation update 2007-05-01 23:26:35 +02:00
smbus-protocol i2c: Delete unused function i2c_smbus_write_quick 2008-07-14 22:38:23 +02:00
summary i2c: Delete an outdated piece of documentation 2007-12-12 13:45:24 +01:00
ten-bit-addresses Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
writing-clients i2c: Add detection capability to new-style drivers 2008-07-14 22:38:36 +02:00