aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2011-11-16 10:28:16 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-12 23:55:06 -0500
commit94f9ec936513b9743996cf89d2f9c8e3110cf0f4 (patch)
treead72b43fa607269ce963bc791f9eda3ea68ca2f9 /drivers
parentbf315173359b2f3b8b8ccca4264815e91f30be12 (diff)
regmap: Move initialization of regcache related fields to regcache_init
Move the initialization regcache related fields of the regmap struct to regcache_init. This allows us to keep regmap and regcache code better separated. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/regmap/internal.h2
-rw-r--r--drivers/base/regmap/regcache.c9
-rw-r--r--drivers/base/regmap/regmap.c8
3 files changed, 10 insertions, 9 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 6483e0bda0cf..954f7b73238f 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -106,7 +106,7 @@ static inline void regmap_debugfs_exit(struct regmap *map) { }
106#endif 106#endif
107 107
108/* regcache core declarations */ 108/* regcache core declarations */
109int regcache_init(struct regmap *map); 109int regcache_init(struct regmap *map, const struct regmap_config *config);
110void regcache_exit(struct regmap *map); 110void regcache_exit(struct regmap *map);
111int regcache_read(struct regmap *map, 111int regcache_read(struct regmap *map,
112 unsigned int reg, unsigned int *value); 112 unsigned int reg, unsigned int *value);
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 6ab9f0384d82..bd9d01b681d1 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -79,7 +79,7 @@ static int regcache_hw_init(struct regmap *map)
79 return 0; 79 return 0;
80} 80}
81 81
82int regcache_init(struct regmap *map) 82int regcache_init(struct regmap *map, const struct regmap_config *config)
83{ 83{
84 int ret; 84 int ret;
85 int i; 85 int i;
@@ -100,6 +100,13 @@ int regcache_init(struct regmap *map)
100 return -EINVAL; 100 return -EINVAL;
101 } 101 }
102 102
103 map->reg_defaults = config->reg_defaults;
104 map->num_reg_defaults = config->num_reg_defaults;
105 map->num_reg_defaults_raw = config->num_reg_defaults_raw;
106 map->reg_defaults_raw = config->reg_defaults_raw;
107 map->cache_size_raw = (config->val_bits / 8) * config->num_reg_defaults_raw;
108 map->cache_word_size = config->val_bits / 8;
109
103 map->cache = NULL; 110 map->cache = NULL;
104 map->cache_ops = cache_types[i]; 111 map->cache_ops = cache_types[i];
105 112
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 579e85b8a684..44606f7c8ec8 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -147,12 +147,6 @@ struct regmap *regmap_init(struct device *dev,
147 map->volatile_reg = config->volatile_reg; 147 map->volatile_reg = config->volatile_reg;
148 map->precious_reg = config->precious_reg; 148 map->precious_reg = config->precious_reg;
149 map->cache_type = config->cache_type; 149 map->cache_type = config->cache_type;
150 map->reg_defaults = config->reg_defaults;
151 map->num_reg_defaults = config->num_reg_defaults;
152 map->num_reg_defaults_raw = config->num_reg_defaults_raw;
153 map->reg_defaults_raw = config->reg_defaults_raw;
154 map->cache_size_raw = (config->val_bits / 8) * config->num_reg_defaults_raw;
155 map->cache_word_size = config->val_bits / 8;
156 150
157 if (config->read_flag_mask || config->write_flag_mask) { 151 if (config->read_flag_mask || config->write_flag_mask) {
158 map->read_flag_mask = config->read_flag_mask; 152 map->read_flag_mask = config->read_flag_mask;
@@ -215,7 +209,7 @@ struct regmap *regmap_init(struct device *dev,
215 goto err_map; 209 goto err_map;
216 } 210 }
217 211
218 ret = regcache_init(map); 212 ret = regcache_init(map, config);
219 if (ret < 0) 213 if (ret < 0)
220 goto err_map; 214 goto err_map;
221 215