Skip to content

Commit 0c9d2eb

Browse files
committed
regmap: Account for register length in SMBus I/O limits
The SMBus I2C buses have limits on the size of transfers they can do but do not factor in the register length meaning we may try to do a transfer longer than our length limit, the core will not take care of this. Future changes will factor this out into the core but there are a number of users that assume current behaviour so let's just do something conservative here. This does not take account padding bits but practically speaking these are very rarely if ever used on I2C buses given that they generally run slowly enough to mean there's no issue. Cc: stable@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Xu Yilun <yilun.xu@intel.com> Link: https://lore.kernel.org/r/20230712-regmap-max-transfer-v1-2-80e2aed22e83@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent bc64734 commit 0c9d2eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/base/regmap/regmap-i2c.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ static int regmap_i2c_smbus_i2c_read(void *context, const void *reg,
242242
static const struct regmap_bus regmap_i2c_smbus_i2c_block = {
243243
.write = regmap_i2c_smbus_i2c_write,
244244
.read = regmap_i2c_smbus_i2c_read,
245-
.max_raw_read = I2C_SMBUS_BLOCK_MAX,
246-
.max_raw_write = I2C_SMBUS_BLOCK_MAX,
245+
.max_raw_read = I2C_SMBUS_BLOCK_MAX - 1,
246+
.max_raw_write = I2C_SMBUS_BLOCK_MAX - 1,
247247
};
248248

249249
static int regmap_i2c_smbus_i2c_write_reg16(void *context, const void *data,
@@ -299,8 +299,8 @@ static int regmap_i2c_smbus_i2c_read_reg16(void *context, const void *reg,
299299
static const struct regmap_bus regmap_i2c_smbus_i2c_block_reg16 = {
300300
.write = regmap_i2c_smbus_i2c_write_reg16,
301301
.read = regmap_i2c_smbus_i2c_read_reg16,
302-
.max_raw_read = I2C_SMBUS_BLOCK_MAX,
303-
.max_raw_write = I2C_SMBUS_BLOCK_MAX,
302+
.max_raw_read = I2C_SMBUS_BLOCK_MAX - 2,
303+
.max_raw_write = I2C_SMBUS_BLOCK_MAX - 2,
304304
};
305305

306306
static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c,

0 commit comments

Comments
 (0)