Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regmap: Let users check if a register is cached

The HDA driver has a use case for checking if a register is cached which
it bodges in awkwardly and unclearly. Provide an API which allows it to
directly do what it's trying to do.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230717-regmap-cache-check-v1-1-73ef688afae3@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

+24
+23
drivers/base/regmap/regcache.c
··· 561 561 } 562 562 EXPORT_SYMBOL_GPL(regcache_cache_bypass); 563 563 564 + /** 565 + * regcache_reg_cached - Check if a register is cached 566 + * 567 + * @map: map to check 568 + * @reg: register to check 569 + * 570 + * Reports if a register is cached. 571 + */ 572 + bool regcache_reg_cached(struct regmap *map, unsigned int reg) 573 + { 574 + unsigned int val; 575 + int ret; 576 + 577 + map->lock(map->lock_arg); 578 + 579 + ret = regcache_read(map, reg, &val); 580 + 581 + map->unlock(map->lock_arg); 582 + 583 + return ret == 0; 584 + } 585 + EXPORT_SYMBOL_GPL(regcache_reg_cached); 586 + 564 587 void regcache_set_val(struct regmap *map, void *base, unsigned int idx, 565 588 unsigned int val) 566 589 {
+1
include/linux/regmap.h
··· 1287 1287 void regcache_cache_only(struct regmap *map, bool enable); 1288 1288 void regcache_cache_bypass(struct regmap *map, bool enable); 1289 1289 void regcache_mark_dirty(struct regmap *map); 1290 + bool regcache_reg_cached(struct regmap *map, unsigned int reg); 1290 1291 1291 1292 bool regmap_check_range_table(struct regmap *map, unsigned int reg, 1292 1293 const struct regmap_access_table *table);