Skip to content

Commit

Permalink
regmap: Add a function to check if a regmap register is cached
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Cristian Birsan authored and Mark Brown committed Aug 9, 2016
1 parent 29b4817 commit 1ea975c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/base/regmap/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct regcache_ops {
int (*drop)(struct regmap *map, unsigned int min, unsigned int max);
};

bool regmap_cached(struct regmap *map, unsigned int reg);
bool regmap_writeable(struct regmap *map, unsigned int reg);
bool regmap_readable(struct regmap *map, unsigned int reg);
bool regmap_volatile(struct regmap *map, unsigned int reg);
Expand Down
23 changes: 23 additions & 0 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,29 @@ bool regmap_writeable(struct regmap *map, unsigned int reg)
return true;
}

bool regmap_cached(struct regmap *map, unsigned int reg)
{
int ret;
unsigned int val;

if (map->cache == REGCACHE_NONE)
return false;

if (!map->cache_ops)
return false;

if (map->max_register && reg > map->max_register)
return false;

map->lock(map->lock_arg);
ret = regcache_read(map, reg, &val);
map->unlock(map->lock_arg);
if (ret)
return false;

return true;
}

bool regmap_readable(struct regmap *map, unsigned int reg)
{
if (!map->reg_read)
Expand Down

0 comments on commit 1ea975c

Please sign in to comment.