Commit f7cc5062 authored by Aidan MacDonald's avatar Aidan MacDonald Committed by Mark Brown

regmap-irq: Refactor checks for status bulk read support

There are several conditions that must be satisfied to support
bulk read of status registers. Move the check into a function
to avoid duplicating it in two places.
Signed-off-by: default avatarAidan MacDonald <aidanmacdonald.0x0@gmail.com>
Link: https://lore.kernel.org/r/20220623211420.918875-8-aidanmacdonald.0x0@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ad22b3e9
...@@ -73,6 +73,14 @@ struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data, ...@@ -73,6 +73,14 @@ struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data,
return &data->chip->irqs[irq]; return &data->chip->irqs[irq];
} }
static bool regmap_irq_can_bulk_read_status(struct regmap_irq_chip_data *data)
{
struct regmap *map = data->map;
return data->irq_reg_stride == 1 && map->reg_stride == 1 &&
!map->use_single_read;
}
static void regmap_irq_lock(struct irq_data *data) static void regmap_irq_lock(struct irq_data *data)
{ {
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
...@@ -467,8 +475,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) ...@@ -467,8 +475,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
} }
} }
} else if (!map->use_single_read && map->reg_stride == 1 && } else if (regmap_irq_can_bulk_read_status(data)) {
data->irq_reg_stride == 1) {
u8 *buf8 = data->status_reg_buf; u8 *buf8 = data->status_reg_buf;
u16 *buf16 = data->status_reg_buf; u16 *buf16 = data->status_reg_buf;
...@@ -729,8 +736,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, ...@@ -729,8 +736,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
else else
d->irq_reg_stride = 1; d->irq_reg_stride = 1;
if (!map->use_single_read && map->reg_stride == 1 && if (regmap_irq_can_bulk_read_status(d)) {
d->irq_reg_stride == 1) {
d->status_reg_buf = kmalloc_array(chip->num_regs, d->status_reg_buf = kmalloc_array(chip->num_regs,
map->format.val_bytes, map->format.val_bytes,
GFP_KERNEL); GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment