[PATCH v2 01/17] regmap-irq: Use sub_irq_reg() to calculate unmask register address

From: Aidan MacDonald
Date: Tue Jun 07 2022 - 11:52:57 EST


Call sub_irq_reg() instead of calculating the offset of the register
to avoid relying on the fact that sub_irq_reg() is a linear function.
This prepares for allowing drivers to override the default sub_irq_reg
implementation if the default behavior is unsuitable.

Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@xxxxxxxxx>
---
drivers/base/regmap/regmap-irq.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 400c7412a7dc..4a2e1f6aa94d 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -97,7 +97,6 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
struct regmap *map = d->map;
int i, j, ret;
u32 reg;
- u32 unmask_offset;
u32 val;

if (d->chip->runtime_pm) {
@@ -141,11 +140,11 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
dev_err(d->map->dev,
"Failed to sync unmasks in %x\n",
reg);
- unmask_offset = d->chip->unmask_base -
- d->chip->mask_base;
+
/* clear mask with unmask_base register */
+ reg = sub_irq_reg(d, d->chip->unmask_base, i);
ret = regmap_irq_update_bits(d,
- reg + unmask_offset,
+ reg,
d->mask_buf_def[i],
d->mask_buf[i]);
} else {
@@ -632,7 +631,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
int ret = -ENOMEM;
int num_type_reg;
u32 reg;
- u32 unmask_offset;

if (chip->num_regs <= 0)
return -EINVAL;
@@ -773,10 +771,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
ret = regmap_irq_update_bits(d, 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;
+ reg = sub_irq_reg(d, d->chip->unmask_base, i);
ret = regmap_irq_update_bits(d,
- reg + unmask_offset,
+ reg,
d->mask_buf[i],
d->mask_buf[i]);
} else
--
2.35.1