[PATCH 7/8] regmap: It is impossible to be given a NULL defaults cache

From: Dimitris Papastamos
Date: Fri Sep 02 2011 - 11:46:50 EST


In the new regcache API, it is impossible to hand a NULL defaults
cache to any of the cache compression types.

Signed-off-by: Dimitris Papastamos <dp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
---
drivers/base/regmap/regcache-lzo.c | 30 +++---------------------------
1 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/base/regmap/regcache-lzo.c b/drivers/base/regmap/regcache-lzo.c
index 9e0d7be..18e1a8c 100644
--- a/drivers/base/regmap/regcache-lzo.c
+++ b/drivers/base/regmap/regcache-lzo.c
@@ -125,32 +125,17 @@ static int regcache_lzo_init(struct regmap *map)
{
struct regcache_lzo_ctx **lzo_blocks;
size_t bmp_size;
- int ret, tofree, i, blksize, blkcount;
+ int ret, i, blksize, blkcount;
const char *p, *end;
unsigned long *sync_bmp;

ret = 0;

- /*
- * If we have not been given a default register cache
- * then allocate a dummy zero-ed out region, compress it
- * and remember to free it afterwards.
- */
- tofree = 0;
- if (!map->cache_defaults_raw) {
- map->cache_defaults_raw = kzalloc(map->cache_size_raw, GFP_KERNEL);
- if (!map->cache_defaults_raw)
- return -ENOMEM;
- tofree = 1;
- }
-
blkcount = regcache_lzo_block_count();
map->cache = kzalloc(blkcount * sizeof *lzo_blocks,
GFP_KERNEL);
- if (!map->cache) {
- ret = -ENOMEM;
- goto err_tofree;
- }
+ if (!map->cache)
+ return -ENOMEM;
lzo_blocks = map->cache;

/*
@@ -203,18 +188,9 @@ static int regcache_lzo_init(struct regmap *map)
lzo_blocks[i]->src_len;
}

- if (tofree) {
- kfree(map->cache_defaults_raw);
- map->cache_defaults_raw = NULL;
- }
return 0;
err:
regcache_exit(map);
-err_tofree:
- if (tofree) {
- kfree(map->cache_defaults_raw);
- map->cache_defaults_raw = NULL;
- }
return ret;
}

--
1.7.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/