提交 82732bdd 编写于 作者: M Mark Brown

regmap: Prepare LZO cache for variable block sizes

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: NMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: NDimitris Papastamos <dp@opensource.wolfsonmicro.com>
上级 1ea6b8f4
...@@ -27,7 +27,7 @@ struct regcache_lzo_ctx { ...@@ -27,7 +27,7 @@ struct regcache_lzo_ctx {
}; };
#define LZO_BLOCK_NUM 8 #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; return LZO_BLOCK_NUM;
} }
...@@ -106,19 +106,22 @@ static inline int regcache_lzo_get_blkindex(struct regmap *map, ...@@ -106,19 +106,22 @@ static inline int regcache_lzo_get_blkindex(struct regmap *map,
unsigned int reg) unsigned int reg)
{ {
return (reg * map->cache_word_size) / 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, static inline int regcache_lzo_get_blkpos(struct regmap *map,
unsigned int reg) 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); map->cache_word_size);
} }
static inline int regcache_lzo_get_blksize(struct regmap *map) 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) static int regcache_lzo_init(struct regmap *map)
...@@ -131,7 +134,7 @@ static int regcache_lzo_init(struct regmap *map) ...@@ -131,7 +134,7 @@ static int regcache_lzo_init(struct regmap *map)
ret = 0; ret = 0;
blkcount = regcache_lzo_block_count(); blkcount = regcache_lzo_block_count(map);
map->cache = kzalloc(blkcount * sizeof *lzo_blocks, map->cache = kzalloc(blkcount * sizeof *lzo_blocks,
GFP_KERNEL); GFP_KERNEL);
if (!map->cache) if (!map->cache)
...@@ -203,7 +206,7 @@ static int regcache_lzo_exit(struct regmap *map) ...@@ -203,7 +206,7 @@ static int regcache_lzo_exit(struct regmap *map)
if (!lzo_blocks) if (!lzo_blocks)
return 0; return 0;
blkcount = regcache_lzo_block_count(); blkcount = regcache_lzo_block_count(map);
/* /*
* the pointer to the bitmap used for syncing the cache * the pointer to the bitmap used for syncing the cache
* is shared amongst all lzo_blocks. Ensure it is freed * is shared amongst all lzo_blocks. Ensure it is freed
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册