diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-10-17 19:37:00 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-11-08 06:32:05 -0500 |
commit | 82732bdd663ee9dc1ad4b0409881fe89a9d827ca (patch) | |
tree | 11e85062bdac8075c296a45350f0bde3dbb70130 /drivers/base | |
parent | 1ea6b8f48918282bdca0b32a34095504ee65bab5 (diff) |
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: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regcache-lzo.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/base/regmap/regcache-lzo.c b/drivers/base/regmap/regcache-lzo.c index 066aeece3626..0075690e5bb5 100644 --- a/drivers/base/regmap/regcache-lzo.c +++ b/drivers/base/regmap/regcache-lzo.c | |||
@@ -27,7 +27,7 @@ struct regcache_lzo_ctx { | |||
27 | }; | 27 | }; |
28 | 28 | ||
29 | #define LZO_BLOCK_NUM 8 | 29 | #define LZO_BLOCK_NUM 8 |
30 | static int regcache_lzo_block_count(void) | 30 | static int regcache_lzo_block_count(struct regmap *map) |
31 | { | 31 | { |
32 | return LZO_BLOCK_NUM; | 32 | return LZO_BLOCK_NUM; |
33 | } | 33 | } |
@@ -106,19 +106,22 @@ static inline int regcache_lzo_get_blkindex(struct regmap *map, | |||
106 | unsigned int reg) | 106 | unsigned int reg) |
107 | { | 107 | { |
108 | return (reg * map->cache_word_size) / | 108 | return (reg * map->cache_word_size) / |
109 | DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()); | 109 | DIV_ROUND_UP(map->cache_size_raw, |
110 | regcache_lzo_block_count(map)); | ||
110 | } | 111 | } |
111 | 112 | ||
112 | static inline int regcache_lzo_get_blkpos(struct regmap *map, | 113 | static inline int regcache_lzo_get_blkpos(struct regmap *map, |
113 | unsigned int reg) | 114 | unsigned int reg) |
114 | { | 115 | { |
115 | return reg % (DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()) / | 116 | return reg % (DIV_ROUND_UP(map->cache_size_raw, |
117 | regcache_lzo_block_count(map)) / | ||
116 | map->cache_word_size); | 118 | map->cache_word_size); |
117 | } | 119 | } |
118 | 120 | ||
119 | static inline int regcache_lzo_get_blksize(struct regmap *map) | 121 | static inline int regcache_lzo_get_blksize(struct regmap *map) |
120 | { | 122 | { |
121 | return DIV_ROUND_UP(map->cache_size_raw, regcache_lzo_block_count()); | 123 | return DIV_ROUND_UP(map->cache_size_raw, |
124 | regcache_lzo_block_count(map)); | ||
122 | } | 125 | } |
123 | 126 | ||
124 | static int regcache_lzo_init(struct regmap *map) | 127 | static int regcache_lzo_init(struct regmap *map) |
@@ -131,7 +134,7 @@ static int regcache_lzo_init(struct regmap *map) | |||
131 | 134 | ||
132 | ret = 0; | 135 | ret = 0; |
133 | 136 | ||
134 | blkcount = regcache_lzo_block_count(); | 137 | blkcount = regcache_lzo_block_count(map); |
135 | map->cache = kzalloc(blkcount * sizeof *lzo_blocks, | 138 | map->cache = kzalloc(blkcount * sizeof *lzo_blocks, |
136 | GFP_KERNEL); | 139 | GFP_KERNEL); |
137 | if (!map->cache) | 140 | if (!map->cache) |
@@ -203,7 +206,7 @@ static int regcache_lzo_exit(struct regmap *map) | |||
203 | if (!lzo_blocks) | 206 | if (!lzo_blocks) |
204 | return 0; | 207 | return 0; |
205 | 208 | ||
206 | blkcount = regcache_lzo_block_count(); | 209 | blkcount = regcache_lzo_block_count(map); |
207 | /* | 210 | /* |
208 | * the pointer to the bitmap used for syncing the cache | 211 | * the pointer to the bitmap used for syncing the cache |
209 | * is shared amongst all lzo_blocks. Ensure it is freed | 212 | * is shared amongst all lzo_blocks. Ensure it is freed |