Commit a6539c32949063c8147905512a83a98842c2d254
1 parent
b01543dfe6
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
regmap: Allow users to query the size of register values
Generic infrastructure based on top of regmap may want to operate on blocks of data and therefore find it useful to find the size of the register values. Provide an accessor operation for this. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Showing 2 changed files with 16 additions and 0 deletions Side-by-side Diff
drivers/base/regmap/regmap.c
... | ... | @@ -672,6 +672,21 @@ |
672 | 672 | } |
673 | 673 | EXPORT_SYMBOL_GPL(regmap_update_bits_check); |
674 | 674 | |
675 | +/** | |
676 | + * regmap_get_val_bytes(): Report the size of a register value | |
677 | + * | |
678 | + * Report the size of a register value, mainly intended to for use by | |
679 | + * generic infrastructure built on top of regmap. | |
680 | + */ | |
681 | +int regmap_get_val_bytes(struct regmap *map) | |
682 | +{ | |
683 | + if (map->format.format_write) | |
684 | + return -EINVAL; | |
685 | + | |
686 | + return map->format.val_bytes; | |
687 | +} | |
688 | +EXPORT_SYMBOL_GPL(regmap_get_val_bytes); | |
689 | + | |
675 | 690 | static int __init regmap_initcall(void) |
676 | 691 | { |
677 | 692 | regmap_debugfs_initcall(); |
include/linux/regmap.h
... | ... | @@ -143,6 +143,7 @@ |
143 | 143 | int regmap_update_bits_check(struct regmap *map, unsigned int reg, |
144 | 144 | unsigned int mask, unsigned int val, |
145 | 145 | bool *change); |
146 | +int regmap_get_val_bytes(struct regmap *map); | |
146 | 147 | |
147 | 148 | int regcache_sync(struct regmap *map); |
148 | 149 | void regcache_cache_only(struct regmap *map, bool enable); |