mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 04:43:52 -04:00
Merge tag 'regmap-fix-v6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap fix from Mark Brown: "A fix for how we handle controller constraints on SPI message sizes, only impacting systems with SPI controllers with very low limits like the AMD controller used in the Steam Deck" * tag 'regmap-fix-v6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: spi: Reserve space for register address/padding
This commit is contained in:
@@ -113,6 +113,7 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi,
|
||||
const struct regmap_config *config)
|
||||
{
|
||||
size_t max_size = spi_max_transfer_size(spi);
|
||||
size_t max_msg_size, reg_reserve_size;
|
||||
struct regmap_bus *bus;
|
||||
|
||||
if (max_size != SIZE_MAX) {
|
||||
@@ -120,9 +121,16 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi,
|
||||
if (!bus)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
max_msg_size = spi_max_message_size(spi);
|
||||
reg_reserve_size = config->reg_bits / BITS_PER_BYTE
|
||||
+ config->pad_bits / BITS_PER_BYTE;
|
||||
if (max_size + reg_reserve_size > max_msg_size)
|
||||
max_size -= reg_reserve_size;
|
||||
|
||||
bus->free_on_exit = true;
|
||||
bus->max_raw_read = max_size;
|
||||
bus->max_raw_write = max_size;
|
||||
|
||||
return bus;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user