Skip to content

Commit 1ea975c

Browse files
cristibirsanbroonie
authored andcommitted
regmap: Add a function to check if a regmap register is cached
Add a function to check if a regmap register is cached. This will be used in debugfs to dump the cached values of write only registers. Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 29b4817 commit 1ea975c

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

drivers/base/regmap/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ struct regcache_ops {
173173
int (*drop)(struct regmap *map, unsigned int min, unsigned int max);
174174
};
175175

176+
bool regmap_cached(struct regmap *map, unsigned int reg);
176177
bool regmap_writeable(struct regmap *map, unsigned int reg);
177178
bool regmap_readable(struct regmap *map, unsigned int reg);
178179
bool regmap_volatile(struct regmap *map, unsigned int reg);

drivers/base/regmap/regmap.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,29 @@ bool regmap_writeable(struct regmap *map, unsigned int reg)
9393
return true;
9494
}
9595

96+
bool regmap_cached(struct regmap *map, unsigned int reg)
97+
{
98+
int ret;
99+
unsigned int val;
100+
101+
if (map->cache == REGCACHE_NONE)
102+
return false;
103+
104+
if (!map->cache_ops)
105+
return false;
106+
107+
if (map->max_register && reg > map->max_register)
108+
return false;
109+
110+
map->lock(map->lock_arg);
111+
ret = regcache_read(map, reg, &val);
112+
map->unlock(map->lock_arg);
113+
if (ret)
114+
return false;
115+
116+
return true;
117+
}
118+
96119
bool regmap_readable(struct regmap *map, unsigned int reg)
97120
{
98121
if (!map->reg_read)

0 commit comments

Comments
 (0)