linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH] regmap: allow to define reg_update_bits for no bus configuration
@ 2021-11-11  1:41 Ansuel Smith
  2021-11-11 12:39 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Ansuel Smith @ 2021-11-11  1:41 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel
  Cc: Ansuel Smith

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 special function in regmap_config for reg_update_bits
as we do with the bus config and append it to the regmap_volatile logic in
_regmap_update_bits.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/base/regmap/regmap.c | 3 ++-
 include/linux/regmap.h       | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 21a0c2562ec0..d6fcb45194b0 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -876,6 +876,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;
@@ -3064,7 +3065,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
 	if (change)
 		*change = false;
 
-	if (regmap_volatile(map, reg) && map->reg_update_bits) {
+	if ((regmap_volatile(map, reg) || !map->bus) && map->reg_update_bits) {
 		ret = map->reg_update_bits(map->bus_context, reg, mask, val);
 		if (ret == 0 && change)
 			*change = true;
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index e3c9a25a853a..22652e5fbc38 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -290,6 +290,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).
@@ -372,6 +377,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;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] regmap: allow to define reg_update_bits for no bus configuration
  2021-11-11  1:41 [RESEND PATCH] regmap: allow to define reg_update_bits for no bus configuration Ansuel Smith
@ 2021-11-11 12:39 ` Mark Brown
  2021-11-11 14:49   ` Ansuel Smith
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2021-11-11 12:39 UTC (permalink / raw)
  To: Ansuel Smith; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

On Thu, Nov 11, 2021 at 02:41:38AM +0100, Ansuel Smith wrote:
> 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.

Please allow a reasonable time for review and remember that it's the
merge window right now so no new patches are being applied.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] regmap: allow to define reg_update_bits for no bus configuration
  2021-11-11 12:39 ` Mark Brown
@ 2021-11-11 14:49   ` Ansuel Smith
  2021-11-11 15:16     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Ansuel Smith @ 2021-11-11 14:49 UTC (permalink / raw)
  To: Mark Brown; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel

On Thu, Nov 11, 2021 at 12:39:23PM +0000, Mark Brown wrote:
> On Thu, Nov 11, 2021 at 02:41:38AM +0100, Ansuel Smith wrote:
> > 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.
> 
> Please allow a reasonable time for review and remember that it's the
> merge window right now so no new patches are being applied.

I'm so sorry. I had some problem last time with sending v2 that got
rejected automatically by patchwork and I thought it was the same for
this. Again sorry.

-- 
	Ansuel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] regmap: allow to define reg_update_bits for no bus configuration
  2021-11-11 14:49   ` Ansuel Smith
@ 2021-11-11 15:16     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2021-11-11 15:16 UTC (permalink / raw)
  To: Ansuel Smith; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 606 bytes --]

On Thu, Nov 11, 2021 at 03:49:33PM +0100, Ansuel Smith wrote:
> On Thu, Nov 11, 2021 at 12:39:23PM +0000, Mark Brown wrote:

> > Please allow a reasonable time for review and remember that it's the
> > merge window right now so no new patches are being applied.

> I'm so sorry. I had some problem last time with sending v2 that got
> rejected automatically by patchwork and I thought it was the same for
> this. Again sorry.

The patchwork instance for LKML is now read only (at some point it might
even get converted to just point at the threads in lore automatically
IIRC) - nothing new is being added.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-11 15:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11  1:41 [RESEND PATCH] regmap: allow to define reg_update_bits for no bus configuration Ansuel Smith
2021-11-11 12:39 ` Mark Brown
2021-11-11 14:49   ` Ansuel Smith
2021-11-11 15:16     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).