]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
regmap: allow regmap instances to be named
authorStephen Warren <swarren@nvidia.com>
Wed, 4 Apr 2012 21:48:29 +0000 (15:48 -0600)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 10 Apr 2012 09:31:41 +0000 (10:31 +0100)
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>
drivers/base/regmap/internal.h
drivers/base/regmap/regmap-debugfs.c
drivers/base/regmap/regmap.c
include/linux/regmap.h

index fcafc5b2e65113e36e496079ec2e20c93e20abb3..6beef6691c4743a2168e234696f60e549ac319f3 100644 (file)
@@ -41,6 +41,7 @@ struct regmap {
 
 #ifdef CONFIG_DEBUG_FS
        struct dentry *debugfs;
+       const char *debugfs_name;
 #endif
 
        unsigned int max_register;
@@ -101,7 +102,7 @@ int _regmap_write(struct regmap *map, unsigned int reg,
 
 #ifdef CONFIG_DEBUG_FS
 extern void regmap_debugfs_initcall(void);
-extern void regmap_debugfs_init(struct regmap *map);
+extern void regmap_debugfs_init(struct regmap *map, const char *name);
 extern void regmap_debugfs_exit(struct regmap *map);
 #else
 static inline void regmap_debugfs_initcall(void) { }
index 58517a5dac1360b96b0779c0724d12e926d11c77..9715e8e4450694f38eba1cbf65a913bc36cdc539 100644 (file)
@@ -248,10 +248,17 @@ static const struct file_operations regmap_access_fops = {
        .llseek = default_llseek,
 };
 
-void regmap_debugfs_init(struct regmap *map)
+void regmap_debugfs_init(struct regmap *map, const char *name)
 {
-       map->debugfs = debugfs_create_dir(dev_name(map->dev),
-                                         regmap_debugfs_root);
+       if (name) {
+               map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
+                                             dev_name(map->dev), name);
+               name = map->debugfs_name;
+       } else {
+               name = dev_name(map->dev);
+       }
+
+       map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
        if (!map->debugfs) {
                dev_warn(map->dev, "Failed to create debugfs directory\n");
                return;
@@ -280,6 +287,7 @@ void regmap_debugfs_init(struct regmap *map)
 void regmap_debugfs_exit(struct regmap *map)
 {
        debugfs_remove_recursive(map->debugfs);
+       kfree(map->debugfs_name);
 }
 
 void regmap_debugfs_initcall(void)
index 7a3f535e481c69ac31254b84bc6111e0d9793814..b1dad1f9c47df25ffc1e36e81ce0d313f6c22e8b 100644 (file)
@@ -289,7 +289,7 @@ struct regmap *regmap_init(struct device *dev,
                goto err_map;
        }
 
-       regmap_debugfs_init(map);
+       regmap_debugfs_init(map, config->name);
 
        ret = regcache_init(map, config);
        if (ret < 0)
@@ -372,7 +372,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
        map->precious_reg = config->precious_reg;
        map->cache_type = config->cache_type;
 
-       regmap_debugfs_init(map);
+       regmap_debugfs_init(map, config->name);
 
        map->cache_bypass = false;
        map->cache_only = false;
index a90abb6bfa6400402b516865df47db182dd5e0a0..0a27ee809ca152b896c5ae5e31cd4aac75c2c185 100644 (file)
@@ -46,6 +46,9 @@ struct reg_default {
 /**
  * Configuration for the register map of a device.
  *
+ * @name: Optional name of the regmap. Useful when a device has multiple
+ *        register regions.
+ *
  * @reg_bits: Number of bits in a register address, mandatory.
  * @pad_bits: Number of bits of padding between register and value.
  * @val_bits: Number of bits in a register value, mandatory.
@@ -77,6 +80,8 @@ struct reg_default {
  * @num_reg_defaults_raw: Number of elements in reg_defaults_raw.
  */
 struct regmap_config {
+       const char *name;
+
        int reg_bits;
        int pad_bits;
        int val_bits;