Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+10 -22
+10 -22
drivers/i2c/i2c-core.c
··· 1378 1378 I2C_SMBUS_BYTE_DATA, &dummy); 1379 1379 else 1380 1380 #endif 1381 - if ((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50 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 1381 + if (!((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50) 1382 + && i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) 1386 1383 err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0, 1387 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 1393 return err >= 0; 1390 1394 } ··· 1469 1465 if (!(adapter->class & driver->class)) 1470 1466 goto exit_free; 1471 1467 1472 - /* Stop here if the bus doesn't support probing */ 1473 - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE)) { 1474 - if (address_list[0] == I2C_CLIENT_END) 1475 - goto exit_free; 1476 - 1477 - dev_warn(&adapter->dev, "Probing not supported\n"); 1478 - err = -EOPNOTSUPP; 1479 - goto exit_free; 1480 - } 1481 - 1482 1468 for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) { 1483 1469 dev_dbg(&adapter->dev, "found normal entry for adapter %d, " 1484 1470 "addr 0x%02x\n", adap_id, address_list[i]); ··· 1498 1504 { 1499 1505 int i; 1500 1506 1501 - if (!probe) { 1502 - /* Stop here if the bus doesn't support probing */ 1503 - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE)) { 1504 - dev_err(&adap->dev, "Probing not supported\n"); 1505 - return NULL; 1506 - } 1507 + if (!probe) 1507 1508 probe = i2c_default_probe; 1508 - } 1509 1509 1510 1510 for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) { 1511 1511 /* Check address validity */