diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-08-11 12:20:56 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2010-08-11 12:20:56 -0400 |
commit | 9a94241afcc9a481691a9c29b7460217925b59b8 (patch) | |
tree | 7f2d42935422a228686bcd8680dc97ff8a1005bc /drivers/i2c | |
parent | f1c2e33c295de423db5740647bfaa5e2ad139192 (diff) |
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.c | 16 |
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) | |||
1464 | struct i2c_client * | 1464 | struct i2c_client * |
1465 | i2c_new_probed_device(struct i2c_adapter *adap, | 1465 | i2c_new_probed_device(struct i2c_adapter *adap, |
1466 | struct i2c_board_info *info, | 1466 | struct i2c_board_info *info, |
1467 | unsigned short const *addr_list) | 1467 | unsigned short const *addr_list, |
1468 | int (*probe)(struct i2c_adapter *, unsigned short addr)) | ||
1468 | { | 1469 | { |
1469 | int i; | 1470 | int i; |
1470 | 1471 | ||
1471 | /* Stop here if the bus doesn't support probing */ | 1472 | if (!probe) { |
1472 | if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) { | 1473 | /* Stop here if the bus doesn't support probing */ |
1473 | dev_err(&adap->dev, "Probing not supported\n"); | 1474 | if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) { |
1474 | return NULL; | 1475 | dev_err(&adap->dev, "Probing not supported\n"); |
1476 | return NULL; | ||
1477 | } | ||
1478 | probe = i2c_default_probe; | ||
1475 | } | 1479 | } |
1476 | 1480 | ||
1477 | for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) { | 1481 | for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) { |
@@ -1490,7 +1494,7 @@ i2c_new_probed_device(struct i2c_adapter *adap, | |||
1490 | } | 1494 | } |
1491 | 1495 | ||
1492 | /* Test address responsiveness */ | 1496 | /* Test address responsiveness */ |
1493 | if (i2c_default_probe(adap, addr_list[i])) | 1497 | if (probe(adap, addr_list[i])) |
1494 | break; | 1498 | break; |
1495 | } | 1499 | } |
1496 | 1500 | ||