Browse Source

regmap: debugfs: Add support for dumping write only device registers

Add support for dumping write only device registers in debugfs. This is
useful for audio codecs that have write only registers (like WM8731).
The logic that decides if a value can be printed is moved to
regmap_printable() function to allow for easier future updates.

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cristian Birsan 9 years ago
parent
commit
359a2f1760
1 changed files with 13 additions and 3 deletions
  1. 13 3
      drivers/base/regmap/regmap-debugfs.c

+ 13 - 3
drivers/base/regmap/regmap-debugfs.c

@@ -77,6 +77,17 @@ static void regmap_debugfs_free_dump_cache(struct regmap *map)
 	}
 	}
 }
 }
 
 
+static bool regmap_printable(struct regmap *map, unsigned int reg)
+{
+	if (regmap_precious(map, reg))
+		return false;
+
+	if (!regmap_readable(map, reg) && !regmap_cached(map, reg))
+		return false;
+
+	return true;
+}
+
 /*
 /*
  * Work out where the start offset maps into register numbers, bearing
  * Work out where the start offset maps into register numbers, bearing
  * in mind that we suppress hidden registers.
  * in mind that we suppress hidden registers.
@@ -105,8 +116,7 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
 	if (list_empty(&map->debugfs_off_cache)) {
 	if (list_empty(&map->debugfs_off_cache)) {
 		for (; i <= map->max_register; i += map->reg_stride) {
 		for (; i <= map->max_register; i += map->reg_stride) {
 			/* Skip unprinted registers, closing off cache entry */
 			/* Skip unprinted registers, closing off cache entry */
-			if (!regmap_readable(map, i) ||
-			    regmap_precious(map, i)) {
+			if (!regmap_printable(map, i)) {
 				if (c) {
 				if (c) {
 					c->max = p - 1;
 					c->max = p - 1;
 					c->max_reg = i - map->reg_stride;
 					c->max_reg = i - map->reg_stride;
@@ -204,7 +214,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 	start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
 	start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
 
 
 	for (i = start_reg; i <= to; i += map->reg_stride) {
 	for (i = start_reg; i <= to; i += map->reg_stride) {
-		if (!regmap_readable(map, i))
+		if (!regmap_readable(map, i) && !regmap_cached(map, i))
 			continue;
 			continue;
 
 
 		if (regmap_precious(map, i))
 		if (regmap_precious(map, i))