[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220607155324.118102-2-aidanmacdonald.0x0@gmail.com>
Date: Tue, 7 Jun 2022 16:53:08 +0100
From: Aidan MacDonald <aidanmacdonald.0x0@...il.com>
To: linus.walleij@...aro.org, brgl@...ev.pl, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, wens@...e.org, jic23@...nel.org,
lee.jones@...aro.org, sre@...nel.org, broonie@...nel.org,
gregkh@...uxfoundation.org, lgirdwood@...il.com
Cc: lars@...afoo.de, rafael@...nel.org, quic_gurus@...cinc.com,
linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
linux-pm@...r.kernel.org
Subject: [PATCH v2 01/17] regmap-irq: Use sub_irq_reg() to calculate unmask register address
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@...il.com>
---
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
Powered by blists - more mailing lists