Patchwork [RFC,1/2] i2c: Allow SPD probing with READ_BYTE_DATA and improve logging

login
register
mail settings
Submitter Andrew Lutomirski
Date July 1, 2013, 11:30 p.m.
Message ID <2bb2489068b9d6e0833ed1d3f79a2a0c302b8c2f.1372720609.git.luto@amacapital.net>
Download mbox | patch
Permalink /patch/256248/
State Superseded
Headers show

Comments

Andrew Lutomirski - July 1, 2013, 11:30 p.m.
The Intel iMC SMBUS controller can't READ_BYTE.  (This seems odd to me
-- it supports WRITE_BYTE.)  SPD EEPROMs are safe to probe with
READ_BYTE_DATA, so fall back to that.

While I'm in here, also show the address that had no probing method for
easier debugging.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
---
 drivers/i2c/i2c-core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 991d38d..ea88fc0 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1501,8 +1501,13 @@  static int i2c_default_probe(struct i2c_adapter *adap, unsigned short addr)
 	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 if ((addr & ~0x0f) == 0x50
+	 && i2c_check_functionality(adap, I2C_FUNC_SMBUS_READ_BYTE_DATA))
+		err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, 0,
+				     I2C_SMBUS_BYTE_DATA, &dummy);
 	else {
-		dev_warn(&adap->dev, "No suitable probing method supported\n");
+		dev_warn(&adap->dev, "No suitable probing method supported for address 0x%02X\n",
+			 addr);
 		err = -EOPNOTSUPP;
 	}