]> Pileus Git - ~andy/linux/commitdiff
regmap: Move initialization of regcache related fields to regcache_init
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 16 Nov 2011 15:28:16 +0000 (16:28 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 13 Dec 2011 04:55:06 +0000 (12:55 +0800)
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>
drivers/base/regmap/internal.h
drivers/base/regmap/regcache.c
drivers/base/regmap/regmap.c

index 6483e0bda0cfb97a48489f13a30e55c36c893e47..954f7b73238fdca2b529e1f593cb46bd0c955ab1 100644 (file)
@@ -106,7 +106,7 @@ static inline void regmap_debugfs_exit(struct regmap *map) { }
 #endif
 
 /* regcache core declarations */
-int regcache_init(struct regmap *map);
+int regcache_init(struct regmap *map, const struct regmap_config *config);
 void regcache_exit(struct regmap *map);
 int regcache_read(struct regmap *map,
                       unsigned int reg, unsigned int *value);
index 6ab9f0384d82c3fa82f6c575d45dac31d4b305ca..bd9d01b681d1fd3bfebcada905f08f3a2b00d636 100644 (file)
@@ -79,7 +79,7 @@ static int regcache_hw_init(struct regmap *map)
        return 0;
 }
 
-int regcache_init(struct regmap *map)
+int regcache_init(struct regmap *map, const struct regmap_config *config)
 {
        int ret;
        int i;
@@ -100,6 +100,13 @@ int regcache_init(struct regmap *map)
                return -EINVAL;
        }
 
+       map->reg_defaults = config->reg_defaults;
+       map->num_reg_defaults = config->num_reg_defaults;
+       map->num_reg_defaults_raw = config->num_reg_defaults_raw;
+       map->reg_defaults_raw = config->reg_defaults_raw;
+       map->cache_size_raw = (config->val_bits / 8) * config->num_reg_defaults_raw;
+       map->cache_word_size = config->val_bits / 8;
+
        map->cache = NULL;
        map->cache_ops = cache_types[i];
 
index 579e85b8a68458842b6cc918b316742ea0aa1554..44606f7c8ec8fab2b5b5ee18fe492aca1e4f4d32 100644 (file)
@@ -147,12 +147,6 @@ struct regmap *regmap_init(struct device *dev,
        map->volatile_reg = config->volatile_reg;
        map->precious_reg = config->precious_reg;
        map->cache_type = config->cache_type;
-       map->reg_defaults = config->reg_defaults;
-       map->num_reg_defaults = config->num_reg_defaults;
-       map->num_reg_defaults_raw = config->num_reg_defaults_raw;
-       map->reg_defaults_raw = config->reg_defaults_raw;
-       map->cache_size_raw = (config->val_bits / 8) * config->num_reg_defaults_raw;
-       map->cache_word_size = config->val_bits / 8;
 
        if (config->read_flag_mask || config->write_flag_mask) {
                map->read_flag_mask = config->read_flag_mask;
@@ -215,7 +209,7 @@ struct regmap *regmap_init(struct device *dev,
                goto err_map;
        }
 
-       ret = regcache_init(map);
+       ret = regcache_init(map, config);
        if (ret < 0)
                goto err_map;