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

Configure Feed

Select the types of activity you want to include in your feed.

pinctrl: tegra: use flexible array member for array

Simplifies allocation slightly by removing a kcalloc call and using
struct_size.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
[linusw@kernel.org: Add in count variable and use __counted_by()]
Signed-off-by: Linus Walleij <linusw@kernel.org>

authored by

Rosen Penev and committed by
Linus Walleij
d4530869 47a9050e

+5 -9
+3 -7
drivers/pinctrl/tegra/pinctrl-tegra.c
··· 832 832 int fn, gn, gfn; 833 833 unsigned long backup_regs_size = 0; 834 834 835 - pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL); 835 + pmx = devm_kzalloc(&pdev->dev, 836 + struct_size(pmx, pingroup_configs, soc_data->ngroups), GFP_KERNEL); 836 837 if (!pmx) 837 838 return -ENOMEM; 838 839 839 840 pmx->dev = &pdev->dev; 840 841 pmx->soc = soc_data; 841 - 842 - pmx->pingroup_configs = devm_kcalloc(&pdev->dev, 843 - pmx->soc->ngroups, sizeof(*pmx->pingroup_configs), 844 - GFP_KERNEL); 845 - if (!pmx->pingroup_configs) 846 - return -ENOMEM; 842 + pmx->num_pingroup_configs = soc_data->ngroups; 847 843 848 844 /* 849 845 * Each mux group will appear in 4 functions' list of groups.
+2 -2
drivers/pinctrl/tegra/pinctrl-tegra.h
··· 25 25 int nbanks; 26 26 void __iomem **regs; 27 27 u32 *backup_regs; 28 - /* Array of size soc->ngroups */ 29 - struct tegra_pingroup_config *pingroup_configs; 28 + unsigned int num_pingroup_configs; 29 + struct tegra_pingroup_config pingroup_configs[] __counted_by(num_pingroup_configs); 30 30 }; 31 31 32 32 enum tegra_pinconf_param {