.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Flash memory access on SA11x0 based devices |
---|
3 | 4 | * |
---|
.. | .. |
---|
20 | 21 | #include <linux/mtd/concat.h> |
---|
21 | 22 | |
---|
22 | 23 | #include <mach/hardware.h> |
---|
23 | | -#include <asm/sizes.h> |
---|
| 24 | +#include <linux/sizes.h> |
---|
24 | 25 | #include <asm/mach/flash.h> |
---|
25 | 26 | |
---|
26 | 27 | struct sa_subdev_info { |
---|
.. | .. |
---|
33 | 34 | struct sa_info { |
---|
34 | 35 | struct mtd_info *mtd; |
---|
35 | 36 | int num_subdev; |
---|
36 | | - struct sa_subdev_info subdev[0]; |
---|
| 37 | + struct sa_subdev_info subdev[]; |
---|
37 | 38 | }; |
---|
38 | 39 | |
---|
39 | 40 | static DEFINE_SPINLOCK(sa1100_vpp_lock); |
---|
.. | .. |
---|
80 | 81 | default: |
---|
81 | 82 | printk(KERN_WARNING "SA1100 flash: unknown base address " |
---|
82 | 83 | "0x%08lx, assuming CS0\n", phys); |
---|
83 | | - |
---|
| 84 | + fallthrough; |
---|
84 | 85 | case SA1100_CS0_PHYS: |
---|
85 | 86 | subdev->map.bankwidth = (MSC0 & MSC_RBW) ? 2 : 4; |
---|
86 | 87 | break; |
---|
.. | .. |
---|
221 | 222 | info->mtd = info->subdev[0].mtd; |
---|
222 | 223 | ret = 0; |
---|
223 | 224 | } else if (info->num_subdev > 1) { |
---|
224 | | - struct mtd_info *cdev[nr]; |
---|
| 225 | + struct mtd_info **cdev; |
---|
| 226 | + |
---|
| 227 | + cdev = kmalloc_array(nr, sizeof(*cdev), GFP_KERNEL); |
---|
| 228 | + if (!cdev) { |
---|
| 229 | + ret = -ENOMEM; |
---|
| 230 | + goto err; |
---|
| 231 | + } |
---|
| 232 | + |
---|
225 | 233 | /* |
---|
226 | 234 | * We detected multiple devices. Concatenate them together. |
---|
227 | 235 | */ |
---|
.. | .. |
---|
230 | 238 | |
---|
231 | 239 | info->mtd = mtd_concat_create(cdev, info->num_subdev, |
---|
232 | 240 | plat->name); |
---|
| 241 | + kfree(cdev); |
---|
233 | 242 | if (info->mtd == NULL) { |
---|
234 | 243 | ret = -ENXIO; |
---|
235 | 244 | goto err; |
---|