Skip to content

Commit

Permalink
regmap: Prepare LZO cache for variable block sizes
Browse files Browse the repository at this point in the history
Give regcache_lzo_block_count() a copy of the map so that when we decide
we want to make the LZO cache more controllable we can more easily do so.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Nov 8, 2011
1 parent 1ea6b8f commit 82732bd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drivers/base/regmap/regcache-lzo.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct regcache_lzo_ctx {
};

#define LZO_BLOCK_NUM 8
static int regcache_lzo_block_count(void)
static int regcache_lzo_block_count(struct regmap *map)
{
return LZO_BLOCK_NUM;
}
Expand Down Expand Up @@ -106,19 +106,22 @@ static inline int regcache_lzo_get_blkindex(struct regmap *map,
unsigned int reg)
{
return (reg * map->cache_word_size) /
DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count());
DIV_ROUND_UP(map->cache_size_raw,
regcache_lzo_block_count(map));
}

static inline int regcache_lzo_get_blkpos(struct regmap *map,
unsigned int reg)
{
return reg % (DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()) /
return reg % (DIV_ROUND_UP(map->cache_size_raw,
regcache_lzo_block_count(map)) /
map->cache_word_size);
}

static inline int regcache_lzo_get_blksize(struct regmap *map)
{
return DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count());
return DIV_ROUND_UP(map->cache_size_raw,
regcache_lzo_block_count(map));
}

static int regcache_lzo_init(struct regmap *map)
Expand All @@ -131,7 +134,7 @@ static int regcache_lzo_init(struct regmap *map)

ret = 0;

blkcount = regcache_lzo_block_count();
blkcount = regcache_lzo_block_count(map);
map->cache = kzalloc(blkcount * sizeof *lzo_blocks,
GFP_KERNEL);
if (!map->cache)
Expand Down Expand Up @@ -203,7 +206,7 @@ static int regcache_lzo_exit(struct regmap *map)
if (!lzo_blocks)
return 0;

blkcount = regcache_lzo_block_count();
blkcount = regcache_lzo_block_count(map);
/*
* the pointer to the bitmap used for syncing the cache
* is shared amongst all lzo_blocks. Ensure it is freed
Expand Down

0 comments on commit 82732bd

Please sign in to comment.