081-v5.17-regmap-allow-to-define-reg_update_bits-for-no-bus.patch 2.3 KB

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