regmap: Fix for v6.7
One fix here, for an interaction between noinc registers and caches - if a device uses noinc registers (which is rare) then we could corrupt registers after the noinc register in the cache. -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmVKGw8ACgkQJNaLcl1U h9C8Bwf/U2a00UtJqvg+deoXHQ/7QY8w093DnHxdTLyUcDvwffbfTMrPPOmPtRLh 1OYTtPPAgcF2PjyMaazHON2Y3a1/jPLEyjfRI3UmMWoVCVObUzh30ARASdRlvZj0 1bnj88v32W2hFu/TuUPVVii3g2qH3XccEvX/JaNm0yG9lBHfugPGbVOI2S+MzWL9 iFq+nYyqi6RzD7gq99ZaoA6UdacbCyPWgvHKxoZqhknTlX/KQQDdBlq2alhmbOoU lW3t9dwtZlcoskSTmKDI7Ukz0EnRvK1fcrkhZ/3XrQl349eLmtqcG7rM/ZMoORqL wx8eoxNCyCDnjxV+QfEL6SSQEX+8Mg== =M81g -----END PGP SIGNATURE----- Merge tag 'regmap-fix-v6.7-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap Pull regmap fix from Mark Brown: "One fix here, for an interaction between noinc registers and caches. If a device uses noinc registers (which is rare) then we could corrupt registers after the noinc register in the cache" * tag 'regmap-fix-v6.7-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: prevent noinc writes from clobbering cache
This commit is contained in:
commit
eaec7c9892
@ -1620,17 +1620,19 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
|
||||
}
|
||||
|
||||
if (!map->cache_bypass && map->format.parse_val) {
|
||||
unsigned int ival;
|
||||
unsigned int ival, offset;
|
||||
int val_bytes = map->format.val_bytes;
|
||||
for (i = 0; i < val_len / val_bytes; i++) {
|
||||
ival = map->format.parse_val(val + (i * val_bytes));
|
||||
ret = regcache_write(map,
|
||||
reg + regmap_get_offset(map, i),
|
||||
ival);
|
||||
|
||||
/* Cache the last written value for noinc writes */
|
||||
i = noinc ? val_len - val_bytes : 0;
|
||||
for (; i < val_len; i += val_bytes) {
|
||||
ival = map->format.parse_val(val + i);
|
||||
offset = noinc ? 0 : regmap_get_offset(map, i / val_bytes);
|
||||
ret = regcache_write(map, reg + offset, ival);
|
||||
if (ret) {
|
||||
dev_err(map->dev,
|
||||
"Error in caching of register: %x ret: %d\n",
|
||||
reg + regmap_get_offset(map, i), ret);
|
||||
reg + offset, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user