mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
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>
This commit is contained in:
parent
0258fe8721
commit
223d9a310c
|
|
@ -46,8 +46,8 @@ struct egpio_info {
|
|||
uint chained_irq;
|
||||
|
||||
/* egpio info */
|
||||
struct egpio_chip *chip;
|
||||
int nchips;
|
||||
struct egpio_chip chip[] __counted_by(nchips);
|
||||
};
|
||||
|
||||
static inline void egpio_writew(u16 value, struct egpio_info *ei, int reg)
|
||||
|
|
@ -270,10 +270,12 @@ static int __init egpio_probe(struct platform_device *pdev)
|
|||
int i;
|
||||
|
||||
/* Initialize ei data structure. */
|
||||
ei = devm_kzalloc(&pdev->dev, sizeof(*ei), GFP_KERNEL);
|
||||
ei = devm_kzalloc(&pdev->dev, struct_size(ei, chip, pdata->num_chips), GFP_KERNEL);
|
||||
if (!ei)
|
||||
return -ENOMEM;
|
||||
|
||||
ei->nchips = pdata->num_chips;
|
||||
|
||||
spin_lock_init(&ei->lock);
|
||||
|
||||
/* Find chained irq */
|
||||
|
|
@ -302,13 +304,6 @@ static int __init egpio_probe(struct platform_device *pdev)
|
|||
|
||||
platform_set_drvdata(pdev, ei);
|
||||
|
||||
ei->nchips = pdata->num_chips;
|
||||
ei->chip = devm_kcalloc(&pdev->dev,
|
||||
ei->nchips, sizeof(struct egpio_chip),
|
||||
GFP_KERNEL);
|
||||
if (!ei->chip)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < ei->nchips; i++) {
|
||||
ei->chip[i].reg_start = pdata->chip[i].reg_start;
|
||||
ei->chip[i].cached_values = pdata->chip[i].initial_values;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user