aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-10-03 08:13:16 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-10-14 20:59:59 -0400
commit4b020b3f9ba2af8031c5c7d759fbafd234d1c390 (patch)
tree0089993156b75b107585ed7048f4a6ab79ca3315 /drivers/base
parentbd9cc12f4a7e7389432bba0cae6970dfc28f423c (diff)
regmap: Provide debugfs read of register ranges
If a register range is named then provide a debugfs file showing the contents of the range separately. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/internal.h1
-rw-r--r--drivers/base/regmap/regmap-debugfs.c31
-rw-r--r--drivers/base/regmap/regmap.c1
3 files changed, 33 insertions, 0 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 27e66c3e7a59..ac869d28d5ba 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -121,6 +121,7 @@ int _regmap_write(struct regmap *map, unsigned int reg,
121struct regmap_range_node { 121struct regmap_range_node {
122 struct rb_node node; 122 struct rb_node node;
123 const char *name; 123 const char *name;
124 struct regmap *map;
124 125
125 unsigned int range_min; 126 unsigned int range_min;
126 unsigned int range_max; 127 unsigned int range_max;
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 25b6843d6a41..f4b9dd01c981 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -183,6 +183,22 @@ static const struct file_operations regmap_map_fops = {
183 .llseek = default_llseek, 183 .llseek = default_llseek,
184}; 184};
185 185
186static ssize_t regmap_range_read_file(struct file *file, char __user *user_buf,
187 size_t count, loff_t *ppos)
188{
189 struct regmap_range_node *range = file->private_data;
190 struct regmap *map = range->map;
191
192 return regmap_read_debugfs(map, range->range_min, range->range_max,
193 user_buf, count, ppos);
194}
195
196static const struct file_operations regmap_range_fops = {
197 .open = simple_open,
198 .read = regmap_range_read_file,
199 .llseek = default_llseek,
200};
201
186static ssize_t regmap_access_read_file(struct file *file, 202static ssize_t regmap_access_read_file(struct file *file,
187 char __user *user_buf, size_t count, 203 char __user *user_buf, size_t count,
188 loff_t *ppos) 204 loff_t *ppos)
@@ -253,6 +269,9 @@ static const struct file_operations regmap_access_fops = {
253 269
254void regmap_debugfs_init(struct regmap *map, const char *name) 270void regmap_debugfs_init(struct regmap *map, const char *name)
255{ 271{
272 struct rb_node *next;
273 struct regmap_range_node *range_node;
274
256 if (name) { 275 if (name) {
257 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", 276 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
258 dev_name(map->dev), name); 277 dev_name(map->dev), name);
@@ -285,6 +304,18 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
285 debugfs_create_bool("cache_bypass", 0400, map->debugfs, 304 debugfs_create_bool("cache_bypass", 0400, map->debugfs,
286 &map->cache_bypass); 305 &map->cache_bypass);
287 } 306 }
307
308 next = rb_first(&map->range_tree);
309 while (next) {
310 range_node = rb_entry(next, struct regmap_range_node, node);
311
312 if (range_node->name)
313 debugfs_create_file(range_node->name, 0400,
314 map->debugfs, range_node,
315 &regmap_range_fops);
316
317 next = rb_next(&range_node->node);
318 }
288} 319}
289 320
290void regmap_debugfs_exit(struct regmap *map) 321void regmap_debugfs_exit(struct regmap *map)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index ce5129df4406..366b629f4b10 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -579,6 +579,7 @@ struct regmap *regmap_init(struct device *dev,
579 goto err_range; 579 goto err_range;
580 } 580 }
581 581
582 new->map = map;
582 new->name = range_cfg->name; 583 new->name = range_cfg->name;
583 new->range_min = range_cfg->range_min; 584 new->range_min = range_cfg->range_min;
584 new->range_max = range_cfg->range_max; 585 new->range_max = range_cfg->range_max;