aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-04-04 17:48:29 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-13 06:29:19 -0400
commit4b5c0186e48c8d14fd7c38ff99b8d1b9aa475432 (patch)
tree55c80e93f1ae158bed0798ca0354b043639e3bac
parent2690dfdb05abf3a8e11ff21ec12dbbe620a026fb (diff)
regmap: allow regmap instances to be named
Some devices have multiple separate register regions. Logically, one regmap would be created per region. One issue that prevents this is that each instance will attempt to create the same debugfs files. Avoid this by allowing regmaps to be named, and use the name to construct the debugfs directory name. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/base/regmap/internal.h3
-rw-r--r--drivers/base/regmap/regmap-debugfs.c14
-rw-r--r--drivers/base/regmap/regmap.c4
-rw-r--r--include/linux/regmap.h5
4 files changed, 20 insertions, 6 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 44e3b1c438f4..9bc1d270f0bd 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -48,6 +48,7 @@ struct regmap {
48 48
49#ifdef CONFIG_DEBUG_FS 49#ifdef CONFIG_DEBUG_FS
50 struct dentry *debugfs; 50 struct dentry *debugfs;
51 const char *debugfs_name;
51#endif 52#endif
52 53
53 unsigned int max_register; 54 unsigned int max_register;
@@ -111,7 +112,7 @@ int _regmap_write(struct regmap *map, unsigned int reg,
111 112
112#ifdef CONFIG_DEBUG_FS 113#ifdef CONFIG_DEBUG_FS
113extern void regmap_debugfs_initcall(void); 114extern void regmap_debugfs_initcall(void);
114extern void regmap_debugfs_init(struct regmap *map); 115extern void regmap_debugfs_init(struct regmap *map, const char *name);
115extern void regmap_debugfs_exit(struct regmap *map); 116extern void regmap_debugfs_exit(struct regmap *map);
116#else 117#else
117static inline void regmap_debugfs_initcall(void) { } 118static inline void regmap_debugfs_initcall(void) { }
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 251eb70f83e7..df97c93efa8e 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -242,10 +242,17 @@ static const struct file_operations regmap_access_fops = {
242 .llseek = default_llseek, 242 .llseek = default_llseek,
243}; 243};
244 244
245void regmap_debugfs_init(struct regmap *map) 245void regmap_debugfs_init(struct regmap *map, const char *name)
246{ 246{
247 map->debugfs = debugfs_create_dir(dev_name(map->dev), 247 if (name) {
248 regmap_debugfs_root); 248 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
249 dev_name(map->dev), name);
250 name = map->debugfs_name;
251 } else {
252 name = dev_name(map->dev);
253 }
254
255 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
249 if (!map->debugfs) { 256 if (!map->debugfs) {
250 dev_warn(map->dev, "Failed to create debugfs directory\n"); 257 dev_warn(map->dev, "Failed to create debugfs directory\n");
251 return; 258 return;
@@ -274,6 +281,7 @@ void regmap_debugfs_init(struct regmap *map)
274void regmap_debugfs_exit(struct regmap *map) 281void regmap_debugfs_exit(struct regmap *map)
275{ 282{
276 debugfs_remove_recursive(map->debugfs); 283 debugfs_remove_recursive(map->debugfs);
284 kfree(map->debugfs_name);
277} 285}
278 286
279void regmap_debugfs_initcall(void) 287void regmap_debugfs_initcall(void)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e6038bc54210..40f910162781 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -346,7 +346,7 @@ struct regmap *regmap_init(struct device *dev,
346 goto err_map; 346 goto err_map;
347 } 347 }
348 348
349 regmap_debugfs_init(map); 349 regmap_debugfs_init(map, config->name);
350 350
351 ret = regcache_init(map, config); 351 ret = regcache_init(map, config);
352 if (ret < 0) 352 if (ret < 0)
@@ -431,7 +431,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
431 map->precious_reg = config->precious_reg; 431 map->precious_reg = config->precious_reg;
432 map->cache_type = config->cache_type; 432 map->cache_type = config->cache_type;
433 433
434 regmap_debugfs_init(map); 434 regmap_debugfs_init(map, config->name);
435 435
436 map->cache_bypass = false; 436 map->cache_bypass = false;
437 map->cache_only = false; 437 map->cache_only = false;
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index f6abc8d33d64..680ddd7de60e 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -46,6 +46,9 @@ struct reg_default {
46/** 46/**
47 * Configuration for the register map of a device. 47 * Configuration for the register map of a device.
48 * 48 *
49 * @name: Optional name of the regmap. Useful when a device has multiple
50 * register regions.
51 *
49 * @reg_bits: Number of bits in a register address, mandatory. 52 * @reg_bits: Number of bits in a register address, mandatory.
50 * @pad_bits: Number of bits of padding between register and value. 53 * @pad_bits: Number of bits of padding between register and value.
51 * @val_bits: Number of bits in a register value, mandatory. 54 * @val_bits: Number of bits in a register value, mandatory.
@@ -77,6 +80,8 @@ struct reg_default {
77 * @num_reg_defaults_raw: Number of elements in reg_defaults_raw. 80 * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
78 */ 81 */
79struct regmap_config { 82struct regmap_config {
83 const char *name;
84
80 int reg_bits; 85 int reg_bits;
81 int pad_bits; 86 int pad_bits;
82 int val_bits; 87 int val_bits;