diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-08 08:35:58 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-08 15:52:46 -0500 |
commit | 95f971c745a343255744703dc4ae8d78508519cc (patch) | |
tree | fd2e65fe41219457c64eaa62635bb8dfa65b0ddf | |
parent | 5a1d6d172bc8a3ecf29add6c84d047025cb71566 (diff) |
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: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | drivers/base/regmap/regmap-debugfs.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index e8d15db2f126..9099cd33fbcb 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c | |||
@@ -56,6 +56,19 @@ static const struct file_operations regmap_name_fops = { | |||
56 | .llseek = default_llseek, | 56 | .llseek = default_llseek, |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static void regmap_debugfs_free_dump_cache(struct regmap *map) | ||
60 | { | ||
61 | struct regmap_debugfs_off_cache *c; | ||
62 | |||
63 | while (!list_empty(&map->debugfs_off_cache)) { | ||
64 | c = list_first_entry(&map->debugfs_off_cache, | ||
65 | struct regmap_debugfs_off_cache, | ||
66 | list); | ||
67 | list_del(&c->list); | ||
68 | kfree(c); | ||
69 | } | ||
70 | } | ||
71 | |||
59 | /* | 72 | /* |
60 | * Work out where the start offset maps into register numbers, bearing | 73 | * Work out where the start offset maps into register numbers, bearing |
61 | * in mind that we suppress hidden registers. | 74 | * in mind that we suppress hidden registers. |
@@ -91,8 +104,10 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, | |||
91 | /* No cache entry? Start a new one */ | 104 | /* No cache entry? Start a new one */ |
92 | if (!c) { | 105 | if (!c) { |
93 | c = kzalloc(sizeof(*c), GFP_KERNEL); | 106 | c = kzalloc(sizeof(*c), GFP_KERNEL); |
94 | if (!c) | 107 | if (!c) { |
95 | break; | 108 | regmap_debugfs_free_dump_cache(map); |
109 | return base; | ||
110 | } | ||
96 | c->min = p; | 111 | c->min = p; |
97 | c->base_reg = i; | 112 | c->base_reg = i; |
98 | } | 113 | } |
@@ -388,16 +403,8 @@ void regmap_debugfs_init(struct regmap *map, const char *name) | |||
388 | 403 | ||
389 | void regmap_debugfs_exit(struct regmap *map) | 404 | void regmap_debugfs_exit(struct regmap *map) |
390 | { | 405 | { |
391 | struct regmap_debugfs_off_cache *c; | ||
392 | |||
393 | debugfs_remove_recursive(map->debugfs); | 406 | debugfs_remove_recursive(map->debugfs); |
394 | while (!list_empty(&map->debugfs_off_cache)) { | 407 | regmap_debugfs_free_dump_cache(map); |
395 | c = list_first_entry(&map->debugfs_off_cache, | ||
396 | struct regmap_debugfs_off_cache, | ||
397 | list); | ||
398 | list_del(&c->list); | ||
399 | kfree(c); | ||
400 | } | ||
401 | kfree(map->debugfs_name); | 408 | kfree(map->debugfs_name); |
402 | } | 409 | } |
403 | 410 | ||