Skip to content

Commit 92b46e9

Browse files
committed
regmap-i2c: fix sparse warning in regmap_smbus_word_write_reg16
i2c_smbus_write_word_data() expects a plain u16, but cpu_to_le16() returns __le16 (a sparse-restricted endian type). SMBus already defines byte ordering internally, so replace cpu_to_le16() with a plain (u16) cast. Fixes: bad4bd28abf4 ("regmap-i2c: add SMBus byte/word reg16 bus for adapters lacking I2C_FUNC_I2C") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202605161621.mY5zFh4D-lkp@intel.com/ Signed-off-by: Nishanth Sampath Kumar <nissampa@cisco.com>
1 parent 4497c63 commit 92b46e9

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From c8cc0e330e797005e3870bb45d1c5d387e1a5b61 Mon Sep 17 00:00:00 2001
2+
From: Nishanth Sampath Kumar <nissampa@cisco.com>
3+
Date: Tue, 19 May 2026 09:41:53 -0700
4+
Subject: [PATCH] regmap-i2c: fix sparse warning in
5+
regmap_smbus_word_write_reg16
6+
7+
i2c_smbus_write_word_data() expects a plain u16, but cpu_to_le16()
8+
returns __le16 (a sparse-restricted endian type), causing:
9+
10+
drivers/base/regmap/regmap-i2c.c:340: sparse: incorrect type in
11+
argument 3 (different base types)
12+
expected unsigned short [usertype] value
13+
got restricted __le16 [usertype]
14+
15+
SMBus already defines byte ordering internally, so cpu_to_le16() is
16+
wrong here. Replace it with a plain (u16) cast.
17+
18+
Fixes: bad4bd28abf4 ("regmap-i2c: add SMBus byte/word reg16 bus for adapters lacking I2C_FUNC_I2C")
19+
Reported-by: kernel test robot <lkp@intel.com>
20+
Closes: https://lore.kernel.org/oe-kbuild-all/202605161621.mY5zFh4D-lkp@intel.com/
21+
Signed-off-by: Nishanth Sampath Kumar <nissampa@cisco.com>
22+
---
23+
drivers/base/regmap/regmap-i2c.c | 2 +-
24+
1 file changed, 1 insertion(+), 1 deletion(-)
25+
26+
diff --git a/drivers/base/regmap/regmap-i2c.c b/drivers/base/regmap/regmap-i2c.c
27+
index 31e30dfced19..ae441fc63127 100644
28+
--- a/drivers/base/regmap/regmap-i2c.c
29+
+++ b/drivers/base/regmap/regmap-i2c.c
30+
@@ -337,7 +337,7 @@ static int regmap_smbus_word_write_reg16(void *context, const void *data,
31+
val = ((u8 *)data)[2];
32+
33+
return i2c_smbus_write_word_data(i2c, addr_hi,
34+
- cpu_to_le16(((u16)val << 8) | addr_lo));
35+
+ ((u16)val << 8) | addr_lo));
36+
}
37+
38+
static const struct regmap_bus regmap_smbus_byte_word_reg16 = {
39+
--
40+
2.25.1
41+

0 commit comments

Comments
 (0)