Skip to contentSkip to conversation

misc: eeprom/idt_89hpesx: Convert data structures to LE explicitly

PATCH In review Dawei Li 2 participants 3 messages Jan 31, 2024 – Feb 14, 2024 Char and misc drivers

lore
Share & tools
lore

Dawei Li

author
#0 lore raw

PATCH v2 1/1 misc: eeprom/idt_89hpesx: Convert data structures to LE explicitly

Kernel test robot reports following sparse warnings:

Quoted 1 line
Quoted 1 line

drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse: sparse:

incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype]
memaddr @@ got restricted __le16 [usertype] @@

drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:
expected unsigned short [addressable] [assigned] [usertype] memaddr

drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:
restricted __le16 [usertype]

.....

For data structures needs cpu_to_le* conversion, their prototype need to be declared with __le* explicitly.

Declare data structures to __le* explicitly to address the issue:
- struct idt_eeprom_seq::memaddr
- struct idt_csr_seq::csraddr
- struct idt_csr_seq::data

---
v1 -> v2:
- Add sparse warning info from Kernel test robot.
- Remove Fixes & cc stable tag.
- Add Reviewed-by from Serge.

v1: https://lore.kernel.org/all/[email protected]/

 drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/misc/eeprom/idt_89hpesx.c +3 -3
index d807d08e2614..327afb866b21 100644
@@ -129,7 +129,7 @@ struct idt_smb_seq {
 struct idt_eeprom_seq {
 	u8 cmd;
 	u8 eeaddr;
-	u16 memaddr;
+	__le16 memaddr;
 	u8 data;
 } __packed;
 
@@ -141,8 +141,8 @@ struct idt_eeprom_seq {
  */
 struct idt_csr_seq {
 	u8 cmd;
-	u16 csraddr;
-	u32 data;
+	__le16 csraddr;
+	__le32 data;
 } __packed;
 
 /*
Signature · 1 line
2.27.0
author
#1 lore raw

Hi Greg,

Sorry for bothering.

Quoted 27 lines · Dawei Li

Kernel test robot reports following sparse warnings:

Quoted 1 line
Quoted 1 line

drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse: sparse:

incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype]
memaddr @@ got restricted __le16 [usertype] @@

   drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:
   expected unsigned short [addressable] [assigned] [usertype]
   memaddr

   drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:
   restricted __le16 [usertype]

   .....

For data structures needs cpu_to_le* conversion, their prototype need to be declared with __le* explicitly.

Declare data structures to __le* explicitly to address the issue:
- struct idt_eeprom_seq::memaddr
- struct idt_csr_seq::csraddr
- struct idt_csr_seq::data

Quoted 8 lines

---
v1 -> v2:
- Add sparse warning info from Kernel test robot.
- Remove Fixes & cc stable tag.
- Add Reviewed-by from Serge.

v1: https://lore.kernel.org/all/[email protected]/

Any comments on this?

Thanks,

Dawei

Quoted 30 lines
 drivers/misc/eeprom/idt_89hpesx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/misc/eeprom/idt_89hpesx.c +3 -3
index d807d08e2614..327afb866b21 100644
@@ -129,7 +129,7 @@ struct idt_smb_seq {
 struct idt_eeprom_seq {
 	u8 cmd;
 	u8 eeaddr;
-	u16 memaddr;
+	__le16 memaddr;
 	u8 data;
 } __packed;
 
@@ -141,8 +141,8 @@ struct idt_eeprom_seq {
  */
 struct idt_csr_seq {
 	u8 cmd;
-	u16 csraddr;
-	u32 data;
+	__le16 csraddr;
+	__le32 data;
 } __packed;
 
 /*
Signature · 1 line
2.27.0
maintainer Acked-by on v2 1/1
#2 lore raw
In reply to Dawei Li
Quoted 23 lines · Dawei Li

Kernel test robot reports following sparse warnings:

Quoted 1 line
Quoted 1 line

drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse: sparse:

incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype]
memaddr @@ got restricted __le16 [usertype] @@

   drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:
   expected unsigned short [addressable] [assigned] [usertype]
   memaddr

   drivers/misc/eeprom/idt_89hpesx.c:599:31: sparse:
   restricted __le16 [usertype]

   .....

For data structures needs cpu_to_le* conversion, their prototype need to be declared with __le* explicitly.

Declare data structures to __le* explicitly to address the issue:
- struct idt_eeprom_seq::memaddr
- struct idt_csr_seq::csraddr
- struct idt_csr_seq::data

Quoted 5 lines

Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/