summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2025-04-07 22:01:52 +0200
committerTom Rini <trini@konsulko.com>2025-04-16 16:51:45 -0600
commit53e83caa870f45a8470dba85e9bd627f6b3d010d (patch)
treedb00b5766f10ed53d09a003cdad555ee54293191
parent92c8047f24d571a34f8159ee48211d1014797c9d (diff)
regmap: Add regmap_set/clear_bits shorthands
Port Linux kernel regmap_set/clear_bits shorthands to set and clear bits in a regmap. These are handy if only specific bits needs to be applied or cleared and makes it easier to port regmap based driver from kernel upstream. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
-rw-r--r--include/regmap.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/regmap.h b/include/regmap.h
index 22b043408ac..8c6f7c1c9b1 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -362,6 +362,34 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val);
/**
+ * regmap_set_bits() - Set bits to a regmap
+ *
+ * @map: Regmap to write bits to
+ * @offset: Offset in the regmap to write to
+ * @bits: Bits to set to the regmap at the specified offset
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static inline int regmap_set_bits(struct regmap *map, uint offset, uint bits)
+{
+ return regmap_update_bits(map, offset, bits, bits);
+}
+
+/**
+ * regmap_clear_bits() - Clear bits to a regmap
+ *
+ * @map: Regmap to write bits to
+ * @offset: Offset in the regmap to write to
+ * @bits: Bits to clear to the regmap at the specified offset
+ *
+ * Return: 0 if OK, -ve on error
+ */
+static inline int regmap_clear_bits(struct regmap *map, uint offset, uint bits)
+{
+ return regmap_update_bits(map, offset, bits, 0);
+}
+
+/**
* regmap_init_mem() - Set up a new register map that uses memory access
*
* @node: Device node that uses this map