public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
To: broonie@kernel.org
Cc: gregkh@linuxfoundation.org, rafael@kernel.org,
	andy.shevchenko@gmail.com, mazziesaccount@gmail.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 06/12] regmap-irq: Remove mask_writeonly and regmap_irq_update_bits()
Date: Thu, 23 Jun 2022 22:14:14 +0100	[thread overview]
Message-ID: <20220623211420.918875-7-aidanmacdonald.0x0@gmail.com> (raw)
In-Reply-To: <20220623211420.918875-1-aidanmacdonald.0x0@gmail.com>

Commit a71411dbf6c8 ("regmap: irq: add chip option mask_writeonly")
introduced the mask_writeonly option, but it isn't used now and it
appears it's never been used by any in-tree drivers. The motivation
for the option is mentioned in the commit message,

    Some irq controllers have writeonly/multipurpose register
    layouts. In those cases we read invalid data back. [...]

The option causes mask register updates to use regmap_write_bits()
instead of regmap_update_bits().

However, regmap_write_bits() doesn't solve the reading invalid data
problem. It's still a read-modify-write op like regmap_update_bits().
The difference is that 'update bits' will only write the new value
if it is different from the current value, while 'write bits' will
write the new value unconditionally, even if it's the same as the
current value.

This seems like a bit of a specialized use case and probably isn't
that useful for regmap-irq, so let's just remove the option and go
back to using an 'update bits' op for the mask registers. We can
always add the option back if some driver ends up needing it in the
future.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
---
 drivers/base/regmap/regmap-irq.c | 24 +++++++-----------------
 include/linux/regmap.h           |  2 --
 2 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index cb20ce6f91e7..7e93dd8af56b 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -80,16 +80,6 @@ static void regmap_irq_lock(struct irq_data *data)
 	mutex_lock(&d->lock);
 }
 
-static int regmap_irq_update_bits(struct regmap_irq_chip_data *d,
-				  unsigned int reg, unsigned int mask,
-				  unsigned int val)
-{
-	if (d->chip->mask_writeonly)
-		return regmap_write_bits(d->map, reg, mask, val);
-	else
-		return regmap_update_bits(d->map, reg, mask, val);
-}
-
 static void regmap_irq_sync_unlock(struct irq_data *data)
 {
 	struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
@@ -130,11 +120,11 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 
 		reg = sub_irq_reg(d, d->chip->mask_base, i);
 		if (d->chip->mask_invert) {
-			ret = regmap_irq_update_bits(d, reg,
+			ret = regmap_update_bits(d->map, reg,
 					 d->mask_buf_def[i], ~d->mask_buf[i]);
 		} else if (d->chip->unmask_base) {
 			/* set mask with mask_base register */
-			ret = regmap_irq_update_bits(d, reg,
+			ret = regmap_update_bits(d->map, reg,
 					d->mask_buf_def[i], ~d->mask_buf[i]);
 			if (ret < 0)
 				dev_err(d->map->dev,
@@ -143,12 +133,12 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
 			unmask_offset = d->chip->unmask_base -
 							d->chip->mask_base;
 			/* clear mask with unmask_base register */
-			ret = regmap_irq_update_bits(d,
+			ret = regmap_update_bits(d->map,
 					reg + unmask_offset,
 					d->mask_buf_def[i],
 					d->mask_buf[i]);
 		} else {
-			ret = regmap_irq_update_bits(d, reg,
+			ret = regmap_update_bits(d->map, reg,
 					 d->mask_buf_def[i], d->mask_buf[i]);
 		}
 		if (ret != 0)
@@ -763,17 +753,17 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 		reg = sub_irq_reg(d, d->chip->mask_base, i);
 
 		if (chip->mask_invert)
-			ret = regmap_irq_update_bits(d, reg,
+			ret = regmap_update_bits(d->map, reg,
 					 d->mask_buf[i], ~d->mask_buf[i]);
 		else if (d->chip->unmask_base) {
 			unmask_offset = d->chip->unmask_base -
 					d->chip->mask_base;
-			ret = regmap_irq_update_bits(d,
+			ret = regmap_update_bits(d->map,
 					reg + unmask_offset,
 					d->mask_buf[i],
 					d->mask_buf[i]);
 		} else
-			ret = regmap_irq_update_bits(d, reg,
+			ret = regmap_update_bits(d->map, reg,
 					 d->mask_buf[i], d->mask_buf[i]);
 		if (ret != 0) {
 			dev_err(map->dev, "Failed to set masks in 0x%x: %d\n",
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 106ca1172d3d..d21eb8ad2675 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1452,7 +1452,6 @@ struct regmap_irq_sub_irq_map {
  *
  * @status_base: Base status register address.
  * @mask_base:   Base mask register address.
- * @mask_writeonly: Base mask register is write only.
  * @unmask_base:  Base unmask register address. for chips who have
  *                separate mask and unmask registers
  * @ack_base:    Base ack address. If zero then the chip is clear on read.
@@ -1518,7 +1517,6 @@ struct regmap_irq_chip {
 	unsigned int type_base;
 	unsigned int *virt_reg_base;
 	unsigned int irq_reg_stride;
-	unsigned int mask_writeonly:1;
 	unsigned int init_ack_masked:1;
 	unsigned int mask_invert:1;
 	unsigned int use_ack:1;
-- 
2.35.1


  parent reply	other threads:[~2022-06-23 21:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 21:14 [PATCH v2 00/12] regmap-irq cleanups and refactoring Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 01/12] regmap-irq: Convert bool bitfields to unsigned int Aidan MacDonald
2022-06-23 21:26   ` Andy Shevchenko
2022-06-24 12:11     ` Mark Brown
2022-06-24 12:46       ` Joe Perches
2022-06-24 12:56         ` Mark Brown
2022-06-24 13:05         ` Aidan MacDonald
2022-06-24 13:45           ` Joe Perches
2022-06-24 14:28             ` David Laight
2022-06-24 14:31             ` Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 02/12] regmap-irq: Remove unused type_reg_stride field Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 03/12] regmap-irq: Cleanup sizeof(...) use in memory allocation Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 04/12] regmap-irq: Remove an unnecessary restriction on type_in_mask Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 05/12] regmap-irq: Remove inappropriate uses of regmap_irq_update_bits() Aidan MacDonald
2022-06-23 21:14 ` Aidan MacDonald [this message]
2022-06-23 21:14 ` [PATCH v2 07/12] regmap-irq: Refactor checks for status bulk read support Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 08/12] regmap-irq: Introduce config registers for irq types Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 09/12] regmap-irq: Deprecate type registers and virtual registers Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 10/12] regmap-irq: Fix inverted handling of unmask registers Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 11/12] regmap-irq: Add get_irq_reg() callback Aidan MacDonald
2022-07-01 16:33   ` Marek Szyprowski
2022-07-03 11:06     ` Aidan MacDonald
2022-06-23 21:14 ` [PATCH v2 12/12] regmap-irq: Deprecate the not_fixed_stride flag Aidan MacDonald
2022-06-30 17:27 ` [PATCH v2 00/12] regmap-irq cleanups and refactoring Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220623211420.918875-7-aidanmacdonald.0x0@gmail.com \
    --to=aidanmacdonald.0x0@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox