Commit 95f971c7 authored by Mark Brown's avatar Mark Brown

regmap: debugfs: Discard the cache if we fail to allocate an entry

Rather than trying to soldier on with a partially allocated cache just
throw the cache away and pretend we don't have one in case we can get a
full cache next time around.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 5a1d6d17
...@@ -56,6 +56,19 @@ static const struct file_operations regmap_name_fops = { ...@@ -56,6 +56,19 @@ static const struct file_operations regmap_name_fops = {
.llseek = default_llseek, .llseek = default_llseek,
}; };
static void regmap_debugfs_free_dump_cache(struct regmap *map)
{
struct regmap_debugfs_off_cache *c;
while (!list_empty(&map->debugfs_off_cache)) {
c = list_first_entry(&map->debugfs_off_cache,
struct regmap_debugfs_off_cache,
list);
list_del(&c->list);
kfree(c);
}
}
/* /*
* Work out where the start offset maps into register numbers, bearing * Work out where the start offset maps into register numbers, bearing
* in mind that we suppress hidden registers. * in mind that we suppress hidden registers.
...@@ -91,8 +104,10 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, ...@@ -91,8 +104,10 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
/* No cache entry? Start a new one */ /* No cache entry? Start a new one */
if (!c) { if (!c) {
c = kzalloc(sizeof(*c), GFP_KERNEL); c = kzalloc(sizeof(*c), GFP_KERNEL);
if (!c) if (!c) {
break; regmap_debugfs_free_dump_cache(map);
return base;
}
c->min = p; c->min = p;
c->base_reg = i; c->base_reg = i;
} }
...@@ -388,16 +403,8 @@ void regmap_debugfs_init(struct regmap *map, const char *name) ...@@ -388,16 +403,8 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
void regmap_debugfs_exit(struct regmap *map) void regmap_debugfs_exit(struct regmap *map)
{ {
struct regmap_debugfs_off_cache *c;
debugfs_remove_recursive(map->debugfs); debugfs_remove_recursive(map->debugfs);
while (!list_empty(&map->debugfs_off_cache)) { regmap_debugfs_free_dump_cache(map);
c = list_first_entry(&map->debugfs_off_cache,
struct regmap_debugfs_off_cache,
list);
list_del(&c->list);
kfree(c);
}
kfree(map->debugfs_name); kfree(map->debugfs_name);
} }
......
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