Skip to content

Commit 359a2f1

Browse files
cristibirsanbroonie
authored andcommitted
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>
1 parent 1ea975c commit 359a2f1

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

drivers/base/regmap/regmap-debugfs.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ static void regmap_debugfs_free_dump_cache(struct regmap *map)
7777
}
7878
}
7979

80+
static bool regmap_printable(struct regmap *map, unsigned int reg)
81+
{
82+
if (regmap_precious(map, reg))
83+
return false;
84+
85+
if (!regmap_readable(map, reg) && !regmap_cached(map, reg))
86+
return false;
87+
88+
return true;
89+
}
90+
8091
/*
8192
* Work out where the start offset maps into register numbers, bearing
8293
* in mind that we suppress hidden registers.
@@ -105,8 +116,7 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
105116
if (list_empty(&map->debugfs_off_cache)) {
106117
for (; i <= map->max_register; i += map->reg_stride) {
107118
/* Skip unprinted registers, closing off cache entry */
108-
if (!regmap_readable(map, i) ||
109-
regmap_precious(map, i)) {
119+
if (!regmap_printable(map, i)) {
110120
if (c) {
111121
c->max = p - 1;
112122
c->max_reg = i - map->reg_stride;
@@ -204,7 +214,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
204214
start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
205215

206216
for (i = start_reg; i <= to; i += map->reg_stride) {
207-
if (!regmap_readable(map, i))
217+
if (!regmap_readable(map, i) && !regmap_cached(map, i))
208218
continue;
209219

210220
if (regmap_precious(map, i))

0 commit comments

Comments
 (0)