mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] mfd: viperboard: fix native fields type in structures as little-endiand
@ 2026-07-15 14:52 Mikhail Lukianchikov
  2026-07-17 12:10 ` [PATCH v2] " Mikhail Lukianchikov
  0 siblings, 1 reply; 3+ messages in thread
From: Mikhail Lukianchikov @ 2026-07-15 14:52 UTC (permalink / raw)
  To: lee; +Cc: avermoal, mfd, linux-kernel

Sparse reports several warnings about incorrect type in assignment
(different base types) when building the i2c-viperboard.c driver:

  warning: incorrect type in assignment (different base types)
     expected unsigned short [usertype] addr
     got restricted __le16 [usertype]

The structures vprbrd_i2c_write_hdr, vprbrd_i2c_read_hdr, and
vprbrd_i2c_addr_msg describe raw USB packets and, as I understand it,
require Little-Endian byte-order. Therefore, 16-bit field in these
structures were annotated as __le16, not native unsigned short.
This satisfies Sparse and ensures correct behavior on
Big-Endian architectures.

Signed-off-by: Mikhail Lukianchikov <avermoal@gmail.com>
---
 include/linux/mfd/viperboard.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/mfd/viperboard.h b/include/linux/mfd/viperboard.h
index 46287a1f6bf6..5761ebdc81b3 100644
--- a/include/linux/mfd/viperboard.h
+++ b/include/linux/mfd/viperboard.h
@@ -57,15 +57,15 @@ struct vprbrd_i2c_write_hdr {
 
 struct vprbrd_i2c_read_hdr {
 	u8 cmd;
-	u16 addr;
+	__le16 addr;
 	u8 len0;
 	u8 len1;
 	u8 len2;
 	u8 len3;
 	u8 len4;
 	u8 len5;
-	u16 tf1;                        /* transfer 1 length */
-	u16 tf2;                        /* transfer 2 length */
+	__le16 tf1;                        /* transfer 1 length */
+	__le16 tf2;                        /* transfer 2 length */
 } __packed;
 
 struct vprbrd_i2c_status {
@@ -89,7 +89,7 @@ struct vprbrd_i2c_addr_msg {
 	u8 cmd;
 	u8 addr;
 	u8 unknown1;
-	u16 len;
+	__le16 len;
 	u8 unknown2;
 	u8 unknown3;
 } __packed;
-- 
2.55.0


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

* [PATCH v2] mfd: viperboard: fix native fields type in structures as little-endiand
  2026-07-15 14:52 [PATCH v1] mfd: viperboard: fix native fields type in structures as little-endiand Mikhail Lukianchikov
@ 2026-07-17 12:10 ` Mikhail Lukianchikov
  2026-08-06 11:55   ` (subset) " Lee Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Mikhail Lukianchikov @ 2026-07-17 12:10 UTC (permalink / raw)
  To: lee; +Cc: avermoal, linux-kernel, mfd

Sparse reports several warnings about incorrect type in assignment
(different base types) when building the i2c-viperboard.c driver:

  warning: incorrect type in assignment (different base types)
     expected unsigned short [usertype] addr
     got restricted __le16 [usertype]

Added missing change.

Signed-off-by: Mikhail Lukianchikov <avermoal@gmail.com>
---
Change in v2:
  - Added missing change in vprbrd_i2c_write_hdr structure.

 include/linux/mfd/viperboard.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/mfd/viperboard.h b/include/linux/mfd/viperboard.h
index 0557667fe544..5761ebdc81b3 100644
--- a/include/linux/mfd/viperboard.h
+++ b/include/linux/mfd/viperboard.h
@@ -47,7 +47,7 @@
 
 struct vprbrd_i2c_write_hdr {
 	u8 cmd;
-	u16 addr;
+	__le16 addr;
 	u8 len1;
 	u8 len2;
 	u8 last;
@@ -57,15 +57,15 @@ struct vprbrd_i2c_write_hdr {
 
 struct vprbrd_i2c_read_hdr {
 	u8 cmd;
-	u16 addr;
+	__le16 addr;
 	u8 len0;
 	u8 len1;
 	u8 len2;
 	u8 len3;
 	u8 len4;
 	u8 len5;
-	u16 tf1;                        /* transfer 1 length */
-	u16 tf2;                        /* transfer 2 length */
+	__le16 tf1;                        /* transfer 1 length */
+	__le16 tf2;                        /* transfer 2 length */
 } __packed;
 
 struct vprbrd_i2c_status {
@@ -89,7 +89,7 @@ struct vprbrd_i2c_addr_msg {
 	u8 cmd;
 	u8 addr;
 	u8 unknown1;
-	u16 len;
+	__le16 len;
 	u8 unknown2;
 	u8 unknown3;
 } __packed;
-- 
2.55.0


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

* Re: (subset) [PATCH v2] mfd: viperboard: fix native fields type in structures as little-endiand
  2026-07-17 12:10 ` [PATCH v2] " Mikhail Lukianchikov
@ 2026-08-06 11:55   ` Lee Jones
  0 siblings, 0 replies; 3+ messages in thread
From: Lee Jones @ 2026-08-06 11:55 UTC (permalink / raw)
  To: lee, Mikhail Lukianchikov; +Cc: linux-kernel, mfd

On Fri, 17 Jul 2026 18:10:16 +0600, Mikhail Lukianchikov wrote:
> Sparse reports several warnings about incorrect type in assignment
> (different base types) when building the i2c-viperboard.c driver:
> 
>   warning: incorrect type in assignment (different base types)
>      expected unsigned short [usertype] addr
>      got restricted __le16 [usertype]
> 
> [...]

Applied, thanks!

[1/1] mfd: viperboard: fix native fields type in structures as little-endiand
      commit: d97a98f434af98c1a46f5dc98b0f861187c52f63

--
Lee Jones [李琼斯]


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

end of thread, other threads:[~2026-08-06 11:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 14:52 [PATCH v1] mfd: viperboard: fix native fields type in structures as little-endiand Mikhail Lukianchikov
2026-07-17 12:10 ` [PATCH v2] " Mikhail Lukianchikov
2026-08-06 11:55   ` (subset) " Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®