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: htc-egpio: allocate irq with the main struct

Use a flexible array member to combinwe allocations.

Add __counted_by for extra runtime analysis.

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

authored by

Rosen Penev and committed by
Bartosz Golaszewski
223d9a31 0258fe87

+4 -9
+4 -9
drivers/gpio/gpio-htc-egpio.c
··· 46 46 uint chained_irq; 47 47 48 48 /* egpio info */ 49 - struct egpio_chip *chip; 50 49 int nchips; 50 + struct egpio_chip chip[] __counted_by(nchips); 51 51 }; 52 52 53 53 static inline void egpio_writew(u16 value, struct egpio_info *ei, int reg) ··· 270 270 int i; 271 271 272 272 /* Initialize ei data structure. */ 273 - ei = devm_kzalloc(&pdev->dev, sizeof(*ei), GFP_KERNEL); 273 + ei = devm_kzalloc(&pdev->dev, struct_size(ei, chip, pdata->num_chips), GFP_KERNEL); 274 274 if (!ei) 275 275 return -ENOMEM; 276 + 277 + ei->nchips = pdata->num_chips; 276 278 277 279 spin_lock_init(&ei->lock); 278 280 ··· 303 301 ei->reg_mask = (1 << pdata->reg_width) - 1; 304 302 305 303 platform_set_drvdata(pdev, ei); 306 - 307 - ei->nchips = pdata->num_chips; 308 - ei->chip = devm_kcalloc(&pdev->dev, 309 - ei->nchips, sizeof(struct egpio_chip), 310 - GFP_KERNEL); 311 - if (!ei->chip) 312 - return -ENOMEM; 313 304 314 305 for (i = 0; i < ei->nchips; i++) { 315 306 ei->chip[i].reg_start = pdata->chip[i].reg_start;