kernel: bump 5.10 to 5.10.175
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 081-net-next-regmap-allow-to-define-reg_update_bits-for-no-bus.patch
1 From 02d6fdecb9c38de19065f6bed8d5214556fd061d Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Thu, 4 Nov 2021 16:00:40 +0100
4 Subject: regmap: allow to define reg_update_bits for no bus configuration
5
6 Some device requires a special handling for reg_update_bits and can't use
7 the normal regmap read write logic. An example is when locking is
8 handled by the device and rmw operations requires to do atomic operations.
9 Allow to declare a dedicated function in regmap_config for
10 reg_update_bits in no bus configuration.
11
12 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
13 Link: https://lore.kernel.org/r/20211104150040.1260-1-ansuelsmth@gmail.com
14 Signed-off-by: Mark Brown <broonie@kernel.org>
15 ---
16 drivers/base/regmap/regmap.c | 1 +
17 include/linux/regmap.h | 7 +++++++
18 2 files changed, 8 insertions(+)
19
20 --- a/drivers/base/regmap/regmap.c
21 +++ b/drivers/base/regmap/regmap.c
22 @@ -842,6 +842,7 @@ struct regmap *__regmap_init(struct devi
23 if (!bus) {
24 map->reg_read = config->reg_read;
25 map->reg_write = config->reg_write;
26 + map->reg_update_bits = config->reg_update_bits;
27
28 map->defer_caching = false;
29 goto skip_format_initialization;
30 --- a/include/linux/regmap.h
31 +++ b/include/linux/regmap.h
32 @@ -289,6 +289,11 @@ typedef void (*regmap_unlock)(void *);
33 * read operation on a bus such as SPI, I2C, etc. Most of the
34 * devices do not need this.
35 * @reg_write: Same as above for writing.
36 + * @reg_update_bits: Optional callback that if filled will be used to perform
37 + * all the update_bits(rmw) operation. Should only be provided
38 + * if the function require special handling with lock and reg
39 + * handling and the operation cannot be represented as a simple
40 + * update_bits operation on a bus such as SPI, I2C, etc.
41 * @fast_io: Register IO is fast. Use a spinlock instead of a mutex
42 * to perform locking. This field is ignored if custom lock/unlock
43 * functions are used (see fields lock/unlock of struct regmap_config).
44 @@ -366,6 +371,8 @@ struct regmap_config {
45
46 int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
47 int (*reg_write)(void *context, unsigned int reg, unsigned int val);
48 + int (*reg_update_bits)(void *context, unsigned int reg,
49 + unsigned int mask, unsigned int val);
50
51 bool fast_io;
52