* [PATCH] i2c: Make i2c_default_probe self-sufficient
@ 2010-06-17 16:04 Jean Delvare
0 siblings, 0 replies; only message in thread
From: Jean Delvare @ 2010-06-17 16:04 UTC (permalink / raw)
To: Linux I2C
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-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
---
drivers/i2c/i2c-core.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
--- linux-2.6.35-rc3.orig/drivers/i2c/i2c-core.c 2010-06-17 13:05:41.000000000 +0200
+++ linux-2.6.35-rc3/drivers/i2c/i2c-core.c 2010-06-17 17:02:47.000000000 +0200
@@ -1369,13 +1369,17 @@ static int i2c_default_probe(struct i2c_
I2C_SMBUS_BYTE_DATA, &dummy);
else
#endif
- if ((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50
- || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK))
- err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0,
- I2C_SMBUS_BYTE, &dummy);
- else
+ if (!((addr & ~0x07) == 0x30 || (addr & ~0x0f) == 0x50)
+ && i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK))
err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_WRITE, 0,
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;
}
@@ -1456,16 +1460,6 @@ static int i2c_detect(struct i2c_adapter
if (!(adapter->class & driver->class))
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) {
dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
"addr 0x%02x\n", adap_id, address_list[i]);
@@ -1495,14 +1489,8 @@ i2c_new_probed_device(struct i2c_adapter
{
int i;
- 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;
- }
+ if (!probe)
probe = i2c_default_probe;
- }
for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) {
/* Check address validity */
--
Jean Delvare
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-17 16:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-17 16:04 [PATCH] i2c: Make i2c_default_probe self-sufficient Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).