aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2015-10-12 14:24:30 -0400
committerMark Brown <broonie@kernel.org>2015-10-12 14:24:30 -0400
commitb3961e8703cbacf45116aea44f0c1cdaf8c8b40c (patch)
tree60affcbdc811a4c6af887659012aa95982e1b9e7 /drivers/base
parentba5890a0c7576776ada71a21d95833a2281695e2 (diff)
parent77792b11409c9270d98e604b4314b85ce886ac7d (diff)
Merge tag 'regmap-offload-update-bits' into regmap-next
regmap: Allow buses to provide a custom update_bits() operation Some buses provide a native _update_bits() operation which for uncached registers is faster than doing a read/modify/write cycle as it is a single bus transaction. Add support for implementing this to regmap. # gpg: Signature made Tue 06 Oct 2015 16:21:47 BST using RSA key ID 5D5487D0 # gpg: Oops: keyid_from_fingerprint: no pubkey # gpg: Oops: keyid_from_fingerprint: no pubkey # gpg: key 00000000 occurs more than once in the trustdb # gpg: key 16005C11: no public key for trusted key - skipped # gpg: key 16005C11 marked as ultimately trusted # gpg: Good signature from "Mark Brown <broonie@sirena.org.uk>" # gpg: aka "Mark Brown <broonie@debian.org>" # gpg: aka "Mark Brown <broonie@kernel.org>" # gpg: aka "Mark Brown <broonie@tardis.ed.ac.uk>" # gpg: aka "Mark Brown <broonie@linaro.org>" # gpg: aka "Mark Brown <Mark.Brown@linaro.org>"
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/internal.h2
-rw-r--r--drivers/base/regmap/regmap.c29
2 files changed, 20 insertions, 11 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index cc557886ab23..628ad7ac078b 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -98,6 +98,8 @@ struct regmap {
98 98
99 int (*reg_read)(void *context, unsigned int reg, unsigned int *val); 99 int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
100 int (*reg_write)(void *context, unsigned int reg, unsigned int val); 100 int (*reg_write)(void *context, unsigned int reg, unsigned int val);
101 int (*reg_update_bits)(void *context, unsigned int reg,
102 unsigned int mask, unsigned int val);
101 103
102 bool defer_caching; 104 bool defer_caching;
103 105
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index afaf56200674..8cd155af3d63 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -619,6 +619,7 @@ struct regmap *__regmap_init(struct device *dev,
619 goto skip_format_initialization; 619 goto skip_format_initialization;
620 } else { 620 } else {
621 map->reg_read = _regmap_bus_read; 621 map->reg_read = _regmap_bus_read;
622 map->reg_update_bits = bus->reg_update_bits;
622 } 623 }
623 624
624 reg_endian = regmap_get_reg_endian(bus, config); 625 reg_endian = regmap_get_reg_endian(bus, config);
@@ -2509,20 +2510,26 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
2509 int ret; 2510 int ret;
2510 unsigned int tmp, orig; 2511 unsigned int tmp, orig;
2511 2512
2512 ret = _regmap_read(map, reg, &orig); 2513 if (change)
2513 if (ret != 0) 2514 *change = false;
2514 return ret;
2515 2515
2516 tmp = orig & ~mask; 2516 if (regmap_volatile(map, reg) && map->reg_update_bits) {
2517 tmp |= val & mask; 2517 ret = map->reg_update_bits(map->bus_context, reg, mask, val);
2518 2518 if (ret == 0 && change)
2519 if (force_write || (tmp != orig)) {
2520 ret = _regmap_write(map, reg, tmp);
2521 if (change)
2522 *change = true; 2519 *change = true;
2523 } else { 2520 } else {
2524 if (change) 2521 ret = _regmap_read(map, reg, &orig);
2525 *change = false; 2522 if (ret != 0)
2523 return ret;
2524
2525 tmp = orig & ~mask;
2526 tmp |= val & mask;
2527
2528 if (force_write || (tmp != orig)) {
2529 ret = _regmap_write(map, reg, tmp);
2530 if (ret == 0 && change)
2531 *change = true;
2532 }
2526 } 2533 }
2527 2534
2528 return ret; 2535 return ret;