linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix 'assignment to __be16' warning
@ 2021-04-12 11:53 Bence Csókás
  2021-04-15 20:19 ` Wolfram Sang
  2021-04-15 20:37 ` Al Viro
  0 siblings, 2 replies; 3+ messages in thread
From: Bence Csókás @ 2021-04-12 11:53 UTC (permalink / raw)
  To: linux-i2c; +Cc: Bence Csókás, linux-kernel

While the preamble field _is_ technically big-endian, its value is always 0x2A2A,
which is the same in either endianness, therefore it should be u16 instead.

Signed-off-by: Bence Csókás <bence98@sch.bme.hu>

---
 drivers/i2c/busses/i2c-cp2615.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-cp2615.c b/drivers/i2c/busses/i2c-cp2615.c
index 78cfecd1ea76..2824f4ba7131 100644
--- a/drivers/i2c/busses/i2c-cp2615.c
+++ b/drivers/i2c/busses/i2c-cp2615.c
@@ -38,7 +38,9 @@ enum cp2615_iop_msg_type {
 };
 
 struct __packed cp2615_iop_msg {
-	__be16 preamble, length, msg;
+	/* always 0x2A2A, which is the same in either endianness */
+	u16 preamble;
+	__be16 length, msg;
 	u8 data[MAX_IOP_PAYLOAD_SIZE];
 };
 
-- 
2.31.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix 'assignment to __be16' warning
  2021-04-12 11:53 [PATCH] Fix 'assignment to __be16' warning Bence Csókás
@ 2021-04-15 20:19 ` Wolfram Sang
  2021-04-15 20:37 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2021-04-15 20:19 UTC (permalink / raw)
  To: Bence Csókás; +Cc: linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

Hi Bence,

On Mon, Apr 12, 2021 at 11:53:02AM +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, therefore it should be u16 instead.

Why should it be u16? I don't see it.

I thought the fix would be to add the suffix 'U' to 0x2A2A when it is
assigned to preamble?

Also, please use "i2c: cp2615: <patch header>" in the $subject

Happy hacking,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix 'assignment to __be16' warning
  2021-04-12 11:53 [PATCH] Fix 'assignment to __be16' warning Bence Csókás
  2021-04-15 20:19 ` Wolfram Sang
@ 2021-04-15 20:37 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2021-04-15 20:37 UTC (permalink / raw)
  To: Bence Csókás; +Cc: linux-i2c, linux-kernel

On Mon, Apr 12, 2021 at 11:53:02AM +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, therefore it should be u16 instead.

Just replace the assignment with htons(0x2A2A) and be done with that - it's
a constant expression and compiler will yield the same assembler.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-15 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 11:53 [PATCH] Fix 'assignment to __be16' warning Bence Csókás
2021-04-15 20:19 ` Wolfram Sang
2021-04-15 20:37 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).