| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
|---|
| 2 | | - * |
|---|
| 3 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 4 | | - * it under the terms of the GNU General Public License version 2 and |
|---|
| 5 | | - * only version 2 as published by the Free Software Foundation. |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 8 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 9 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 10 | | - * GNU General Public License for more details. |
|---|
| 11 | 3 | */ |
|---|
| 12 | 4 | |
|---|
| 13 | 5 | /* |
|---|
| .. | .. |
|---|
| 41 | 33 | int parent_irq; |
|---|
| 42 | 34 | u32 nirqs; |
|---|
| 43 | 35 | u32 nregs; |
|---|
| 44 | | - struct combiner_reg regs[0]; |
|---|
| 36 | + struct combiner_reg regs[]; |
|---|
| 45 | 37 | }; |
|---|
| 46 | 38 | |
|---|
| 47 | 39 | static inline int irq_nr(u32 reg, u32 bit) |
|---|
| .. | .. |
|---|
| 237 | 229 | static int __init combiner_probe(struct platform_device *pdev) |
|---|
| 238 | 230 | { |
|---|
| 239 | 231 | struct combiner *combiner; |
|---|
| 240 | | - size_t alloc_sz; |
|---|
| 241 | 232 | int nregs; |
|---|
| 242 | 233 | int err; |
|---|
| 243 | 234 | |
|---|
| .. | .. |
|---|
| 247 | 238 | return -EINVAL; |
|---|
| 248 | 239 | } |
|---|
| 249 | 240 | |
|---|
| 250 | | - alloc_sz = sizeof(*combiner) + sizeof(struct combiner_reg) * nregs; |
|---|
| 251 | | - combiner = devm_kzalloc(&pdev->dev, alloc_sz, GFP_KERNEL); |
|---|
| 241 | + combiner = devm_kzalloc(&pdev->dev, struct_size(combiner, regs, nregs), |
|---|
| 242 | + GFP_KERNEL); |
|---|
| 252 | 243 | if (!combiner) |
|---|
| 253 | 244 | return -ENOMEM; |
|---|
| 254 | 245 | |
|---|
| .. | .. |
|---|
| 257 | 248 | return err; |
|---|
| 258 | 249 | |
|---|
| 259 | 250 | combiner->parent_irq = platform_get_irq(pdev, 0); |
|---|
| 260 | | - if (combiner->parent_irq <= 0) { |
|---|
| 261 | | - dev_err(&pdev->dev, "Error getting IRQ resource\n"); |
|---|
| 251 | + if (combiner->parent_irq <= 0) |
|---|
| 262 | 252 | return -EPROBE_DEFER; |
|---|
| 263 | | - } |
|---|
| 264 | 253 | |
|---|
| 265 | 254 | combiner->domain = irq_domain_create_linear(pdev->dev.fwnode, combiner->nirqs, |
|---|
| 266 | 255 | &domain_ops, combiner); |
|---|