i2c: diolan-u2c: Use __le32 when reading serial number
Subsystems (2)
PATCH v3 1/1 i2c: diolan-u2c: Use __le32 when reading serial number
Sparse reports:
drivers/i2c/busses/i2c-diolan-u2c.c:290:26: warning:
cast to restricted __le32
Cast the serial-number buffer pointer to __le32 before passing it to le32_to_cpu(). This makes the byte-order conversion explicit and silences the sparse warning.
---
Changes in v3:
- Cast the serial-number buffer pointer to __le32 before passing it to le32_to_cpu(), as suggested by Guenter Roeck.
- Keep the serial variable and do not use get_unaligned_le32().
- Reword the commit message to accurately describe the motivation.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Reword the commit message to accurately describe the motivation.
- The serial-number buffer is naturally aligned; do not claim that the
existing access may be unaligned.
- Focus on fixing the sparse "cast to restricted __le32" warning.
- Link to v1: https://patch.msgid.link/[email protected]
To: Guenter Roeck <[email protected]>
To: Andi Shyti <[email protected]>
Cc: [email protected]
--- drivers/i2c/busses/i2c-diolan-u2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-diolan-u2c.c +1 -1
@@ -287,7 +287,7 @@ static void diolan_get_serial(struct i2c_diolan_u2c *dev) ret =diolan_usb_cmd (dev,CMD_GET_SERIAL , true);if (ret >=4 ) { - serial =le32_to_cpu (*(u32 *)dev->ibuffer); + serial =le32_to_cpu (*(__le32 *)dev->ibuffer);dev_info (&dev->interface->dev,"Diolan U2C serial number %u\n" , serial); }
---
base-commit: f4585067150b85e33f60876149a6e742928da75e
change-id: 20261127-i2c-diolan-u2c-unaligned-2599ede88a92
Best regards,
Signature · 1 line
Felix Huang <[email protected]>
Quoted 4 lines · On 11/28/26 07:39, Felix Huang via B4 Relay wrote:
From: Felix Huang <[email protected]>
Sparse reports:
Quoted 8 lines
drivers/i2c/busses/i2c-diolan-u2c.c:290:26: warning:
cast to restricted__le32Cast the serial-number buffer pointer to
__le32before passing it tole32_to_cpu(). This makes the byte-order conversion explicit and silences the sparse warning.Signed-off-by Felix Huang <[email protected]>
Quoted 43 lines
---
Changes in v3:
- Cast the serial-number buffer pointer to__le32before passing it tole32_to_cpu(), as suggested by Guenter Roeck.
- Keep the serial variable and do not useget_unaligned_le32().
- Reword the commit message to accurately describe the motivation.
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- Reword the commit message to accurately describe the motivation.
- The serial-number buffer is naturally aligned; do not claim that the
existing access may be unaligned.
- Focus on fixing the sparse "cast to restricted__le32" warning.
- Link to v1: https://patch.msgid.link/[email protected]To: Guenter Roeck <[email protected]>
To: Andi Shyti <[email protected]>
Cc: [email protected]--- drivers/i2c/busses/i2c-diolan-u2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/busses/i2c-diolan-u2c.c +1
-2@@ -287,7 +287,7 @@ static void diolan_get_serial(struct i2c_diolan_u2c *dev) ret =diolan_usb_cmd (dev,CMD_GET_SERIAL , true);if (ret >=4 ) { - serial =le32_to_cpu (*(u32 *)dev->ibuffer); + serial =le32_to_cpu (*(__le32 *)dev->ibuffer);dev_info (&dev->interface->dev,"Diolan U2C serial number %u\n" , serial); } ---base-commit:
f4585067150b85e33f60876149a6e742928da75e
change-id: 20261127-i2c-diolan-u2c-unaligned-2599ede88a92Best regards,
--
Felix Huang <[email protected]>
Hi Felix,
Quoted 10 lines · Felix Huang
Sparse reports:
drivers/i2c/busses/i2c-diolan-u2c.c:290:26: warning:
cast to restricted__le32Cast the serial-number buffer pointer to
__le32before passing it tole32_to_cpu(). This makes the byte-order conversion explicit and silences the sparse warning.Signed-off-by Felix Huang <[email protected]>
pushed to i2c/i2c.
Thanks,
Andi