summaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-11-03 21:53:08 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-15 08:34:53 +0100
commit47e176461fbbff0b6f3ad863ef7f1fd3bc2d3c02 (patch)
tree959d1fa7dce1f415a2cf9652b31f8b3b2e01d405 /drivers/i2c/i2c.c
parent106742b9009b0d04faabe52d21f9fd3cff408b32 (diff)
downloadbarebox-47e176461fbbff0b6f3ad863ef7f1fd3bc2d3c02.tar.gz
barebox-47e176461fbbff0b6f3ad863ef7f1fd3bc2d3c02.tar.xz
i2c: introduce i2c_new_dummy
This returns an I2C client bound to the "dummy" driver, intended for use with devices that consume multiple addresses. Examples of such chips include various EEPROMS (like 24c04 and 24c08 models). Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/i2c/i2c.c')
-rw-r--r--drivers/i2c/i2c.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 3af5c32ec6..92d9442f25 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -282,6 +282,34 @@ struct i2c_client *i2c_new_device(struct i2c_adapter *adapter,
EXPORT_SYMBOL(i2c_new_device);
/**
+ * i2c_new_dummy - return a new i2c device bound to a dummy driver
+ * @adapter: the adapter managing the device
+ * @address: seven bit address to be used
+ * Context: can sleep
+ *
+ * This returns an I2C client bound to the "dummy" driver, intended for use
+ * with devices that consume multiple addresses. Examples of such chips
+ * include various EEPROMS (like 24c04 and 24c08 models).
+ *
+ * These dummy devices have two main uses. First, most I2C and SMBus calls
+ * except i2c_transfer() need a client handle; the dummy will be that handle.
+ * And second, this prevents the specified address from being bound to a
+ * different driver.
+ *
+ * This returns the new i2c client, which should be saved for later use with
+ * i2c_unregister_device(); or NULL to indicate an error.
+ */
+struct i2c_client *i2c_new_dummy(struct i2c_adapter *adapter, u16 address)
+{
+ struct i2c_board_info info = {
+ I2C_BOARD_INFO("dummy", address),
+ };
+
+ return i2c_new_device(adapter, &info);
+}
+EXPORT_SYMBOL_GPL(i2c_new_dummy);
+
+/**
* i2c_register_board_info - register I2C devices for a given board
*
* @param info array of chip descriptors