Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb4cb76f authored by Mark Brown's avatar Mark Brown
Browse files

regmap: cache: Store caches in native register format where possible



This allows the cached data to be sent directly to the device when
we sync it.

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 8a819ff8
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static int regcache_hw_init(struct regmap *map)
		tmp_buf = kmalloc(map->cache_size_raw, GFP_KERNEL);
		if (!tmp_buf)
			return -EINVAL;
		ret = regmap_bulk_read(map, 0, tmp_buf,
		ret = regmap_raw_read(map, 0, tmp_buf,
				      map->num_reg_defaults_raw);
		map->cache_bypass = cache_bypass;
		if (ret < 0) {
@@ -421,6 +421,13 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
	if (regcache_get_val(map, base, idx) == val)
		return true;

	/* Use device native format if possible */
	if (map->format.format_val) {
		map->format.format_val(base + (map->cache_word_size * idx),
				       val, 0);
		return false;
	}

	switch (map->cache_word_size) {
	case 1: {
		u8 *cache = base;
@@ -449,6 +456,11 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,
	if (!base)
		return -EINVAL;

	/* Use device native format if possible */
	if (map->format.parse_val)
		return map->format.parse_val(base +
					     (map->cache_word_size * idx));

	switch (map->cache_word_size) {
	case 1: {
		const u8 *cache = base;