Skip to contentSkip to conversation

i2c/mips: Fix error return codes from Sibyte i2c bus driver

PATCH Superseded Guenter Roeck 3 participants 5 messages Jun 20, 2010 – Jun 26, 2010 I2C subsystem host drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c/mips: Fix error return codes from Sibyte i2c bus driver

Sibyte i2c bus driver returns non-descriptive error values. Update to return error values as defined in Documentation/i2c/fault-codes.

---
 drivers/i2c/busses/i2c-sibyte.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-sibyte.c +2 -2
index 3d76a18..329cbee 100644
@@ -94,7 +94,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 		}
 		break;
 	default:
-		return -1;      /* XXXKW better error code? */
+		return -EOPNOTSUPP;
 	}
 
 	while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
@@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 	if (error & M_SMB_ERROR) {
 		/* Clear error bit by writing a 1 */
 		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
-		return -1;      /* XXXKW better error code? */
+		return -ENXIO;
 	}
 
 	if (data_bytes == 1)
Signature · 1 line
1.7.0.87.g0901d
#1 lore raw

Hi Guenter,

Quoted 22 lines · Guenter Roeck

Sibyte i2c bus driver returns non-descriptive error values. Update to return error values as defined in Documentation/i2c/fault-codes.

---
 drivers/i2c/busses/i2c-sibyte.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-sibyte.c +1 -1
index 3d76a18..329cbee 100644
@@ -94,7 +94,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 		}
 		break;
 	default:
-		return -1;      /* XXXKW better error code? */
+		return -EOPNOTSUPP;
 	}
 
 	while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)

drivers/i2c/busses/i2c-sibyte.c static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, · line 110

Quoted 8 lines
drivers/i2c/busses/i2c-sibyte.c +1 -1
@@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 	if (error & M_SMB_ERROR) {
 		/* Clear error bit by writing a 1 */
 		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
-		return -1;      /* XXXKW better error code? */
+		return -ENXIO;
 	}
 
 	if (data_bytes == 1)

Definitely an improvement. However, returning -ENXIO on all errors seems wrong. This error value should only be returned on missing ack from the slave on address byte. Isn't it possible to distinguish between different error kinds? M_SMB_ERROR_TYPE seems promising, but one would need to look up the datasheet (which I don't have) to discover its meaning.

Signature · 1 line
Jean Delvare
#2 lore raw
Quoted 32 lines · Jean Delvare

Hi Guenter,

Quoted 29 lines · Guenter Roeck

Sibyte i2c bus driver returns non-descriptive error values. Update to return error values as defined in Documentation/i2c/fault-codes.

---
 drivers/i2c/busses/i2c-sibyte.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-sibyte.c +2 -2
index 3d76a18..329cbee 100644
@@ -94,7 +94,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 		}
 		break;
 	default:
-		return -1;      /* XXXKW better error code? */
+		return -EOPNOTSUPP;
 	}
 
 	while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
@@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 	if (error & M_SMB_ERROR) {
 		/* Clear error bit by writing a 1 */
 		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
-		return -1;      /* XXXKW better error code? */
+		return -ENXIO;
 	}
 
Quoted 9 lines

drivers/i2c/busses/i2c-sibyte.c static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, · line 110

Quoted 1 line
drivers/i2c/busses/i2c-sibyte.c +0 -0
 	if (data_bytes == 1)

Definitely an improvement. However, returning -ENXIO on all errors seems wrong. This error value should only be returned on missing ack from the slave on address byte. Isn't it possible to distinguish between different error kinds? M_SMB_ERROR_TYPE seems promising, but one would need to look up the datasheet (which I don't have) to discover its meaning.

Makes sense. I'll dig up a copy of the datasheet and see if I can improve it.

Guenter

#3 lore raw
Quoted 17 lines · Guenter Roeck
Quoted 8 lines
Quoted 8 lines
drivers/i2c/busses/i2c-sibyte.c +1 -1
@@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 	if (error & M_SMB_ERROR) {
 		/* Clear error bit by writing a 1 */
 		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
-		return -1;      /* XXXKW better error code? */
+		return -ENXIO;
 	}
 
Quoted 9 lines

drivers/i2c/busses/i2c-sibyte.c static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, · line 110

Quoted 1 line
drivers/i2c/busses/i2c-sibyte.c +0 -0
 	if (data_bytes == 1)

Definitely an improvement. However, returning -ENXIO on all errors seems wrong. This error value should only be returned on missing ack from the slave on address byte. Isn't it possible to distinguish between different error kinds? M_SMB_ERROR_TYPE seems promising, but one would need to look up the datasheet (which I don't have) to discover its meaning.

Quoted 1 line

Makes sense. I'll dig up a copy of the datasheet and see if I can improve it.

The M_SMB_ERROR_TYPE bit is cleared if an expected ackonwledgement has
not been seen and set if the transfer has failed after 15 retries. So that's probably ENXIO for the former and EIO for the latter.

Maciej

#4 lore raw
Quoted 19 lines · Maciej W. Rozycki
Quoted 17 lines · Guenter Roeck
Quoted 17 lines

drivers/i2c/busses/i2c-sibyte.c static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, · line 110

Quoted 9 lines
drivers/i2c/busses/i2c-sibyte.c +1 -1
@@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 	if (error & M_SMB_ERROR) {
 		/* Clear error bit by writing a 1 */
 		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
-		return -1;      /* XXXKW better error code? */
+		return -ENXIO;
 	}
 
 	if (data_bytes == 1)

Definitely an improvement. However, returning -ENXIO on all errors seems wrong. This error value should only be returned on missing ack from the slave on address byte. Isn't it possible to distinguish between different error kinds? M_SMB_ERROR_TYPE seems promising, but one would need to look up the datasheet (which I don't have) to discover its meaning.

Quoted 5 lines
Quoted 1 line

Makes sense. I'll dig up a copy of the datasheet and see if I can improve it.

The M_SMB_ERROR_TYPE bit is cleared if an expected ackonwledgement has
not been seen and set if the transfer has failed after 15 retries. So that's probably ENXIO for the former and EIO for the latter.

Exactly what Guenter did. Good.

Signature · 1 line
Jean Delvare