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-10 05:31:41 -0400
commitd3c242e1f22f5dfed009296ee45ce896153f0b53 (patch)
tree074bd0d53a1439e7201639d0acdeeedf5b3f0232
parentdd775ae2549217d3ae09363e3edb305d0fa19928 (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 fcafc5b2e651..6beef6691c47 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -41,6 +41,7 @@ struct regmap {
41 41
42#ifdef CONFIG_DEBUG_FS 42#ifdef CONFIG_DEBUG_FS
43 struct dentry *debugfs; 43 struct dentry *debugfs;
44 const char *debugfs_name;
44#endif 45#endif
45 46
46 unsigned int max_register; 47 unsigned int max_register;
@@ -101,7 +102,7 @@ int _regmap_write(struct regmap *map, unsigned int reg,
101 102
102#ifdef CONFIG_DEBUG_FS 103#ifdef CONFIG_DEBUG_FS
103extern void regmap_debugfs_initcall(void); 104extern void regmap_debugfs_initcall(void);
104extern void regmap_debugfs_init(struct regmap *map); 105extern void regmap_debugfs_init(struct regmap *map, const char *name);
105extern void regmap_debugfs_exit(struct regmap *map); 106extern void regmap_debugfs_exit(struct regmap *map);
106#else 107#else
107static inline void regmap_debugfs_initcall(void) { } 108static inline void regmap_debugfs_initcall(void) { }
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 58517a5dac13..9715e8e44506 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -248,10 +248,17 @@ static const struct file_operations regmap_access_fops = {
248 .llseek = default_llseek, 248 .llseek = default_llseek,
249}; 249};
250 250
251void regmap_debugfs_init(struct regmap *map) 251void regmap_debugfs_init(struct regmap *map, const char *name)
252{ 252{
253 map->debugfs = debugfs_create_dir(dev_name(map->dev), 253 if (name) {
254 regmap_debugfs_root); 254 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
255 dev_name(map->dev), name);
256 name = map->debugfs_name;
257 } else {
258 name = dev_name(map->dev);
259 }
260
261 map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
255 if (!map->debugfs) { 262 if (!map->debugfs) {
256 dev_warn(map->dev, "Failed to create debugfs directory\n"); 263 dev_warn(map->dev, "Failed to create debugfs directory\n");
257 return; 264 return;
@@ -280,6 +287,7 @@ void regmap_debugfs_init(struct regmap *map)
280void regmap_debugfs_exit(struct regmap *map) 287void regmap_debugfs_exit(struct regmap *map)
281{ 288{
282 debugfs_remove_recursive(map->debugfs); 289 debugfs_remove_recursive(map->debugfs);
290 kfree(map->debugfs_name);
283} 291}
284 292
285void regmap_debugfs_initcall(void) 293void regmap_debugfs_initcall(void)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 7a3f535e481c..b1dad1f9c47d 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -289,7 +289,7 @@ struct regmap *regmap_init(struct device *dev,
289 goto err_map; 289 goto err_map;
290 } 290 }
291 291
292 regmap_debugfs_init(map); 292 regmap_debugfs_init(map, config->name);
293 293
294 ret = regcache_init(map, config); 294 ret = regcache_init(map, config);
295 if (ret < 0) 295 if (ret < 0)
@@ -372,7 +372,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
372 map->precious_reg = config->precious_reg; 372 map->precious_reg = config->precious_reg;
373 map->cache_type = config->cache_type; 373 map->cache_type = config->cache_type;
374 374
375 regmap_debugfs_init(map); 375 regmap_debugfs_init(map, config->name);
376 376
377 map->cache_bypass = false; 377 map->cache_bypass = false;
378 map->cache_only = false; 378 map->cache_only = false;
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index a90abb6bfa64..0a27ee809ca1 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;