Skip to content

Commit 2e31aab

Browse files
BWhittenbroonie
authored andcommitted
regmap: fix writes to non incrementing registers
When checking if a register block is writable we must ensure that the block does not start with or contain a non incrementing register. Fixes: 8b9f9d4 ("regmap: verify if register is writeable before writing operations") Signed-off-by: Ben Whitten <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 50816a4 commit 2e31aab

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/base/regmap/regmap.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,11 +1488,18 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
14881488

14891489
WARN_ON(!map->bus);
14901490

1491-
/* Check for unwritable registers before we start */
1492-
for (i = 0; i < val_len / map->format.val_bytes; i++)
1493-
if (!regmap_writeable(map,
1494-
reg + regmap_get_offset(map, i)))
1495-
return -EINVAL;
1491+
/* Check for unwritable or noinc registers in range
1492+
* before we start
1493+
*/
1494+
if (!regmap_writeable_noinc(map, reg)) {
1495+
for (i = 0; i < val_len / map->format.val_bytes; i++) {
1496+
unsigned int element =
1497+
reg + regmap_get_offset(map, i);
1498+
if (!regmap_writeable(map, element) ||
1499+
regmap_writeable_noinc(map, element))
1500+
return -EINVAL;
1501+
}
1502+
}
14961503

14971504
if (!map->cache_bypass && map->format.parse_val) {
14981505
unsigned int ival;

0 commit comments

Comments
 (0)