Skip to content

Commit 22250db

Browse files
committed
regmap: Merge fix for where we get the number of registers from
This didn't get sent for 6.1 since we should do a better fix but that didn't happen in time.
2 parents 69af4bc + 84498d1 commit 22250db

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/base/regmap/regmap-irq.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
730730
int i;
731731
int ret = -ENOMEM;
732732
int num_type_reg;
733+
int num_regs;
733734
u32 reg;
734735

735736
if (chip->num_regs <= 0)
@@ -804,14 +805,20 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
804805
goto err_alloc;
805806
}
806807

807-
num_type_reg = chip->type_in_mask ? chip->num_regs : chip->num_type_reg;
808-
if (num_type_reg) {
809-
d->type_buf_def = kcalloc(num_type_reg,
808+
/*
809+
* Use num_config_regs if defined, otherwise fall back to num_type_reg
810+
* to maintain backward compatibility.
811+
*/
812+
num_type_reg = chip->num_config_regs ? chip->num_config_regs
813+
: chip->num_type_reg;
814+
num_regs = chip->type_in_mask ? chip->num_regs : num_type_reg;
815+
if (num_regs) {
816+
d->type_buf_def = kcalloc(num_regs,
810817
sizeof(*d->type_buf_def), GFP_KERNEL);
811818
if (!d->type_buf_def)
812819
goto err_alloc;
813820

814-
d->type_buf = kcalloc(num_type_reg, sizeof(*d->type_buf),
821+
d->type_buf = kcalloc(num_regs, sizeof(*d->type_buf),
815822
GFP_KERNEL);
816823
if (!d->type_buf)
817824
goto err_alloc;

0 commit comments

Comments
 (0)