lkml.org 
[lkml]   [2024]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 31/33] i2c: fsi: Define a function to check status error bits
Date
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(-)

diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index 096dc7e2369f..5f524fb6f0f8 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -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) {
--
2.39.3

\
 
 \ /
  Last update: 2024-05-27 15:05    [W:0.284 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site