summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2022-06-15 18:03:19 +0100
committerMark Brown <broonie@kernel.org>2022-06-15 18:03:19 +0100
commit26968e614adb7e0c0ff3e36629669135ef690a57 (patch)
tree7f988344141a5338bc9f77f5a7f602d406308193 /drivers
parent72607f372c9c27af458e4fa1411fbd3a2a448386 (diff)
parentf67be8b7ee90c292948c3ec6395673963cccaee6 (diff)
downloadlinux-26968e614adb7e0c0ff3e36629669135ef690a57.tar.bz2
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')
-rw-r--r--drivers/base/regmap/regmap.c22
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
*