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.

gpio: tegra186: allocate irqs with the main struct

Remove an extra kcalloc call by using a flexible array member.

Add __counted_by for extra runtime analysis.

Assign counting variable immediately after allocation as required by
__counted_by.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260309232804.331882-1-rosenp@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

authored by

Rosen Penev and committed by
Bartosz Golaszewski
b4784adf 223d9a31

+9 -13
+9 -13
drivers/gpio/gpio-tegra186.c
··· 125 125 struct tegra_gpio { 126 126 struct gpio_chip gpio; 127 127 unsigned int num_irq; 128 - unsigned int *irq; 129 128 130 129 const struct tegra_gpio_soc *soc; 131 130 unsigned int num_irqs_per_bank; ··· 132 133 133 134 void __iomem *secure; 134 135 void __iomem *base; 136 + 137 + unsigned int irq[] __counted_by(num_irq); 135 138 }; 136 139 137 140 static const struct tegra_gpio_port * ··· 860 859 char **names; 861 860 int node, err; 862 861 863 - gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 862 + err = platform_irq_count(pdev); 863 + if (err < 0) 864 + return err; 865 + 866 + gpio = devm_kzalloc(&pdev->dev, struct_size(gpio, irq, err), GFP_KERNEL); 864 867 if (!gpio) 865 868 return -ENOMEM; 869 + 870 + gpio->num_irq = err; 866 871 867 872 gpio->soc = device_get_match_data(&pdev->dev); 868 873 gpio->gpio.label = gpio->soc->name; ··· 896 889 if (IS_ERR(gpio->base)) 897 890 return PTR_ERR(gpio->base); 898 891 899 - err = platform_irq_count(pdev); 900 - if (err < 0) 901 - return err; 902 - 903 - gpio->num_irq = err; 904 - 905 892 err = tegra186_gpio_irqs_per_bank(gpio); 906 893 if (err < 0) 907 894 return err; 908 - 909 - gpio->irq = devm_kcalloc(&pdev->dev, gpio->num_irq, sizeof(*gpio->irq), 910 - GFP_KERNEL); 911 - if (!gpio->irq) 912 - return -ENOMEM; 913 895 914 896 for (i = 0; i < gpio->num_irq; i++) { 915 897 err = platform_get_irq(pdev, i);