diff mbox series

i2c: Fix sparse warnings for type assignment

Message ID 20190301040900.1609-1-stewart@linux.ibm.com
State Accepted
Headers show
Series i2c: Fix sparse warnings for type assignment | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Stewart Smith March 1, 2019, 4:09 a.m. UTC
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@linux.ibm.com>
---
 core/i2c.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Stewart Smith March 4, 2019, 3:08 a.m. UTC | #1
Stewart Smith <stewart@linux.ibm.com> writes:
> 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

Merged to master as of ee01ef4ed82aa78fcf5516ffd6d49a92b8e912bf
diff mbox series

Patch

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;