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

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

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 4c691664
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -583,17 +583,18 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
		       unsigned int mask, unsigned int val)
{
	int ret;
	unsigned int tmp;
	unsigned int tmp, orig;

	mutex_lock(&map->lock);

	ret = _regmap_read(map, reg, &tmp);
	ret = _regmap_read(map, reg, &orig);
	if (ret != 0)
		goto out;

	tmp &= ~mask;
	tmp = orig & ~mask;
	tmp |= val & mask;

	if (tmp != orig)
		ret = _regmap_write(map, reg, tmp);

out: