Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

+11 -4
+11 -4
drivers/base/regmap/regmap-irq.c
··· 730 730 int i; 731 731 int ret = -ENOMEM; 732 732 int num_type_reg; 733 + int num_regs; 733 734 u32 reg; 734 735 735 736 if (chip->num_regs <= 0) ··· 805 804 goto err_alloc; 806 805 } 807 806 808 - num_type_reg = chip->type_in_mask ? chip->num_regs : chip->num_type_reg; 809 - if (num_type_reg) { 810 - d->type_buf_def = kcalloc(num_type_reg, 807 + /* 808 + * Use num_config_regs if defined, otherwise fall back to num_type_reg 809 + * to maintain backward compatibility. 810 + */ 811 + num_type_reg = chip->num_config_regs ? chip->num_config_regs 812 + : chip->num_type_reg; 813 + num_regs = chip->type_in_mask ? chip->num_regs : num_type_reg; 814 + if (num_regs) { 815 + d->type_buf_def = kcalloc(num_regs, 811 816 sizeof(*d->type_buf_def), GFP_KERNEL); 812 817 if (!d->type_buf_def) 813 818 goto err_alloc; 814 819 815 - d->type_buf = kcalloc(num_type_reg, sizeof(*d->type_buf), 820 + d->type_buf = kcalloc(num_regs, sizeof(*d->type_buf), 816 821 GFP_KERNEL); 817 822 if (!d->type_buf) 818 823 goto err_alloc;