Commit eaec7c98 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'regmap-fix-v6.7-merge-window' of...

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
parents b8dd631f 984a4afd
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -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;
			}
		}