regmap: debugfs: Factor out debugfs_tot_len calc into a function
In preparation to support the regmap debugfs ranges functionality factor this code out to a separate function. We'll need to ensure that the value has been correctly calculated from two separate places in the code. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
cf57d6071f
commit
4dd7c5531d
1 changed files with 14 additions and 8 deletions
|
@ -155,6 +155,19 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void regmap_calc_tot_len(struct regmap *map,
|
||||||
|
void *buf, size_t count)
|
||||||
|
{
|
||||||
|
/* Calculate the length of a fixed format */
|
||||||
|
if (!map->debugfs_tot_len) {
|
||||||
|
map->debugfs_reg_len = regmap_calc_reg_len(map->max_register,
|
||||||
|
buf, count);
|
||||||
|
map->debugfs_val_len = 2 * map->format.val_bytes;
|
||||||
|
map->debugfs_tot_len = map->debugfs_reg_len +
|
||||||
|
map->debugfs_val_len + 3; /* : \n */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
|
static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
|
||||||
unsigned int to, char __user *user_buf,
|
unsigned int to, char __user *user_buf,
|
||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
|
@ -173,14 +186,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Calculate the length of a fixed format */
|
regmap_calc_tot_len(map, buf, count);
|
||||||
if (!map->debugfs_tot_len) {
|
|
||||||
map->debugfs_reg_len = regmap_calc_reg_len(map->max_register,
|
|
||||||
buf, count);
|
|
||||||
map->debugfs_val_len = 2 * map->format.val_bytes;
|
|
||||||
map->debugfs_tot_len = map->debugfs_reg_len +
|
|
||||||
map->debugfs_val_len + 3; /* : \n */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Work out which register we're starting at */
|
/* Work out which register we're starting at */
|
||||||
start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
|
start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
|
||||||
|
|
Loading…
Add table
Reference in a new issue