Skip to content

Commit 6eb0f5e

Browse files
Dimitris Papastamosbroonie
authored andcommitted
regmap: Implement regcache_cache_bypass helper function
Ensure we've got a function so users can enable/disable the cache bypass option. Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1 parent beb1a10 commit 6eb0f5e

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/base/regmap/regcache.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,25 @@ void regcache_cache_only(struct regmap *map, bool enable)
286286
}
287287
EXPORT_SYMBOL_GPL(regcache_cache_only);
288288

289+
/**
290+
* regcache_cache_bypass: Put a register map into cache bypass mode
291+
*
292+
* @map: map to configure
293+
* @cache_only: flag if changes should not be written to the hardware
294+
*
295+
* When a register map is marked with the cache bypass option, writes
296+
* to the register map API will only update the hardware and not the
297+
* the cache directly. This is useful when syncing the cache back to
298+
* the hardware.
299+
*/
300+
void regcache_cache_bypass(struct regmap *map, bool enable)
301+
{
302+
mutex_lock(&map->lock);
303+
map->cache_bypass = enable;
304+
mutex_unlock(&map->lock);
305+
}
306+
EXPORT_SYMBOL_GPL(regcache_cache_bypass);
307+
289308
bool regcache_set_val(void *base, unsigned int idx,
290309
unsigned int val, unsigned int word_size)
291310
{

‎include/linux/regmap.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,6 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
142142

143143
int regcache_sync(struct regmap *map);
144144
void regcache_cache_only(struct regmap *map, bool enable);
145+
void regcache_cache_bypass(struct regmap *map, bool enable);
145146

146147
#endif

0 commit comments

Comments
 (0)