All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4][RFC] regmap: add force write option
@ 2015-06-16  8:51 Kuninori Morimoto
  2015-06-16  8:52 ` [PATCH 1/4][RFC] regmap: add force_write option on _regmap_update_bits() Kuninori Morimoto
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-06-16  8:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba


Hi Mark

Current _regmap_update_bits() writes data to register if current value and
write value was different. This means it doesn't write data if the value was
same as current value.
But, some device needs to write data even though it was same value.

This RFC patch-set adds new "force_write" option on _regmap_update_bits()
for this issue, but it focuses only 1 regmap write function at this point,
because there are many regmap_xxx_write_yyy() functions.
I can care all of regmap_xxx_write_yyy() functions in formal patch-set if
this RFC patch idea was OK.

What do you think about this idea ?

Kuninori Morimoto (4):
      regmap: add force_write option on _regmap_update_bits()
      regmap: add regmap_write_bits()
      regmap: add regmap_fields_force_write()
      ASoC: rsnd: gen: add rsnd_force_write()

 drivers/base/regmap/regmap.c | 51 +++++++++++++++++++++++++++++++++++++++++++--------
 include/linux/regmap.h       | 11 +++++++++++
 sound/soc/sh/rcar/gen.c      | 16 ++++++++++++++++
 sound/soc/sh/rcar/rsnd.h     |  4 ++++
 4 files changed, 74 insertions(+), 8 deletions(-)


Best regards
---
Kuninori Morimoto

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

* [PATCH 1/4][RFC] regmap: add force_write option on _regmap_update_bits()
  2015-06-16  8:51 [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
@ 2015-06-16  8:52 ` Kuninori Morimoto
  2015-07-10 10:40   ` Applied "regmap: add force_write option on _regmap_update_bits()" to the regmap tree Mark Brown
  2015-06-16  8:52 ` [PATCH 2/4][RFC] regmap: add regmap_write_bits() Kuninori Morimoto
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Kuninori Morimoto @ 2015-06-16  8:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba

Sometimes we want to write data even though it doesn't change value.
Then, force_write option on _regmap_update_bits() helps this purpose.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/base/regmap/regmap.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e5eef6f..beb98c6 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -34,7 +34,7 @@
 
 static int _regmap_update_bits(struct regmap *map, unsigned int reg,
 			       unsigned int mask, unsigned int val,
-			       bool *change);
+			       bool *change, bool force_write);
 
 static int _regmap_bus_reg_read(void *context, unsigned int reg,
 				unsigned int *val);
@@ -1179,7 +1179,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg,
 		ret = _regmap_update_bits(map, range->selector_reg,
 					  range->selector_mask,
 					  win_page << range->selector_shift,
-					  &page_chg);
+					  &page_chg, false);
 
 		map->work_buf = orig_work_buf;
 
