Commit abc01b27 authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

i2c-algo-bit: Return standard fault codes

Adjust i2c-algo-bit to return fault codes compliant with
Documentation/i2c/fault-codes, rather than the undocumented and
vague -EREMOTEIO.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent f6beb67d
...@@ -443,7 +443,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -443,7 +443,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
acknak(i2c_adap, 0); acknak(i2c_adap, 0);
dev_err(&i2c_adap->dev, "readbytes: invalid " dev_err(&i2c_adap->dev, "readbytes: invalid "
"block length (%d)\n", inval); "block length (%d)\n", inval);
return -EREMOTEIO; return -EPROTO;
} }
/* The original count value accounts for the extra /* The original count value accounts for the extra
bytes, that is, either 1 for a regular transaction, bytes, that is, either 1 for a regular transaction,
...@@ -472,7 +472,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -472,7 +472,7 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
* reads, writes as well as 10bit-addresses. * reads, writes as well as 10bit-addresses.
* returns: * returns:
* 0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set * 0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set
* -x an error occurred (like: -EREMOTEIO if the device did not answer, or * -x an error occurred (like: -ENXIO if the device did not answer, or
* -ETIMEDOUT, for example if the lines are stuck...) * -ETIMEDOUT, for example if the lines are stuck...)
*/ */
static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
...@@ -495,14 +495,14 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -495,14 +495,14 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
if ((ret != 1) && !nak_ok) { if ((ret != 1) && !nak_ok) {
dev_err(&i2c_adap->dev, dev_err(&i2c_adap->dev,
"died at extended address code\n"); "died at extended address code\n");
return -EREMOTEIO; return -ENXIO;
} }
/* the remaining 8 bit address */ /* the remaining 8 bit address */
ret = i2c_outb(i2c_adap, msg->addr & 0x7f); ret = i2c_outb(i2c_adap, msg->addr & 0x7f);
if ((ret != 1) && !nak_ok) { if ((ret != 1) && !nak_ok) {
/* the chip did not ack / xmission error occurred */ /* the chip did not ack / xmission error occurred */
dev_err(&i2c_adap->dev, "died at 2nd address code\n"); dev_err(&i2c_adap->dev, "died at 2nd address code\n");
return -EREMOTEIO; return -ENXIO;
} }
if (flags & I2C_M_RD) { if (flags & I2C_M_RD) {
bit_dbg(3, &i2c_adap->dev, "emitting repeated " bit_dbg(3, &i2c_adap->dev, "emitting repeated "
...@@ -514,7 +514,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) ...@@ -514,7 +514,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
if ((ret != 1) && !nak_ok) { if ((ret != 1) && !nak_ok) {
dev_err(&i2c_adap->dev, dev_err(&i2c_adap->dev,
"died at repeated address code\n"); "died at repeated address code\n");
return -EREMOTEIO; return -EIO;
} }
} }
} else { /* normal 7bit address */ } else { /* normal 7bit address */
...@@ -572,7 +572,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, ...@@ -572,7 +572,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
ret, ret == 1 ? "" : "s"); ret, ret == 1 ? "" : "s");
if (ret < pmsg->len) { if (ret < pmsg->len) {
if (ret >= 0) if (ret >= 0)
ret = -EREMOTEIO; ret = -EIO;
goto bailout; goto bailout;
} }
} else { } else {
...@@ -583,7 +583,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, ...@@ -583,7 +583,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
ret, ret == 1 ? "" : "s"); ret, ret == 1 ? "" : "s");
if (ret < pmsg->len) { if (ret < pmsg->len) {
if (ret >= 0) if (ret >= 0)
ret = -EREMOTEIO; ret = -EIO;
goto bailout; goto bailout;
} }
} }
......
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