Commit b1d27aa3 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 26b12249 f5723cfc
...@@ -113,6 +113,7 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi, ...@@ -113,6 +113,7 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi,
const struct regmap_config *config) const struct regmap_config *config)
{ {
size_t max_size = spi_max_transfer_size(spi); size_t max_size = spi_max_transfer_size(spi);
size_t max_msg_size, reg_reserve_size;
struct regmap_bus *bus; struct regmap_bus *bus;
if (max_size != SIZE_MAX) { if (max_size != SIZE_MAX) {
...@@ -120,9 +121,16 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi, ...@@ -120,9 +121,16 @@ static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi,
if (!bus) if (!bus)
return ERR_PTR(-ENOMEM); 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->free_on_exit = true;
bus->max_raw_read = max_size; bus->max_raw_read = max_size;
bus->max_raw_write = max_size; bus->max_raw_write = max_size;
return bus; return bus;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment