Skip to content

Commit f7cc506

Browse files
Aidan MacDonaldbroonie
authored andcommitted
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: Aidan MacDonald <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ad22b3e commit f7cc506

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/base/regmap/regmap-irq.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data,
7373
return &data->chip->irqs[irq];
7474
}
7575

76+
static bool regmap_irq_can_bulk_read_status(struct regmap_irq_chip_data *data)
77+
{
78+
struct regmap *map = data->map;
79+
80+
return data->irq_reg_stride == 1 && map->reg_stride == 1 &&
81+
!map->use_single_read;
82+
}
83+
7684
static void regmap_irq_lock(struct irq_data *data)
7785
{
7886
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)
467475
}
468476

469477
}
470-
} else if (!map->use_single_read && map->reg_stride == 1 &&
471-
data->irq_reg_stride == 1) {
478+
} else if (regmap_irq_can_bulk_read_status(data)) {
472479

473480
u8 *buf8 = data->status_reg_buf;
474481
u16 *buf16 = data->status_reg_buf;
@@ -729,8 +736,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
729736
else
730737
d->irq_reg_stride = 1;
731738

732-
if (!map->use_single_read && map->reg_stride == 1 &&
733-
d->irq_reg_stride == 1) {
739+
if (regmap_irq_can_bulk_read_status(d)) {
734740
d->status_reg_buf = kmalloc_array(chip->num_regs,
735741
map->format.val_bytes,
736742
GFP_KERNEL);

0 commit comments

Comments
 (0)