diff options
author | 2022-06-15 18:03:19 +0100 | |
---|---|---|
committer | 2022-06-15 18:03:19 +0100 | |
commit | 26968e614adb7e0c0ff3e36629669135ef690a57 (patch) | |
tree | 7f988344141a5338bc9f77f5a7f602d406308193 /drivers/base | |
parent | regmap: cache: Fix syntax errors in comments (diff) | |
parent | regmap: provide regmap_field helpers for simple bit operations (diff) | |
download | linux-26968e614adb7e0c0ff3e36629669135ef690a57.tar.gz linux-26968e614adb7e0c0ff3e36629669135ef690a57.tar.bz2 linux-26968e614adb7e0c0ff3e36629669135ef690a57.zip |
Merge tag 'regmap-field-bit-helpers' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-5.20
regmap: Add regmap_field helpers for simple bit operations
Add simple bit operations for setting, clearing and testing specific
bits with regmap_field.
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/regmap/regmap.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 2221d9863831..cb0be5e7b100 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2221,6 +2221,28 @@ int regmap_field_update_bits_base(struct regmap_field *field, EXPORT_SYMBOL_GPL(regmap_field_update_bits_base); /** + * regmap_field_test_bits() - Check if all specified bits are set in a + * register field. + * + * @field: Register field to operate on + * @bits: Bits to test + * + * Returns -1 if the underlying regmap_field_read() fails, 0 if at least one of the + * tested bits is not set and 1 if all tested bits are set. + */ +int regmap_field_test_bits(struct regmap_field *field, unsigned int bits) +{ + unsigned int val, ret; + + ret = regmap_field_read(field, &val); + if (ret) + return ret; + + return (val & bits) == bits; +} +EXPORT_SYMBOL_GPL(regmap_field_test_bits); + +/** * regmap_fields_update_bits_base() - Perform a read/modify/write cycle a * register field with port ID * |