diff mbox series

[v7,22/26] sfc-ctrl: endian conversions

Message ID 20191111054918.7188-23-npiggin@gmail.com
State Changes Requested
Headers show
Series little endian skiboot | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch master (d75e82dbfbb9443efeb3f9a5921ac23605aab469)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Nicholas Piggin Nov. 11, 2019, 5:49 a.m. UTC
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 hw/sfc-ctrl.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/hw/sfc-ctrl.c b/hw/sfc-ctrl.c
index f17b8de29..d66be09eb 100644
--- a/hw/sfc-ctrl.c
+++ b/hw/sfc-ctrl.c
@@ -110,33 +110,32 @@  struct sfc_ctrl {
 /* Command register support */
 static inline int sfc_reg_read(uint8_t reg, uint32_t *val)
 {
-	uint32_t tmp;
 	int rc;
 
 	*val = 0xffffffff;
-	rc = lpc_fw_read32(&tmp, SFC_CMDREG_OFFSET + reg);
+	rc = lpc_fw_read32(val, SFC_CMDREG_OFFSET + reg);
 	if (rc)
 		return rc;
-	*val = be32_to_cpu(tmp);
 	return 0;
 }
 
 static inline int sfc_reg_write(uint8_t reg, uint32_t val)
 {
-	return lpc_fw_write32(cpu_to_be32(val), SFC_CMDREG_OFFSET + reg);
+	return lpc_fw_write32(val, SFC_CMDREG_OFFSET + reg);
 }
 
 static int sfc_buf_write(uint32_t len, const void *data)
 {
-	uint32_t tmp, off = 0;
+	__be32 tmp;
+	uint32_t off = 0;
 	int rc;
 
 	if (len > SFC_CMDBUF_SIZE)
 		return FLASH_ERR_PARM_ERROR;
 
 	while (len >= 4) {
-		tmp = *(const uint32_t *)data;
-		rc = lpc_fw_write32(tmp, SFC_CMDBUF_OFFSET + off);
+		tmp = cpu_to_be32(*(const uint32_t *)data);
+		rc = lpc_fw_write32((u32)tmp, SFC_CMDBUF_OFFSET + off);
 		if (rc)
 			return rc;
 		off += 4;
@@ -150,9 +149,9 @@  static int sfc_buf_write(uint32_t len, const void *data)
 	 * in memory with memcpy. The swap in the register on LE doesn't
 	 * matter, the result in memory will be in the right order.
 	 */
-	tmp = -1;
-	memcpy(&tmp, data, len);
-	return lpc_fw_write32(tmp, SFC_CMDBUF_OFFSET + off);
+	tmp = cpu_to_be32(-1);
+	memcpy(&tmp, data, len); /* XXX: is this right? */
+	return lpc_fw_write32((u32)tmp, SFC_CMDBUF_OFFSET + off);
 }
 
 static int sfc_buf_read(uint32_t len, void *data)