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

pinctrl: imx: Use temporary variable to hold pins

The pins are allocated from the heap, but in order to pass
them as constant object, we need to use non-constant pointer.
Achieve this by using a temporary variable.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231129161459.1002323-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
26ea8229 271e6a04

+9 -8
+9 -8
drivers/pinctrl/freescale/pinctrl-imx.c
··· 511 511 { 512 512 const struct imx_pinctrl_soc_info *info = ipctl->info; 513 513 struct imx_pin *pin; 514 + unsigned int *pins; 514 515 int size, pin_size; 515 516 const __be32 *list; 516 517 int i; ··· 558 557 grp->data = devm_kcalloc(ipctl->dev, 559 558 grp->num_pins, sizeof(struct imx_pin), 560 559 GFP_KERNEL); 561 - grp->pins = devm_kcalloc(ipctl->dev, 562 - grp->num_pins, sizeof(unsigned int), 563 - GFP_KERNEL); 564 - if (!grp->pins || !grp->data) 560 + if (!grp->data) 565 561 return -ENOMEM; 562 + 563 + pins = devm_kcalloc(ipctl->dev, grp->num_pins, sizeof(*pins), GFP_KERNEL); 564 + if (!pins) 565 + return -ENOMEM; 566 + grp->pins = pins; 566 567 567 568 for (i = 0; i < grp->num_pins; i++) { 568 569 pin = &((struct imx_pin *)(grp->data))[i]; 569 570 if (info->flags & IMX_USE_SCU) 570 - info->imx_pinctrl_parse_pin(ipctl, &grp->pins[i], 571 - pin, &list); 571 + info->imx_pinctrl_parse_pin(ipctl, &pins[i], pin, &list); 572 572 else 573 - imx_pinctrl_parse_pin_mmio(ipctl, &grp->pins[i], 574 - pin, &list, np); 573 + imx_pinctrl_parse_pin_mmio(ipctl, &pins[i], pin, &list, np); 575 574 } 576 575 577 576 return 0;