@@ -686,14 +686,13 @@ int spi_register_board_info(struct spi_board_info const *info, unsigned n)
if (!n)
return -EINVAL;
- bi = kzalloc(n * sizeof(*bi), GFP_KERNEL);
- if (!bi)
- return -ENOMEM;
-
- for (i = 0; i < n; i++, bi++, info++) {
+ for (i = 0; i < n; i++, info++) {
struct spi_master *master;
- memcpy(&bi->board_info, info, sizeof(*info));
+ bi = kmemdup(info, sizeof(*bi), GFP_KERNEL);
+ if (!bi)
+ return -ENOMEM;
+
bi->board_info.properties =
property_entries_dup(info->properties);
if (IS_ERR(bi->board_info.properties))
Lists of spi_board_info entries registered with spi_register_board_info() can be quite long; instead of forcing memory allocator find contagious chunk of memory, let;s allocate them one-by-one, so they can be packed as needed. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> --- drivers/spi/spi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)