Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp752195imm; Fri, 31 Aug 2018 12:14:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbA5Qlt/oM8CjZ+Nxn+WvEWLkE4ccLoqln/5FLFYIkpyErRwS6anKZK6GwbApYVlWI8KdQk X-Received: by 2002:a63:6183:: with SMTP id v125-v6mr16003871pgb.242.1535742896984; Fri, 31 Aug 2018 12:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535742896; cv=none; d=google.com; s=arc-20160816; b=rJu0K8x7LXgOpK99gMPzT1oPAc6bDc3V5Cwubo95us0f+3kp+sw7Uksns4C881U2r8 GALRiFK5tdWf0+SyT+4xoYHwBywtDE72qEUG/Aro2CFDVEqfd6MHu6ksZbRP6qFJu1fY r+qdj9sk63N0qHTpiyWhN/gXSnzO0EnelGrVy55Bf/wbdoxYowwoB27rtTIHCDpaIRlN Aaq0GqANP/saz98jMhg9W7gRuy62AiQU1Gclxh9fWJgriwG4mSB3q+jiSqxXjqsmG13m 6xF9xikBJ4HuigDIBHKs3YyRsoDmn1vNXMDQl9SJQZZtKt3jJxmVpQUXjKUcIKtabwEb Bkug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=uUQ2iDEix+p4lGC9u/N1yIBg24pApNYwSziUcOLwIas=; b=CrXjG0zvs+Xn8MUEx+kap9ZWVwiXNuXZd+1f4nJ6xMM8MUjQH/Ad6ribDp7OqBSBcR D+gQ4jB3Kuy+6O2lILCl7CFL97tabh2B3LdFwMZ8mNeoOejoMgK4LMfmLFGhFQOKS6kg kbETyaQB9iYawwJ/9THvWFMIfY+/Hmy3xdFA3wi/E3vO9M2JNy3eWJaG5JCJtJqEkNZB 7xBuHYuT7MCx68g3fgzUK072s9qk+5RW3w/gb0A7ab+M8BLuKPekR4kPmTCpF8bNp1Io e+sDBLfaq4rUoLhYk2mBXzmhfCLNmep26JLpTb6RWS6DLUwJvVvtJVM4YlrlsF4zyH0i d39g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="tN/d3jNx"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si10731190pld.114.2018.08.31.12.14.42; Fri, 31 Aug 2018 12:14:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="tN/d3jNx"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727589AbeHaXWW (ORCPT + 99 others); Fri, 31 Aug 2018 19:22:22 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:35834 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727298AbeHaXWV (ORCPT ); Fri, 31 Aug 2018 19:22:21 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w7VJDTFl107882; Fri, 31 Aug 2018 14:13:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1535742809; bh=uUQ2iDEix+p4lGC9u/N1yIBg24pApNYwSziUcOLwIas=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=tN/d3jNxSbWIN/+jyPJ1C7R6RcL8UaENsuqKosmnpr4JkOUnP+sdxS3DEFOsbwyEu pJp9wQQ5wRY5yDTHSM3xgR9HyXNL7cup9sjpxA2OCfDle+R+YrTyqB8XL4T5TiKbvZ f5c8T69f5N/SVwwVdEK62xye46YomEQFk+GYydEs= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJDTbi014452; Fri, 31 Aug 2018 14:13:29 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 31 Aug 2018 14:13:28 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 31 Aug 2018 14:13:29 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w7VJDTPw004137; Fri, 31 Aug 2018 14:13:29 -0500 Received: from localhost (uda0226330.dhcp.ti.com [172.22.167.21]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w7VJDSx13203; Fri, 31 Aug 2018 14:13:28 -0500 (CDT) From: "Andrew F. Davis" To: Sekhar Nori , Kevin Hilman , Keerthy , Linus Walleij CC: , , "Andrew F . Davis" Subject: [PATCH 3/5] gpio: davinci: Allocate the correct amount of memory for controller Date: Fri, 31 Aug 2018 14:13:24 -0500 Message-ID: <20180831191326.25106-3-afd@ti.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180831191326.25106-1-afd@ti.com> References: <20180831191326.25106-1-afd@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously we created a controller structure per bank of GPIO pins. This has since been changed to one per controller, but the allocation size was not changed. Fix this here. This also leaves the variable 'nbank' unused, instead of removing it, move it down and use it to clean up a loop. For loops with multiple initializers and/or iteration expressions, especially ones that don't use those loop counters are quite hard to follow, fix this. Signed-off-by: Andrew F. Davis --- drivers/gpio/gpio-davinci.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 14d1729927d3..121a7948f785 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -165,7 +165,7 @@ davinci_gpio_get_pdata(struct platform_device *pdev) static int davinci_gpio_probe(struct platform_device *pdev) { - int gpio, bank, i, ret = 0; + int bank, i, ret = 0; unsigned int ngpio, nbank, nirq; struct davinci_gpio_controller *chips; struct davinci_gpio_platform_data *pdata; @@ -204,10 +204,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) else nirq = DIV_ROUND_UP(ngpio, 16); - nbank = DIV_ROUND_UP(ngpio, 32); - chips = devm_kcalloc(dev, - nbank, sizeof(struct davinci_gpio_controller), - GFP_KERNEL); + chips = devm_kzalloc(dev, sizeof(*chips), GFP_KERNEL); if (!chips) return -ENOMEM; @@ -247,7 +244,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) #endif spin_lock_init(&chips->lock); - for (gpio = 0, bank = 0; gpio < ngpio; gpio += 32, bank++) + nbank = DIV_ROUND_UP(ngpio, 32); + for (bank = 0; bank < nbank; bank++) chips->regs[bank] = gpio_base + offset_array[bank]; ret = devm_gpiochip_add_data(dev, &chips->chip, chips); -- 2.18.0