summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-08-11 20:20:56 +0400
committerJean Delvare <khali@linux-fr.org>2010-08-11 20:20:56 +0400
commit9a94241afcc9a481691a9c29b7460217925b59b8 (patch)
tree7f2d42935422a228686bcd8680dc97ff8a1005bc /drivers/i2c
parentf1c2e33c295de423db5740647bfaa5e2ad139192 (diff)
downloadlinux-9a94241afcc9a481691a9c29b7460217925b59b8.tar.xz
i2c: Add support for custom probe function
The probe method used by i2c_new_probed_device() may not be suitable for all cases. Let the caller provide its own, optional probe function. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index df937df845eb..cf14ca063181 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1464,14 +1464,18 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
struct i2c_client *
i2c_new_probed_device(struct i2c_adapter *adap,
struct i2c_board_info *info,
- unsigned short const *addr_list)
+ unsigned short const *addr_list,
+ int (*probe)(struct i2c_adapter *, unsigned short addr))
{
int i;
- /* Stop here if the bus doesn't support probing */
- if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) {
- dev_err(&adap->dev, "Probing not supported\n");
- return NULL;
+ if (!probe) {
+ /* Stop here if the bus doesn't support probing */
+ if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) {
+ dev_err(&adap->dev, "Probing not supported\n");
+ return NULL;
+ }
+ probe = i2c_default_probe;
}
for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) {
@@ -1490,7 +1494,7 @@ i2c_new_probed_device(struct i2c_adapter *adap,
}
/* Test address responsiveness */
- if (i2c_default_probe(adap, addr_list[i]))
+ if (probe(adap, addr_list[i]))
break;
}