diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-05-07 14:55:30 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2020-05-07 14:55:42 +0200 |
commit | 8241946f5082d5b03c4ec109434ea8a7a43d02cb (patch) | |
tree | 75562285375de3210f11c02d6090b7ac0a8dd56b | |
parent | 945461c4df6a33163147013d76b23058d2b3f864 (diff) | |
download | hda-emu-8241946f5082d5b03c4ec109434ea8a7a43d02cb.tar.gz |
Support regmap_update_bits*() stuff
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/linux/regmap.h | 6 | ||||
-rw-r--r-- | include/wrapper.h | 1 | ||||
-rw-r--r-- | lib/hdac_regmap.c | 31 |
3 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index b0278f0..27d3294 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -56,4 +56,10 @@ void regcache_cache_only(struct regmap *map, bool enable); void regcache_cache_bypass(struct regmap *map, bool enable); void regcache_mark_dirty(struct regmap *map); +int regmap_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val); +int regmap_update_bits_check(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val, + bool *change); + #endif /* __LINUX_REGMAP_H */ diff --git a/include/wrapper.h b/include/wrapper.h index f40cab7..cd1bf55 100644 --- a/include/wrapper.h +++ b/include/wrapper.h @@ -154,6 +154,7 @@ typedef unsigned int uuid_le; #define __user #define __bitwise #define __iomem +#define __must_check #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) diff --git a/lib/hdac_regmap.c b/lib/hdac_regmap.c index 3f02f7c..81bcb57 100644 --- a/lib/hdac_regmap.c +++ b/lib/hdac_regmap.c @@ -183,3 +183,34 @@ void regcache_mark_dirty(struct regmap *map) map->cache_dirty = true; } +int regmap_update_bits(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val) +{ + return regmap_update_bits_check(map, reg, mask, val, NULL); +} + +int regmap_update_bits_check(struct regmap *map, unsigned int reg, + unsigned int mask, unsigned int val, + bool *change) +{ + unsigned int tmp, orig; + int ret; + + if (change) + *change = false; + + ret = map->config->reg_read(map->bus_context, reg, &orig); + if (ret != 0) + return ret; + + tmp = orig & ~mask; + tmp |= val & mask; + + if (tmp != orig) { + ret = map->config->reg_write(map->bus_context, reg, tmp); + if (ret == 0 && change) + *change = true; + } + + return ret; +} |