Commit cc6a8d69 authored by Lucas Tanure's avatar Lucas Tanure Committed by Mark Brown

regmap: debugfs: Jump to the next readable register

Improve the speed of the loop jumping to the next
available register
Signed-off-by: default avatarLucas Tanure <tanureal@opensource.cirrus.com>
Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a1c67d65
...@@ -195,6 +195,28 @@ static inline void regmap_calc_tot_len(struct regmap *map, ...@@ -195,6 +195,28 @@ static inline void regmap_calc_tot_len(struct regmap *map,
} }
} }
static int regmap_next_readable_reg(struct regmap *map, int reg)
{
struct regmap_debugfs_off_cache *c;
int ret = -EINVAL;
if (regmap_printable(map, reg + map->reg_stride)) {
ret = reg + map->reg_stride;
} else {
mutex_lock(&map->cache_lock);
list_for_each_entry(c, &map->debugfs_off_cache, list) {
if (reg > c->max_reg)
continue;
if (reg < c->base_reg) {
ret = c->base_reg;
break;
}
}
mutex_unlock(&map->cache_lock);
}
return ret;
}
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)
...@@ -218,9 +240,8 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, ...@@ -218,9 +240,8 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
/* 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);
for (i = start_reg; i <= to; i += map->reg_stride) { for (i = start_reg; i >= 0 && i <= to;
if (!regmap_printable(map, i)) i = regmap_next_readable_reg(map, i)) {
continue;
/* If we're in the region the user is trying to read */ /* If we're in the region the user is trying to read */
if (p >= *ppos) { if (p >= *ppos) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment