Skip to content

Commit

Permalink
regmap: drop cache if the bus transfer error
Browse files Browse the repository at this point in the history
regmap_write
->_regmap_raw_write
-->regcache_write first and than use map->bus->write to wirte i2c or spi
But if the i2c or spi transfer failed, But the cache is updated, So if I use
regmap_read will get the cache data which is not the real register value.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Elaine Zhang authored and Mark Brown committed Aug 18, 2016
1 parent b2c7f5d commit 815806e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
ret = map->bus->write(map->bus_context, buf, len);

kfree(buf);
} else if (ret != 0 && !map->cache_bypass && map->format.parse_val) {
regcache_drop_region(map, reg, reg + 1);
}

trace_regmap_hw_write_done(map, reg, val_len / map->format.val_bytes);
Expand Down

0 comments on commit 815806e

Please sign in to comment.