Commit 8031d79b authored by Jean Delvare's avatar Jean Delvare

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: default avatarJean Delvare <khali@linux-fr.org>
parent d6703281
...@@ -1378,13 +1378,17 @@ static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr) ...@@ -1378,13 +1378,17 @@ static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr)
I2C_SMBUS_BYTE_DATA, &dummy); I2C_SMBUS_BYTE_DATA, &dummy);
else else
#endif #endif
if ((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50 if (!((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50)
|| !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) && i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK))
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0,
I2C_SMBUS_BYTE, &dummy);
else
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0, err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0,
I2C_SMBUS_QUICK, NULL); I2C_SMBUS_QUICK, NULL);
else if (i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE))
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0,
I2C_SMBUS_BYTE, &dummy);
else {
dev_warn(&adap->dev, "No suitable probing method supported\n");
err = -EOPNOTSUPP;
}
return err >= 0; return err >= 0;
} }
...@@ -1465,16 +1469,6 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) ...@@ -1465,16 +1469,6 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
if (!(adapter->class & driver->class)) if (!(adapter->class & driver->class))
goto exit_free; goto exit_free;
/* Stop here if the bus doesn't support probing */
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE)) {
if (address_list[0] == I2C_CLIENT_END)
goto exit_free;
dev_warn(&adapter->dev, "Probing not supported\n");
err = -EOPNOTSUPP;
goto exit_free;
}
for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) { for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
dev_dbg(&adapter->dev, "found normal entry for adapter %d, " dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
"addr 0x%02x\n", adap_id, address_list[i]); "addr 0x%02x\n", adap_id, address_list[i]);
...@@ -1504,14 +1498,8 @@ i2c_new_probed_device(struct i2c_adapter *adap, ...@@ -1504,14 +1498,8 @@ i2c_new_probed_device(struct i2c_adapter *adap,
{ {
int i; int i;
if (!probe) { 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; probe = i2c_default_probe;
}
for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) { for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) {
/* Check address validity */ /* Check address validity */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment