@@ -507,6 +507,26 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status)
return -ETIMEDOUT;
}
+static int fsi_i2c_error_status_to_rc(u32 status)
+{
+ if (status & I2C_STAT_INV_CMD)
+ return -EINVAL;
+
+ if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN | I2C_STAT_BE_ACCESS))
+ return -EPROTO;
+
+ if (status & I2C_STAT_NACK)
+ return -ENXIO;
+
+ if (status & I2C_STAT_LOST_ARB)
+ return -EAGAIN;
+
+ if (status & I2C_STAT_STOP_ERR)
+ return -EBADMSG;
+
+ return -EIO;
+}
+
static int fsi_i2c_handle_status(struct fsi_i2c_port *port,
struct i2c_msg *msg, u32 status)
{
@@ -518,23 +538,7 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port,
if (rc)
return rc;
- if (status & I2C_STAT_INV_CMD)
- return -EINVAL;
-
- if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN |
- I2C_STAT_BE_ACCESS))
- return -EPROTO;
-
- if (status & I2C_STAT_NACK)
- return -ENXIO;
-
- if (status & I2C_STAT_LOST_ARB)
- return -EAGAIN;
-
- if (status & I2C_STAT_STOP_ERR)
- return -EBADMSG;
-
- return -EIO;
+ return fsi_i2c_error_status_to_rc(status);
}
if (status & I2C_STAT_DAT_REQ) {
This will be used more than once with interrupt support, so split the error bit checks into a function. Signed-off-by: Eddie James <eajames@linux.ibm.com> --- drivers/i2c/busses/i2c-fsi.c | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-)