diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-08-11 12:21:00 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2010-08-11 12:21:00 -0400 |
commit | 8031d79baedabd44590d047d97a310eb0e0e4e0c (patch) | |
tree | 1ddc3e78c880fdfbcb2377f2f41ff1b9a797731b /drivers/i2c | |
parent | d6703281ff20df6c2c0ea7c39a0cc2fa8be3e680 (diff) |
i2c: Make i2c_default_probe self-sufficient
Make i2c_default_probe self-sufficient, so that callers don't have to
do functionality checks themselves. This ensures everything is and
will stay consistent.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index bb02f8e21a3b..ba86af63f5cf 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -1378,13 +1378,17 @@ static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr) | |||
1378 | I2C_SMBUS_BYTE_DATA, &dummy); | 1378 | I2C_SMBUS_BYTE_DATA, &dummy); |
1379 | else | 1379 | else |
1380 | #endif | 1380 | #endif |
1381 | if ((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50 | 1381 | if (!((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50) |
1382 | || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) | 1382 | && i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) |
1383 | err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0, | ||
1384 | I2C_SMBUS_BYTE, &dummy); | ||
1385 | else | ||
1386 | err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0, | 1383 | err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0, |
1387 | I2C_SMBUS_QUICK, NULL); | 1384 | I2C_SMBUS_QUICK, NULL); |
1385 | else if (i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) | ||
1386 | err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0, | ||
1387 | I2C_SMBUS_BYTE, &dummy); | ||
1388 | else { | ||
1389 | dev_warn(&adap->dev, "No suitable probing method supported\n"); | ||
1390 | err = -EOPNOTSUPP; | ||
1391 | } | ||
1388 | 1392 | ||
1389 | return err >= 0; | 1393 | return err >= 0; |
1390 | } | 1394 | } |
@@ -1465,16 +1469,6 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) | |||
1465 | if (!(adapter->class & driver->class)) | 1469 | if (!(adapter->class & driver->class)) |
1466 | goto exit_free; | 1470 | goto exit_free; |
1467 | 1471 | ||
1468 | /* Stop here if the bus doesn't support probing */ | ||
1469 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE)) { | ||
1470 | if (address_list[0] == I2C_CLIENT_END) | ||
1471 | goto exit_free; | ||
1472 | |||
1473 | dev_warn(&adapter->dev, "Probing not supported\n"); | ||
1474 | err = -EOPNOTSUPP; | ||
1475 | goto exit_free; | ||
1476 | } | ||
1477 | |||
1478 | for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) { | 1472 | for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) { |
1479 | dev_dbg(&adapter->dev, "found normal entry for adapter %d, " | 1473 | dev_dbg(&adapter->dev, "found normal entry for adapter %d, " |
1480 | "addr 0x%02x\n", adap_id, address_list[i]); | 1474 | "addr 0x%02x\n", adap_id, address_list[i]); |
@@ -1504,14 +1498,8 @@ i2c_new_probed_device(struct i2c_adapter *adap, | |||
1504 | { | 1498 | { |
1505 | int i; | 1499 | int i; |
1506 | 1500 | ||
1507 | if (!probe) { | 1501 | if (!probe) |
1508 | /* Stop here if the bus doesn't support probing */ | ||
1509 | if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) { | ||
1510 | dev_err(&adap->dev, "Probing not supported\n"); | ||
1511 | return NULL; | ||
1512 | } | ||
1513 | probe = i2c_default_probe; | 1502 | probe = i2c_default_probe; |
1514 | } | ||
1515 | 1503 | ||
1516 | for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) { | 1504 | for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) { |
1517 | /* Check address validity */ | 1505 | /* Check address validity */ |