hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/rapidio/rio-scan.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * RapidIO enumeration and discovery support
34 *
....@@ -11,11 +12,6 @@
1112 * Copyright 2009 Sysgo AG
1213 * Thomas Moll <thomas.moll@sysgo.com>
1314 * - Added Input- Output- enable functionality, to allow full communication
14
- *
15
- * This program is free software; you can redistribute it and/or modify it
16
- * under the terms of the GNU General Public License as published by the
17
- * Free Software Foundation; either version 2 of the License, or (at your
18
- * option) any later version.
1915 */
2016
2117 #include <linux/types.h>
....@@ -43,7 +39,7 @@
4339 u16 start; /* logical minimal id */
4440 u32 max; /* max number of IDs in table */
4541 spinlock_t lock;
46
- unsigned long table[0];
42
+ unsigned long table[];
4743 };
4844
4945 static int next_destid = 0;
....@@ -334,7 +330,7 @@
334330 size_t size;
335331 u32 swpinfo = 0;
336332
337
- size = sizeof(struct rio_dev);
333
+ size = sizeof(*rdev);
338334 if (rio_mport_read_config_32(port, destid, hopcount,
339335 RIO_PEF_CAR, &result))
340336 return NULL;
....@@ -342,10 +338,8 @@
342338 if (result & (RIO_PEF_SWITCH | RIO_PEF_MULTIPORT)) {
343339 rio_mport_read_config_32(port, destid, hopcount,
344340 RIO_SWP_INFO_CAR, &swpinfo);
345
- if (result & RIO_PEF_SWITCH) {
346
- size += (RIO_GET_TOTAL_PORTS(swpinfo) *
347
- sizeof(rswitch->nextdev[0])) + sizeof(*rswitch);
348
- }
341
+ if (result & RIO_PEF_SWITCH)
342
+ size += struct_size(rswitch, nextdev, RIO_GET_TOTAL_PORTS(swpinfo));
349343 }
350344
351345 rdev = kzalloc(size, GFP_KERNEL);