Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753287AbcLHPZe (ORCPT ); Thu, 8 Dec 2016 10:25:34 -0500 Received: from foss.arm.com ([217.140.101.70]:35090 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752414AbcLHPZc (ORCPT ); Thu, 8 Dec 2016 10:25:32 -0500 Subject: Re: [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions To: Arvind Yadav , daniel@zonque.org, haojian.zhuang@gmail.com, robert.jarzmik@free.fr, linus.walleij@linaro.org References: <1481207730-6332-1-git-send-email-arvind.yadav.cs@gmail.com> <28f80351-a89d-06b4-bd8e-d4a1810ee3c5@arm.com> Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: Robin Murphy Message-ID: Date: Thu, 8 Dec 2016 15:25:20 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <28f80351-a89d-06b4-bd8e-d4a1810ee3c5@arm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1860 Lines: 56 On 08/12/16 15:20, Robin Murphy wrote: > On 08/12/16 14:35, Arvind Yadav wrote: >> In functions pxa2xx_build_functions, the memory allocated for >> 'functions' is live within the function only. After the >> allocation it is immediately freed with devm_kfree. There is >> no need to allocate memory for 'functions' with devm function >> so replace devm_kcalloc with kcalloc and devm_kfree with kfree. >> >> Signed-off-by: Arvind Yadav >> --- >> drivers/pinctrl/pxa/pinctrl-pxa2xx.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c >> index 866aa3c..47b8e3a 100644 >> --- a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c >> +++ b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c >> @@ -277,7 +277,7 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl) >> * alternate function, 6 * npins is an absolute high limit of the number >> * of functions. >> */ >> - functions = devm_kcalloc(pctl->dev, pctl->npins * 6, >> + functions = kcalloc(pctl->npins * 6, >> sizeof(*functions), GFP_KERNEL); > > AFAICS, this is allocating a mere 72 bytes. Why not just declare > > struct pxa_pinctrl_function functions[6] = {0}; > > locally and save *all* the bother? Bah, ignore me, that was an incredible comprehension failure. Sorry for the noise. Robin. >> if (!functions) >> return -ENOMEM; >> @@ -289,10 +289,12 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl) >> pctl->functions = devm_kmemdup(pctl->dev, functions, >> pctl->nfuncs * sizeof(*functions), >> GFP_KERNEL); >> - if (!pctl->functions) >> + if (!pctl->functions) { >> + kfree(functions); >> return -ENOMEM; >> + } >> >> - devm_kfree(pctl->dev, functions); >> + kfree(functions); >> return 0; >> } >> >> >