]> Pileus Git - ~andy/linux/commitdiff
Merge branch 'topic/cache' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 5 Dec 2011 13:18:50 +0000 (13:18 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 5 Dec 2011 13:18:50 +0000 (13:18 +0000)
drivers/base/regmap/regmap.c
include/linux/regmap.h

index add5da6d9c0aa00c90ce666f23e39a21bb798f2d..be10a4ff660915625454375ce9fb30a97d5b7ef9 100644 (file)
@@ -258,6 +258,39 @@ err:
 }
 EXPORT_SYMBOL_GPL(regmap_init);
 
+/**
+ * regmap_reinit_cache(): Reinitialise the current register cache
+ *
+ * @map: Register map to operate on.
+ * @config: New configuration.  Only the cache data will be used.
+ *
+ * Discard any existing register cache for the map and initialize a
+ * new cache.  This can be used to restore the cache to defaults or to
+ * update the cache configuration to reflect runtime discovery of the
+ * hardware.
+ */
+int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
+{
+       int ret;
+
+       mutex_lock(&map->lock);
+
+       regcache_exit(map);
+
+       map->max_register = config->max_register;
+       map->writeable_reg = config->writeable_reg;
+       map->readable_reg = config->readable_reg;
+       map->volatile_reg = config->volatile_reg;
+       map->precious_reg = config->precious_reg;
+       map->cache_type = config->cache_type;
+
+       ret = regcache_init(map, config);
+
+       mutex_unlock(&map->lock);
+
+       return ret;
+}
+
 /**
  * regmap_exit(): Free a previously allocated register map
  */
index a83e4a097abd0e5288e1ebc9ea7467f5d634f4d1..cfce3a358fbf114036f44af141f7e244034208ad 100644 (file)
@@ -128,6 +128,8 @@ struct regmap *regmap_init_spi(struct spi_device *dev,
                               const struct regmap_config *config);
 
 void regmap_exit(struct regmap *map);
+int regmap_reinit_cache(struct regmap *map,
+                       const struct regmap_config *config);
 int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
 int regmap_raw_write(struct regmap *map, unsigned int reg,
                     const void *val, size_t val_len);