We will add a new user of this calculate in a follow-up commit, so make it available as a global function. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- drivers/base/regmap/regmap.c | 9 +++++++-- include/regmap.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 19f5356105f6..da20dc05828d 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -401,6 +401,12 @@ static struct cdev_operations regmap_fops = { .write = regmap_cdev_write, }; +size_t regmap_size_bytes(struct regmap *map) +{ + return regmap_round_val_bytes(map) * (map->max_register + 1) / + map->reg_stride; +} + /* * regmap_register_cdev - register a devfs file for a regmap * @@ -428,8 +434,7 @@ int regmap_register_cdev(struct regmap *map, const char *name) map->cdev.name = xstrdup(dev_name(map->dev)); } - map->cdev.size = regmap_round_val_bytes(map) * (map->max_register + 1) / - map->reg_stride; + map->cdev.size = regmap_size_bytes(map); map->cdev.dev = map->dev; map->cdev.ops = ®map_fops; diff --git a/include/regmap.h b/include/regmap.h index 8f191c87cfcb..986ed391ab28 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -204,6 +204,8 @@ static inline int regmap_clear_bits(struct regmap *map, return regmap_update_bits(map, reg, bits, 0); } +size_t regmap_size_bytes(struct regmap *map); + /** * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs * -- 2.30.2