diff mbox series

[v2] i2c: cp2615: Fix 'assignment to __be16' warning

Message ID 20231030171910.3447256-1-bence98@sch.bme.hu
State New
Headers show
Series [v2] i2c: cp2615: Fix 'assignment to __be16' warning | expand

Commit Message

Bence Csókás Oct. 30, 2023, 5:19 p.m. UTC
While the preamble field _is_ technically big-endian, its value is always 0x2A2A,
which is the same in either endianness. However, to avoid generating a warning,
we should still call `htons()` explicitly.

Signed-off-by: Bence Csókás <bence98@sch.bme.hu>
---
 drivers/i2c/busses/i2c-cp2615.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wolfram Sang Nov. 8, 2023, 9:28 a.m. UTC | #1
On Mon, Oct 30, 2023 at 05:19:10PM +0000, Bence Csókás wrote:
> While the preamble field _is_ technically big-endian, its value is always 0x2A2A,
> which is the same in either endianness. However, to avoid generating a warning,
> we should still call `htons()` explicitly.
> 
> Signed-off-by: Bence Csókás <bence98@sch.bme.hu>

Applied to for-current, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-cp2615.c b/drivers/i2c/busses/i2c-cp2615.c
index 20f8f7c9a8cd..cf3747d87034 100644
--- a/drivers/i2c/busses/i2c-cp2615.c
+++ b/drivers/i2c/busses/i2c-cp2615.c
@@ -85,7 +85,7 @@  static int cp2615_init_iop_msg(struct cp2615_iop_msg *ret, enum cp2615_iop_msg_t
 	if (!ret)
 		return -EINVAL;
 
-	ret->preamble = 0x2A2A;
+	ret->preamble = htons(0x2A2AU);
 	ret->length = htons(data_len + 6);
 	ret->msg = htons(msg);
 	if (data && data_len)