Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp290171imm; Tue, 18 Sep 2018 22:02:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZgNrxndbUzLox/KhQyk/Nf5cIE4Qgj1lXiJ1LuhSUu8TYQBPZwfsKmVMFQDBhcRl/8pp4x X-Received: by 2002:a17:902:8e86:: with SMTP id bg6-v6mr32637540plb.108.1537333363702; Tue, 18 Sep 2018 22:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537333363; cv=none; d=google.com; s=arc-20160816; b=Di6PnmE29kJveVL5tszKta0Bzpud6+/KMVHrPsNXknadDSxjiGWNHndrAVpheRBNGz VbNt7ABJCgucRKXDcqF5FgNzY83nZJYeU4DKKw7UC7pR/QA4FgtBu31tmCldyOYImpQ9 R1DqL8xD1Hddfis7us8VcxWuSJkSocbnksCUzXK6eUx7UIJpyIyDq6j0ee/DiDI7F/QS RUhjOlyGGRyJU7PYKItC3l4LOY5+aCoMJXdiqL0ON2H6SHUFNuQQz5VwwqjRWvU39oYT 79uCESnJ2LgabUY9j8fmQkEB4CYIIXfBMCnhnqEoyTeFtRg/s4pSksgTusktI8lt+snT RNCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=IY+dFm13u+lX1MqyKCrBRaqr9DyvUdXifBHArFWIrQE=; b=DVXhfVxSXEboXbi0pIuuUFD8jDlWBMGHCikflr090exlJWPwLA/EgyHLi+QV4R9jBU AfOHk+29cIGz8q4TxMcQvPpTE9wL1Es9Y/zq80SCJLDaeiJ9NFjdABWmsP72afy0lNv4 eM3r0DTnnRJ3xLFPcuK0An+k7GjSVhwvyQN1+mJxLuAe3d0I2ly9l3jJyg94xmfvzEjt tDPNVEQcNetxYz/88gyX7qY0x2hwJyfFcFx3u7sL+gQucyxpINuRP5ZzKT6RT7dAgWbn LtKBUsGOSJeW5CjqAnrLi2BSdbjCO+QWqRWmoEXyX5jlhbsqO3R796I0lFYKpfkavxER SBcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Pl54qqcl; 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 m24-v6si22199327pfk.56.2018.09.18.22.02.25; Tue, 18 Sep 2018 22:02:43 -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=Pl54qqcl; 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 S1730756AbeISKi3 (ORCPT + 99 others); Wed, 19 Sep 2018 06:38:29 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:58432 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbeISKi2 (ORCPT ); Wed, 19 Sep 2018 06:38:28 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8J52Jbr050684; Wed, 19 Sep 2018 00:02:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1537333339; bh=IY+dFm13u+lX1MqyKCrBRaqr9DyvUdXifBHArFWIrQE=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=Pl54qqcleZz07Fm7DtN/6pVduHpksoNjUjD8uDYPyc9ZEaG0JHedo4NrxATe16z1n vxLo/ACUfeCIynd7mWiFbqDolE2WaD9o+BvsmgZmJW74/m4g7e3EEb3UI1CdkxDLyk UOW6TFStb74qdg5FcdCeb6Pl4QbAqpv9CfKtbMbQ= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8J52JtZ025140; Wed, 19 Sep 2018 00:02:19 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 19 Sep 2018 00:02:19 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 19 Sep 2018 00:02:19 -0500 Received: from [172.24.191.45] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8J52GHY022929; Wed, 19 Sep 2018 00:02:17 -0500 Subject: Re: [PATCH 3/5] gpio: davinci: Allocate the correct amount of memory for controller To: "Andrew F. Davis" , Sekhar Nori , Kevin Hilman , Linus Walleij CC: , References: <20180831191326.25106-1-afd@ti.com> <20180831191326.25106-3-afd@ti.com> From: Keerthy Message-ID: <1cc3aa9b-a736-ee14-d414-8a2b1c4ea659@ti.com> Date: Wed, 19 Sep 2018 10:32:16 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180831191326.25106-3-afd@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit 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 On Saturday 01 September 2018 12:43 AM, Andrew F. Davis wrote: > 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. > Tested for gpio interrupts on k2g and da850-lcdk Tested-by: Keerthy Acked-by: Keerthy > 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); >