提交 d91e8db2 编写于 作者: M Mark Brown

regmap: Suppress noop writes in regmap_update_bits()

If the new register value is identical to the original one then suppress
the write to the hardware in regmap_update_bits(), saving some I/O cost.
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 4c691664
...@@ -583,17 +583,18 @@ int regmap_update_bits(struct regmap *map, unsigned int reg, ...@@ -583,17 +583,18 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val) unsigned int mask, unsigned int val)
{ {
int ret; int ret;
unsigned int tmp; unsigned int tmp, orig;
mutex_lock(&map->lock); mutex_lock(&map->lock);
ret = _regmap_read(map, reg, &tmp); ret = _regmap_read(map, reg, &orig);
if (ret != 0) if (ret != 0)
goto out; goto out;
tmp &= ~mask; tmp = orig & ~mask;
tmp |= val & mask; tmp |= val & mask;
if (tmp != orig)
ret = _regmap_write(map, reg, tmp); ret = _regmap_write(map, reg, tmp);
out: out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册