]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
regmap: allow to define reg_update_bits for no bus configuration
authorAnsuel Smith <ansuelsmth@gmail.com>
Thu, 4 Nov 2021 15:00:40 +0000 (16:00 +0100)
committerSasha Levin <sashal@kernel.org>
Fri, 15 Mar 2024 14:48:22 +0000 (10:48 -0400)
[ Upstream commit 02d6fdecb9c38de19065f6bed8d5214556fd061d ]

Some device requires a special handling for reg_update_bits and can't use
the normal regmap read write logic. An example is when locking is
handled by the device and rmw operations requires to do atomic operations.
Allow to declare a dedicated function in regmap_config for
reg_update_bits in no bus configuration.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20211104150040.1260-1-ansuelsmth@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Stable-dep-of: 3f42b142ea11 ("serial: max310x: fix IO data corruption in batched operations")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/regmap/regmap.c
include/linux/regmap.h

index 7bc603145bd981157be4cbb97d3f8c372e658794..8f39aacdad0dcd457d91feb9f1e6bf377adce9ef 100644 (file)
@@ -842,6 +842,7 @@ struct regmap *__regmap_init(struct device *dev,
        if (!bus) {
                map->reg_read  = config->reg_read;
                map->reg_write = config->reg_write;
+               map->reg_update_bits = config->reg_update_bits;
 
                map->defer_caching = false;
                goto skip_format_initialization;
index e7834d98207f7a3c7dccd5fa40b7a068ac7228e4..d6f0d876fa42450bb43261d655c02d9fffd34f57 100644 (file)
@@ -289,6 +289,11 @@ typedef void (*regmap_unlock)(void *);
  *               read operation on a bus such as SPI, I2C, etc. Most of the
  *               devices do not need this.
  * @reg_write:   Same as above for writing.
+ * @reg_update_bits: Optional callback that if filled will be used to perform
+ *                  all the update_bits(rmw) operation. Should only be provided
+ *                  if the function require special handling with lock and reg
+ *                  handling and the operation cannot be represented as a simple
+ *                  update_bits operation on a bus such as SPI, I2C, etc.
  * @fast_io:     Register IO is fast. Use a spinlock instead of a mutex
  *               to perform locking. This field is ignored if custom lock/unlock
  *               functions are used (see fields lock/unlock of struct regmap_config).
@@ -366,6 +371,8 @@ struct regmap_config {
 
        int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
        int (*reg_write)(void *context, unsigned int reg, unsigned int val);
+       int (*reg_update_bits)(void *context, unsigned int reg,
+                              unsigned int mask, unsigned int val);
 
        bool fast_io;