@@ -2328,7 +2328,7 @@ EXPORT_SYMBOL_GPL(regmap_bulk_read);
 
 static int _regmap_update_bits(struct regmap *map, unsigned int reg,
 			       unsigned int mask, unsigned int val,
-			       bool *change)
+			       bool *change, bool force_write)
 {
 	int ret;
 	unsigned int tmp, orig;
@@ -2340,7 +2340,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
 	tmp = orig & ~mask;
 	tmp |= val & mask;
 
-	if (tmp != orig) {
+	if (force_write || (tmp != orig)) {
 		ret = _regmap_write(map, reg, tmp);
 		if (change)
 			*change = true;
@@ -2368,7 +2368,7 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
 	int ret;
 
 	map->lock(map->lock_arg);
-	ret = _regmap_update_bits(map, reg, mask, val, NULL);
+	ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
 	map->unlock(map->lock_arg);
 
 	return ret;
@@ -2399,7 +2399,7 @@ int regmap_update_bits_async(struct regmap *map, unsigned int reg,
 
 	map->async = true;
 
-	ret = _regmap_update_bits(map, reg, mask, val, NULL);
+	ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
 
 	map->async = false;
 
@@ -2428,7 +2428,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
 	int ret;
 
 	map->lock(map->lock_arg);
-	ret = _regmap_update_bits(map, reg, mask, val, change);
+	ret = _regmap_update_bits(map, reg, mask, val, change, false);
 	map->unlock(map->lock_arg);
 	return ret;
 }
@@ -2461,7 +2461,7 @@ int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
 
 	map->async = true;
 
-	ret = _regmap_update_bits(map, reg, mask, val, change);
+	ret = _regmap_update_bits(map, reg, mask, val, change, false);
 
 	map->async = false;
 
-- 
1.9.1


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

* [PATCH 2/4][RFC] regmap: add regmap_write_bits()
  2015-06-16  8:51 [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
  2015-06-16  8:52 ` [PATCH 1/4][RFC] regmap: add force_write option on _regmap_update_bits() Kuninori Morimoto
@ 2015-06-16  8:52 ` Kuninori Morimoto
  2015-07-10 10:40   ` Applied "regmap: add regmap_write_bits()" to the regmap tree Mark Brown
  2015-06-16  8:52 ` [PATCH 3/4][RFC] regmap: add regmap_fields_force_write() Kuninori Morimoto
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Kuninori Morimoto @ 2015-06-16  8:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba

regmap_write_bits() is similar to regmap_update_bits(),
but regmap_write_bits() write data to register even though
it is same value.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/base/regmap/regmap.c | 23 +++++++++++++++++++++++
 include/linux/regmap.h       |  9 +++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index beb98c6..a5bb3fa 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2376,6 +2376,29 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
 EXPORT_SYMBOL_GPL(regmap_update_bits);
 
 /**
+ * regmap_write_bits: Perform a read/modify/write cycle on the register map
+ *
+ * @map: Register map to update
+ * @reg: Register to update
+ * @mask: Bitmask to change
+ * @val: New value for bitmask
+ *
+ * Returns zero for success, a negative number on error.
+ */
+int regmap_write_bits(struct regmap *map, unsigned int reg,
+		      unsigned int mask, unsigned int val)
+{
+	int ret;
+
+	map->lock(map->lock_arg);
+	ret = _regmap_update_bits(map, reg, mask, val, NULL, true);
+	map->unlock(map->lock_arg);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(regmap_write_bits);
+
+/**
  * regmap_update_bits_async: Perform a read/modify/write cycle on the register
  *                           map asynchronously
  *
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 59c55ea..e4b9ad4 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -424,6 +424,8 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 		     size_t val_count);
 int regmap_update_bits(struct regmap *map, unsigned int reg,
 		       unsigned int mask, unsigned int val);
+int regmap_write_bits(struct regmap *map, unsigned int reg,
+		       unsigned int mask, unsigned int val);
 int regmap_update_bits_async(struct regmap *map, unsigned int reg,
 			     unsigned int mask, unsigned int val);
 int regmap_update_bits_check(struct regmap *map, unsigned int reg,
@@ -645,6 +647,13 @@ static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
 	return -EINVAL;
 }
 
+static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
+				     unsigned int mask, unsigned int val)
+{
+	WARN_ONCE(1, "regmap API is disabled");
+	return -EINVAL;
+}
+
 static inline int regmap_update_bits_async(struct regmap *map,
 					   unsigned int reg,
 					   unsigned int mask, unsigned int val)
-- 
1.9.1


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

* [PATCH 3/4][RFC] regmap: add regmap_fields_force_write()
  2015-06-16  8:51 [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
  2015-06-16  8:52 ` [PATCH 1/4][RFC] regmap: add force_write option on _regmap_update_bits() Kuninori Morimoto
  2015-06-16  8:52 ` [PATCH 2/4][RFC] regmap: add regmap_write_bits() Kuninori Morimoto
@ 2015-06-16  8:52 ` Kuninori Morimoto
  2015-07-10 10:40   ` Applied "regmap: add regmap_fields_force_write()" to the regmap tree Mark Brown
  2015-06-16  8:53 ` [PATCH 4/4][RFC] ASoC: rsnd: gen: add rsnd_force_write() Kuninori Morimoto
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Kuninori Morimoto @ 2015-06-16  8:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba

regmap_fields_force_write() is similar to regmap_fields_write(),
but regmap_fields_force_write() write data to register even though
it is same value.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/base/regmap/regmap.c | 12 ++++++++++++
 include/linux/regmap.h       |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index a5bb3fa..c07d74b 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1625,6 +1625,18 @@ int regmap_fields_write(struct regmap_field *field, unsigned int id,
 }
 EXPORT_SYMBOL_GPL(regmap_fields_write);
 
+int regmap_fields_force_write(struct regmap_field *field, unsigned int id,
+			unsigned int val)
+{
+	if (id >= field->id_size)
+		return -EINVAL;
+
+	return regmap_write_bits(field->regmap,
+				  field->reg + (field->id_offset * id),
+				  field->mask, val << field->shift);
+}
+EXPORT_SYMBOL_GPL(regmap_fields_force_write);
+
 /**
  * regmap_fields_update_bits():	Perform a read/modify/write cycle
  *                              on the register field
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index e4b9ad4..519c962 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -505,6 +505,8 @@ int regmap_field_update_bits(struct regmap_field *field,
 
 int regmap_fields_write(struct regmap_field *field, unsigned int id,
 			unsigned int val);
+int regmap_fields_force_write(struct regmap_field *field, unsigned int id,
+			unsigned int val);
 int regmap_fields_read(struct regmap_field *field, unsigned int id,
 		       unsigned int *val);
 int regmap_fields_update_bits(struct regmap_field *field,  unsigned int id,
-- 
1.9.1


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

* [PATCH 4/4][RFC] ASoC: rsnd: gen: add rsnd_force_write()
  2015-06-16  8:51 [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2015-06-16  8:52 ` [PATCH 3/4][RFC] regmap: add regmap_fields_force_write() Kuninori Morimoto
@ 2015-06-16  8:53 ` Kuninori Morimoto
  2015-07-02  7:07 ` [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
  2015-07-02  7:46 ` Lars-Peter Clausen
  5 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-06-16  8:53 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba

rsnd_force_write() is similar to rsnd_write(),
but rsnd_force_write() write data to register even though
it is same value.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/gen.c  | 16 ++++++++++++++++
 sound/soc/sh/rcar/rsnd.h |  4 ++++
 2 files changed, 20 insertions(+)

diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c
index 8c7dc51..48f704b 100644
--- a/sound/soc/sh/rcar/gen.c
+++ b/sound/soc/sh/rcar/gen.c
@@ -103,6 +103,22 @@ void rsnd_write(struct rsnd_priv *priv,
 	regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data);
 }
 
+void rsnd_force_write(struct rsnd_priv *priv,
+		      struct rsnd_mod *mod,
+		      enum rsnd_reg reg, u32 data)
+{
+	struct device *dev = rsnd_priv_to_dev(priv);
+	struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
+
+	if (!rsnd_is_accessible_reg(priv, gen, reg))
+		return;
+
+	dev_dbg(dev, "w %s[%d] - %4d : %08x\n",
+		rsnd_mod_name(mod), rsnd_mod_id(mod), reg, data);
+
+	regmap_fields_force_write(gen->regs[reg], rsnd_mod_id(mod), data);
+}
+
 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
 	       enum rsnd_reg reg, u32 mask, u32 data)
 {
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 03ff071..9760183 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -157,12 +157,16 @@ struct rsnd_dai_stream;
 	rsnd_read(rsnd_mod_to_priv(m), m, RSND_REG_##r)
 #define rsnd_mod_write(m, r, d) \
 	rsnd_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d)
+#define rsnd_mod_force_write(m, r, d) \
+	rsnd_force_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d)
 #define rsnd_mod_bset(m, r, s, d) \
 	rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d)
 
 u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg);
 void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
 		enum rsnd_reg reg, u32 data);
+void rsnd_force_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
+		enum rsnd_reg reg, u32 data);
 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
 		    u32 mask, u32 data);
 u32 rsnd_get_adinr(struct rsnd_mod *mod);
-- 
1.9.1


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

* Re: [PATCH 0/4][RFC] regmap: add force write option
  2015-06-16  8:51 [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2015-06-16  8:53 ` [PATCH 4/4][RFC] ASoC: rsnd: gen: add rsnd_force_write() Kuninori Morimoto
@ 2015-07-02  7:07 ` Kuninori Morimoto
  2015-07-03 12:48   ` Mark Brown
  2015-07-02  7:46 ` Lars-Peter Clausen
  5 siblings, 1 reply; 13+ messages in thread
From: Kuninori Morimoto @ 2015-07-02  7:07 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba


Hi Mark

Can I have some feedback about these patches ?

> Current _regmap_update_bits() writes data to register if current value and
> write value was different. This means it doesn't write data if the value was
> same as current value.
> But, some device needs to write data even though it was same value.
> 
> This RFC patch-set adds new "force_write" option on _regmap_update_bits()
> for this issue, but it focuses only 1 regmap write function at this point,
> because there are many regmap_xxx_write_yyy() functions.
> I can care all of regmap_xxx_write_yyy() functions in formal patch-set if
> this RFC patch idea was OK.
> 
> What do you think about this idea ?
> 
> Kuninori Morimoto (4):
>       regmap: add force_write option on _regmap_update_bits()
>       regmap: add regmap_write_bits()
>       regmap: add regmap_fields_force_write()
>       ASoC: rsnd: gen: add rsnd_force_write()
> 
>  drivers/base/regmap/regmap.c | 51 +++++++++++++++++++++++++++++++++++++++++++--------
>  include/linux/regmap.h       | 11 +++++++++++
>  sound/soc/sh/rcar/gen.c      | 16 ++++++++++++++++
>  sound/soc/sh/rcar/rsnd.h     |  4 ++++
>  4 files changed, 74 insertions(+), 8 deletions(-)
> 
> 
> Best regards
> ---
> Kuninori Morimoto

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

* Re: [PATCH 0/4][RFC] regmap: add force write option
  2015-06-16  8:51 [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2015-07-02  7:07 ` [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
@ 2015-07-02  7:46 ` Lars-Peter Clausen
  2015-07-02  8:58   ` Kuninori Morimoto
  5 siblings, 1 reply; 13+ messages in thread
From: Lars-Peter Clausen @ 2015-07-02  7:46 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba

On 06/16/2015 10:51 AM, Kuninori Morimoto wrote:
>
> Hi Mark
>
> Current _regmap_update_bits() writes data to register if current value and
> write value was different. This means it doesn't write data if the value was
> same as current value.
> But, some device needs to write data even though it was same value.

Can you go into more detail about the exact usecase with a specific example?


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

* Re: [PATCH 0/4][RFC] regmap: add force write option
  2015-07-02  7:46 ` Lars-Peter Clausen
@ 2015-07-02  8:58   ` Kuninori Morimoto
  0 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-07-02  8:58 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Mark Brown, Linux-Kernel, Greg KH, shiiba


Hi Lars

> > Current _regmap_update_bits() writes data to register if current value and
> > write value was different. This means it doesn't write data if the value was
> > same as current value.
> > But, some device needs to write data even though it was same value.
> 
> Can you go into more detail about the exact usecase with a specific example?

Some of our device registers need to be written data even though it was same as current value.
Otherwise, it doesn't work correctly.
Now, its device driver is using regmap. If my understanding was correct, regmap write
function will try to read current data. then it writes data if current data and
write data were not same. this behavior can reduce process, but we had trouble.

pseudo code of current regmap is

xxx regmap_xx_write(reg, new)
{
        old = xx_read(reg);

        if (old != new)
               xxx_write(reg, new);
}

We would like to have "force" write feature

xxx regmap_xx_write(reg, new, force)
{
        old = xx_read(reg);

        /*
         * we would like to write data
         * even though old == new here
         */

        if (force || (old != new))
               xxx_write(reg, new);
}


Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 0/4][RFC] regmap: add force write option
  2015-07-02  7:07 ` [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
@ 2015-07-03 12:48   ` Mark Brown
  2015-07-08  0:52     ` Kuninori Morimoto
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2015-07-03 12:48 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-Kernel, Greg KH, shiiba

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

On Thu, Jul 02, 2015 at 07:07:15AM +0000, Kuninori Morimoto wrote:

> Can I have some feedback about these patches ?

Please do allow some time for review, especially during the merge
window.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH 0/4][RFC] regmap: add force write option
  2015-07-03 12:48   ` Mark Brown
@ 2015-07-08  0:52     ` Kuninori Morimoto
  0 siblings, 0 replies; 13+ messages in thread
From: Kuninori Morimoto @ 2015-07-08  0:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-Kernel, Greg KH, shiiba


Hi Mark

> > Can I have some feedback about these patches ?
> 
> Please do allow some time for review, especially during the merge
> window.

Thank you for your feedback, and sorry for my reminder.
I will re-send these to ML after -rc1 or -rc2

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

* Applied "regmap: add regmap_fields_force_write()" to the regmap tree
  2015-06-16  8:52 ` [PATCH 3/4][RFC] regmap: add regmap_fields_force_write() Kuninori Morimoto
@ 2015-07-10 10:40   ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2015-07-10 10:40 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: linux-kernel

The patch

   regmap: add regmap_fields_force_write()

has been applied to the regmap tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From e874e6c7edc43436f73cf84157d9221f8b807c36 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Tue, 16 Jun 2015 08:52:55 +0000
Subject: [PATCH] regmap: add regmap_fields_force_write()

regmap_fields_force_write() is similar to regmap_fields_write(),
but regmap_fields_force_write() write data to register even though
it is same value.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/base/regmap/regmap.c | 12 ++++++++++++
 include/linux/regmap.h       |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d93bb9a8ab98..dd63bcbbf8a5 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1624,6 +1624,18 @@ int regmap_fields_write(struct regmap_field *field, unsigned int id,
 }
 EXPORT_SYMBOL_GPL(regmap_fields_write);
 
+int regmap_fields_force_write(struct regmap_field *field, unsigned int id,
+			unsigned int val)
+{
+	if (id >= field->id_size)
+		return -EINVAL;
+
+	return regmap_write_bits(field->regmap,
+				  field->reg + (field->id_offset * id),
+				  field->mask, val << field->shift);
+}
+EXPORT_SYMBOL_GPL(regmap_fields_force_write);
+
 /**
  * regmap_fields_update_bits():	Perform a read/modify/write cycle
  *                              on the register field
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index e4b9ad4f05ef..519c96231a91 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -505,6 +505,8 @@ int regmap_field_update_bits(struct regmap_field *field,
 
 int regmap_fields_write(struct regmap_field *field, unsigned int id,
 			unsigned int val);
+int regmap_fields_force_write(struct regmap_field *field, unsigned int id,
+			unsigned int val);
 int regmap_fields_read(struct regmap_field *field, unsigned int id,
 		       unsigned int *val);
 int regmap_fields_update_bits(struct regmap_field *field,  unsigned int id,
-- 
2.1.4


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

* Applied "regmap: add regmap_write_bits()" to the regmap tree
  2015-06-16  8:52 ` [PATCH 2/4][RFC] regmap: add regmap_write_bits() Kuninori Morimoto
@ 2015-07-10 10:40   ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2015-07-10 10:40 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: linux-kernel

The patch

   regmap: add regmap_write_bits()

has been applied to the regmap tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From fd4b7286ccc469bf5dde22db6b8fcc455c3c4a66 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Tue, 16 Jun 2015 08:52:39 +0000
Subject: [PATCH] regmap: add regmap_write_bits()

regmap_write_bits() is similar to regmap_update_bits(),
but regmap_write_bits() write data to register even though
it is same value.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/base/regmap/regmap.c | 23 +++++++++++++++++++++++
 include/linux/regmap.h       |  9 +++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 69ec411ce722..d93bb9a8ab98 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2375,6 +2375,29 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
 EXPORT_SYMBOL_GPL(regmap_update_bits);
 
 /**
+ * regmap_write_bits: Perform a read/modify/write cycle on the register map
+ *
+ * @map: Register map to update
+ * @reg: Register to update
+ * @mask: Bitmask to change
+ * @val: New value for bitmask
+ *
+ * Returns zero for success, a negative number on error.
+ */
+int regmap_write_bits(struct regmap *map, unsigned int reg,
+		      unsigned int mask, unsigned int val)
+{
+	int ret;
+
+	map->lock(map->lock_arg);
+	ret = _regmap_update_bits(map, reg, mask, val, NULL, true);
+	map->unlock(map->lock_arg);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(regmap_write_bits);
+
+/**
  * regmap_update_bits_async: Perform a read/modify/write cycle on the register
  *                           map asynchronously
  *
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 59c55ea0f0b5..e4b9ad4f05ef 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -424,6 +424,8 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 		     size_t val_count);
 int regmap_update_bits(struct regmap *map, unsigned int reg,
 		       unsigned int mask, unsigned int val);
+int regmap_write_bits(struct regmap *map, unsigned int reg,
+		       unsigned int mask, unsigned int val);
 int regmap_update_bits_async(struct regmap *map, unsigned int reg,
 			     unsigned int mask, unsigned int val);
 int regmap_update_bits_check(struct regmap *map, unsigned int reg,
@@ -645,6 +647,13 @@ static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
 	return -EINVAL;
 }
 
+static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
+				     unsigned int mask, unsigned int val)
+{
+	WARN_ONCE(1, "regmap API is disabled");
+	return -EINVAL;
+}
+
 static inline int regmap_update_bits_async(struct regmap *map,
 					   unsigned int reg,
 					   unsigned int mask, unsigned int val)
-- 
2.1.4


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

* Applied "regmap: add force_write option on _regmap_update_bits()" to the regmap tree
  2015-06-16  8:52 ` [PATCH 1/4][RFC] regmap: add force_write option on _regmap_update_bits() Kuninori Morimoto
@ 2015-07-10 10:40   ` Mark Brown
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2015-07-10 10:40 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: linux-kernel

The patch

   regmap: add force_write option on _regmap_update_bits()

has been applied to the regmap tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 7ff0589c7bff4ca31b255ac2028f633f14047762 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Tue, 16 Jun 2015 08:52:22 +0000
Subject: [PATCH] regmap: add force_write option on _regmap_update_bits()

Sometimes we want to write data even though it doesn't change value.
Then, force_write option on _regmap_update_bits() helps this purpose.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/base/regmap/regmap.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 7111d04f2621..69ec411ce722 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -34,7 +34,7 @@
 
 static int _regmap_update_bits(struct regmap *map, unsigned int reg,
 			       unsigned int mask, unsigned int val,
-			       bool *change);
+			       bool *change, bool force_write);
 
 static int _regmap_bus_reg_read(void *context, unsigned int reg,
 				unsigned int *val);
@@ -1178,7 +1178,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg,
 		ret = _regmap_update_bits(map, range->selector_reg,
 					  range->selector_mask,
 					  win_page << range->selector_shift,
-					  &page_chg);
+					  &page_chg, false);
 
 		map->work_buf = orig_work_buf;
 
@@ -2327,7 +2327,7 @@ EXPORT_SYMBOL_GPL(regmap_bulk_read);
 
 static int _regmap_update_bits(struct regmap *map, unsigned int reg,
 			       unsigned int mask, unsigned int val,
-			       bool *change)
+			       bool *change, bool force_write)
 {
 	int ret;
 	unsigned int tmp, orig;
@@ -2339,7 +2339,7 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg,
 	tmp = orig & ~mask;
 	tmp |= val & mask;
 
-	if (tmp != orig) {
+	if (force_write || (tmp != orig)) {
 		ret = _regmap_write(map, reg, tmp);
 		if (change)
 			*change = true;
@@ -2367,7 +2367,7 @@ int regmap_update_bits(struct regmap *map, unsigned int reg,
 	int ret;
 
 	map->lock(map->lock_arg);
-	ret = _regmap_update_bits(map, reg, mask, val, NULL);
+	ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
 	map->unlock(map->lock_arg);
 
 	return ret;
@@ -2398,7 +2398,7 @@ int regmap_update_bits_async(struct regmap *map, unsigned int reg,
 
 	map->async = true;
 
-	ret = _regmap_update_bits(map, reg, mask, val, NULL);
+	ret = _regmap_update_bits(map, reg, mask, val, NULL, false);
 
 	map->async = false;
 
@@ -2427,7 +2427,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
 	int ret;
 
 	map->lock(map->lock_arg);
-	ret = _regmap_update_bits(map, reg, mask, val, change);
+	ret = _regmap_update_bits(map, reg, mask, val, change, false);
 	map->unlock(map->lock_arg);
 	return ret;
 }
@@ -2460,7 +2460,7 @@ int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
 
 	map->async = true;
 
-	ret = _regmap_update_bits(map, reg, mask, val, change);
+	ret = _regmap_update_bits(map, reg, mask, val, change, false);
 
 	map->async = false;
 
-- 
2.1.4


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

end of thread, other threads:[~2015-07-10 10:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-16  8:51 [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
2015-06-16  8:52 ` [PATCH 1/4][RFC] regmap: add force_write option on _regmap_update_bits() Kuninori Morimoto
2015-07-10 10:40   ` Applied "regmap: add force_write option on _regmap_update_bits()" to the regmap tree Mark Brown
2015-06-16  8:52 ` [PATCH 2/4][RFC] regmap: add regmap_write_bits() Kuninori Morimoto
2015-07-10 10:40   ` Applied "regmap: add regmap_write_bits()" to the regmap tree Mark Brown
2015-06-16  8:52 ` [PATCH 3/4][RFC] regmap: add regmap_fields_force_write() Kuninori Morimoto
2015-07-10 10:40   ` Applied "regmap: add regmap_fields_force_write()" to the regmap tree Mark Brown
2015-06-16  8:53 ` [PATCH 4/4][RFC] ASoC: rsnd: gen: add rsnd_force_write() Kuninori Morimoto
2015-07-02  7:07 ` [PATCH 0/4][RFC] regmap: add force write option Kuninori Morimoto
2015-07-03 12:48   ` Mark Brown
2015-07-08  0:52     ` Kuninori Morimoto
2015-07-02  7:46 ` Lars-Peter Clausen
2015-07-02  8:58   ` Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.