Skip to content

Commit

Permalink
regmap: Merge fix for where we get the number of registers from
Browse files Browse the repository at this point in the history
This didn't get sent for 6.1 since we should do a better fix but that
didn't happen in time.
  • Loading branch information
Mark Brown committed Dec 12, 2022
2 parents 69af4bc + 84498d1 commit 22250db
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions drivers/base/regmap/regmap-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
int i;
int ret = -ENOMEM;
int num_type_reg;
int num_regs;
u32 reg;

if (chip->num_regs <= 0)
Expand Down Expand Up @@ -804,14 +805,20 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
goto err_alloc;
}

num_type_reg = chip->type_in_mask ? chip->num_regs : chip->num_type_reg;
if (num_type_reg) {
d->type_buf_def = kcalloc(num_type_reg,
/*
* Use num_config_regs if defined, otherwise fall back to num_type_reg
* to maintain backward compatibility.
*/
num_type_reg = chip->num_config_regs ? chip->num_config_regs
: chip->num_type_reg;
num_regs = chip->type_in_mask ? chip->num_regs : num_type_reg;
if (num_regs) {
d->type_buf_def = kcalloc(num_regs,
sizeof(*d->type_buf_def), GFP_KERNEL);
if (!d->type_buf_def)
goto err_alloc;

d->type_buf = kcalloc(num_type_reg, sizeof(*d->type_buf),
d->type_buf = kcalloc(num_regs, sizeof(*d->type_buf),
GFP_KERNEL);
if (!d->type_buf)
goto err_alloc;
Expand Down

0 comments on commit 22250db

Please sign in to comment.