summaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/internal.h
diff options
context:
space:
mode:
authorXiubo Li <lixiubo@cmss.chinamobile.com>2016-01-04 18:00:33 +0800
committerMark Brown <broonie@kernel.org>2016-02-20 01:11:23 +0900
commitca747be22fa57bbee50e34c220401160e8f2a07f (patch)
tree402e74745cc42672333891ca30232716c1b8eafe /drivers/base/regmap/internal.h
parent92e963f50fc74041b5e9e744c330dca48e04f08d (diff)
downloadop-kernel-dev-ca747be22fa57bbee50e34c220401160e8f2a07f.zip
op-kernel-dev-ca747be22fa57bbee50e34c220401160e8f2a07f.tar.gz
regmap: core: Introduce register stride order
Since the register stride should always equal to 2^N, and bit rotation is much faster than multiplication and division. So introducing the stride order and using bit rotation to get the offset of the register from the index to improve the performance. Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/base/regmap/internal.h')
-rw-r--r--drivers/base/regmap/internal.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 3df9770..c22b04b2 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -110,6 +110,7 @@ struct regmap {
/* number of bits to (left) shift the reg value when formatting*/
int reg_shift;
int reg_stride;
+ int reg_stride_order;
/* regcache specific members */
const struct regcache_ops *cache_ops;
@@ -263,4 +264,13 @@ static inline const char *regmap_name(const struct regmap *map)
return map->name;
}
+static inline unsigned int regmap_get_offset(const struct regmap *map,
+ unsigned int index)
+{
+ if (map->reg_stride_order >= 0)
+ return index << map->reg_stride_order;
+ else
+ return index * map->reg_stride;
+}
+
#endif
OpenPOWER on IntegriCloud