[Skiboot] [PATCH] i2c: Fix sparse warnings for type assignment

Stewart Smith stewart at linux.ibm.com
Fri Mar 1 15:09:00 AEDT 2019


Use the correct beXX_to_cpu() macros.

core/i2c.c:105:29: warning: incorrect type in assignment (different base types)
core/i2c.c:105:29:    expected unsigned int [usertype] offset
core/i2c.c:105:29:    got restricted beint32_t [usertype] subaddr
core/i2c.c:110:29: warning: incorrect type in assignment (different base types)
core/i2c.c:110:29:    expected unsigned int [usertype] offset
core/i2c.c:110:29:    got restricted beint32_t [usertype] subaddr
core/i2c.c:117:23: warning: incorrect type in assignment (different base types)
core/i2c.c:117:23:    expected unsigned int [usertype] dev_addr
core/i2c.c:117:23:    got restricted beint16_t [usertype] addr
core/i2c.c:118:21: warning: incorrect type in assignment (different base types)
core/i2c.c:118:21:    expected unsigned int [usertype] rw_len
core/i2c.c:118:21:    got restricted beint32_t [usertype] size
core/i2c.c:119:24: warning: cast from restricted beint64_t

Signed-off-by: Stewart Smith <stewart at linux.ibm.com>
---
 core/i2c.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/core/i2c.c b/core/i2c.c
index 3c6000249c86..00dac0d12abb 100644
--- a/core/i2c.c
+++ b/core/i2c.c
@@ -102,21 +102,21 @@ static int opal_i2c_request(uint64_t async_token, uint32_t bus_id,
 		break;
 	case OPAL_I2C_SM_READ:
 		req->op = SMBUS_READ;
-		req->offset = oreq->subaddr;
+		req->offset = be32_to_cpu(oreq->subaddr);
 		req->offset_bytes = oreq->subaddr_sz;
 		break;
 	case OPAL_I2C_SM_WRITE:
 		req->op = SMBUS_WRITE;
-		req->offset = oreq->subaddr;
+		req->offset = be32_to_cpu(oreq->subaddr);
 		req->offset_bytes = oreq->subaddr_sz;
 		break;
 	default:
 		free(req);
 		return OPAL_PARAMETER;
 	}
-	req->dev_addr = oreq->addr;
-	req->rw_len = oreq->size;
-	req->rw_buf = (void *)oreq->buffer_ra;
+	req->dev_addr = be16_to_cpu(oreq->addr);
+	req->rw_len = be32_to_cpu(oreq->size);
+	req->rw_buf = (void *)be64_to_cpu(oreq->buffer_ra);
 	req->completion = opal_i2c_request_complete;
 	req->user_data = (void *)(unsigned long)async_token;
 	req->bus = bus;
-- 
2.20.1



More information about the Skiboot mailing list