mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 13:49:24 -04:00
regmap: fix writes to non incrementing registers
commit 2e31aab08bad0d4ee3d3d890a7b74cb6293e0a41 upstream.
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: 8b9f9d4dc5 ("regmap: verify if register is writeable before writing operations")
Signed-off-by: Ben Whitten <ben.whitten@gmail.com>
Link: https://lore.kernel.org/r/20200118205625.14532-1-ben.whitten@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4eb12ef749
commit
3b9586e82c
1 changed files with 12 additions and 5 deletions
|
|
@ -1488,11 +1488,18 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
|
|||
|
||||
WARN_ON(!map->bus);
|
||||
|
||||
/* Check for unwritable registers before we start */
|
||||
for (i = 0; i < val_len / map->format.val_bytes; i++)
|
||||
if (!regmap_writeable(map,
|
||||
reg + regmap_get_offset(map, i)))
|
||||
return -EINVAL;
|
||||
/* Check for unwritable or noinc registers in range
|
||||
* before we start
|
||||
*/
|
||||
if (!regmap_writeable_noinc(map, reg)) {
|
||||
for (i = 0; i < val_len / map->format.val_bytes; i++) {
|
||||
unsigned int element =
|
||||
reg + regmap_get_offset(map, i);
|
||||
if (!regmap_writeable(map, element) ||
|
||||
regmap_writeable_noinc(map, element))
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!map->cache_bypass && map->format.parse_val) {
|
||||
unsigned int ival;
|
||||
|
|
|
|||
Loading…
Reference in a new issue