From patchwork Tue Feb 28 04:18:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9594655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2037660453 for ; Tue, 28 Feb 2017 04:30:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A4A528500 for ; Tue, 28 Feb 2017 04:30:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D14F28515; Tue, 28 Feb 2017 04:30:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1A6A28500 for ; Tue, 28 Feb 2017 04:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751344AbdB1EaF (ORCPT ); Mon, 27 Feb 2017 23:30:05 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35422 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751181AbdB1EaE (ORCPT ); Mon, 27 Feb 2017 23:30:04 -0500 Received: by mail-pg0-f67.google.com with SMTP id 1so170219pgz.2 for ; Mon, 27 Feb 2017 20:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LZqrp1DbdbVPckwPnnp07D1/+Sgje913FObznvmtX/4=; b=eNAgD+n4YzxlWYN5+/g+d6iJBA0AfytsIRENlqlvtLV5bByOB22q+rHH5ySMtFVwhz 2YWriyUj3tgZEHl+p1xyjO71UUBrX7RP50V6rNj3ja+Lx6agJKarbf19nSuwRppYpJva 1PIf0DJLHkmyoKqLS6MYBuIXHFH+If1cQJwsHE+C2H7qbkew+ulAllkmnb/lURYT1tmH QGzyhkWy9kOesuZ6zth1jDRZiSlQrUmvrmyVmgEUDThEmJOcy/1dVxWNJBfeM8at/9sN ytGrEduqYFWhrnZa2P3hn7T4xtGVKR59szoJeuFWvTvGADuOfwLKDydcPGmeBI1t1YMf jL2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LZqrp1DbdbVPckwPnnp07D1/+Sgje913FObznvmtX/4=; b=IMEBAe5O46V3VA++GnWxV+6dVSpTj6qkaC6Wu8l36F2yONlGOZv1bkufRV04BuYF6C erLthbZjDAWuPjvRP0TzKwzmVo48QrDp29s8VB4js4n+BZK5jrqWEAOufHEOZUZmnyhM bdIsxeJXBY1vFTpfUB2d4FAEOQuOzQVYGnoTzVEUsBAeg61QjiIZwhS0X1DPA6J6NU+l E5BLfIR1jfzgKz0B1C9AUPT9OWc/MVIvOY0/JWSXrL2Gc7kANGJ2lFe6LWNLzy70MJBZ 88sHzfntSnZ3SsreZOXuEfb4L3bVViFE7DV9gxpPVf4YsitqcPWn172Q6qifooUnT2qr /clA== X-Gm-Message-State: AMke39mjV3EZqdu0qDwDj6/OAlbZM7Pfzk6iEHqOjvB9JLZo/EZBN+IvusRHbeV5+JCxcg== X-Received: by 10.98.6.133 with SMTP id 127mr356476pfg.110.1488255540798; Mon, 27 Feb 2017 20:19:00 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id t6sm670035pgt.8.2017.02.27.20.19.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Feb 2017 20:19:00 -0800 (PST) From: Dmitry Torokhov To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] spi: allocate spi_board_info entries one by one Date: Mon, 27 Feb 2017 20:18:56 -0800 Message-Id: <20170228041857.13292-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170228041857.13292-1-dmitry.torokhov@gmail.com> References: <20170228041857.13292-1-dmitry.torokhov@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/spi/spi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index b948d8cdbace..1b66e0497327 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -686,14 +686,14 @@ 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 = kmalloc(sizeof(*bi), GFP_KERNEL); + if (!bi) + return -ENOMEM; + + bi->board_info = *info; bi->board_info.properties = property_entries_dup(info->properties); if (IS_ERR(bi->board_info.properties))