From patchwork Tue Feb 28 04:08:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9594637 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 90329601D7 for ; Tue, 28 Feb 2017 04:19:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8968E28512 for ; Tue, 28 Feb 2017 04:19:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D60A28516; Tue, 28 Feb 2017 04:19:12 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 5999328512 for ; Tue, 28 Feb 2017 04:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751373AbdB1ETK (ORCPT ); Mon, 27 Feb 2017 23:19:10 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36001 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbdB1ETK (ORCPT ); Mon, 27 Feb 2017 23:19:10 -0500 Received: by mail-pf0-f194.google.com with SMTP id j5so108095pfb.3; Mon, 27 Feb 2017 20:16:55 -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=AEP3bgxVXPOvMr7ehc6oEpGXThiJT62MAzhb0sPfF2k=; b=KclZlssTJi3qyuTMEV5j0YpTW1T65FjKWBWw6V91PivpWInVQKYkeLWyFIHXIW6crP FXby3W280uepBM/v9KY5/SAWiCKky4NeYdLA4OCjGFzf4knREe6vNFUzi72LnXa5b3dk vsdvmagC1Aj1eUYL/E+T6iWUBvu94at7dwzgJodrm/aGbC3IySHhlYeRZsELSsXVC3vi TqT/pmnkKvAofooydXMlSdSaRjV4B3fhWUVZS5HnRr8Kb2ewdlMvuC4NK1S/yfwF456H RenEu4j9wAQPAXJqwrFbv352bm1gDrMVdyw6wtGAGdfeYn8GPEubyolZRDf4J8g1OF3B 1Dxw== 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=AEP3bgxVXPOvMr7ehc6oEpGXThiJT62MAzhb0sPfF2k=; b=pm7a1J5yGjN00lW3xIvqh4C77Xcngz2oQuYPIWvUKtkEWOJz1dMIxPwi6wjXSMErU4 G8hypkBGsUW7Kg6gc5kRIRkLSmQx+eE/tGTRDWbgvrVlQxRI7VPslHJQjWYuTjaJ9aDK xjtr7xwI3DDLhYZ1CiilKiVigZ6jtZuYsPDPtEEXVPZLO/nAIxG1s2ApGu1j9kdNGT+o +speEB07BefQpmwqGl7Jr3WjMnQzw5tNLtjkAe0f2drFeyIAsRptf9mx5CdLa/6GQqXu agvuUotxUe+Dtc2TrDoTllVMII9cHYT0ExCQ+2OsuUImatTj2yVunMHDlS6Su1Fm0GSX mtQw== X-Gm-Message-State: AMke39mlBjJ9KoVJgaPweA4XBoHlqxD0+/5OBavBOXc5nXdwX1RFzjVLgUChTnJwI1dDPA== X-Received: by 10.84.173.4 with SMTP id o4mr389359plb.106.1488254931010; Mon, 27 Feb 2017 20:08:51 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id v4sm614333pfb.36.2017.02.27.20.08.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Feb 2017 20:08:50 -0800 (PST) From: Dmitry Torokhov To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] spi: allocate spi_board_info entries one by one Date: Mon, 27 Feb 2017 20:08:47 -0800 Message-Id: <20170228040848.9447-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170228040848.9447-1-dmitry.torokhov@gmail.com> References: <20170228040848.9447-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 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index b948d8cdbace..029864410a5f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -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))