summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-18 16:03:50 +0000
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-20 20:56:38 +0000
commitd91e8db2c3bbe8ef0e2f3e1a6ff5b31a8d53ef16 (patch)
tree2bcc299fa62738407b5e25483230f7249f0d016d /drivers/base
parent4c691664583ef6a91f9ed0e08a75fbd30a5ffd5c (diff)
downloadlinux-d91e8db2c3bbe8ef0e2f3e1a6ff5b31a8d53ef16.tar.gz
linux-d91e8db2c3bbe8ef0e2f3e1a6ff5b31a8d53ef16.tar.bz2
linux-d91e8db2c3bbe8ef0e2f3e1a6ff5b31a8d53ef16.zip
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: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e533368e5598..10ecbba32e10 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -583,18 +583,19 @@ 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;
- ret = _regmap_write(map, reg, tmp);
+ if (tmp != orig)
+ ret = _regmap_write(map, reg, tmp);
out:
mutex_unlock(&map->lock);