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>
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user