regmap: Account for register length in SMBus I/O limits
authorMark Brown <broonie@kernel.org>
Wed, 12 Jul 2023 11:16:40 +0000 (12:16 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2023 06:50:26 +0000 (08:50 +0200)
commit3e463a4f380115c522a5a021a805fa91ccc2df99
treedde0a183233512d18b7f7adecfa8f7bbca3d8245
parentef7ad397fb8cf3d7e9b5bb9ed8ba11945ee0d97f
regmap: Account for register length in SMBus I/O limits

commit 0c9d2eb5e94792fe64019008a04d4df5e57625af upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/regmap/regmap-i2c.c