From: Robin Murphy <robin.murphy@arm.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>,
daniel@zonque.org, haojian.zhuang@gmail.com,
robert.jarzmik@free.fr, linus.walleij@linaro.org
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions
Date: Thu, 8 Dec 2016 15:25:20 +0000 [thread overview]
Message-ID: <ef260e14-c785-cac6-b8c1-d3c5cfeb44fc@arm.com> (raw)
In-Reply-To: <28f80351-a89d-06b4-bd8e-d4a1810ee3c5@arm.com>
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 <arvind.yadav.cs@gmail.com>
>> ---
>> 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;
>> }
>>
>>
>
next prev parent reply other threads:[~2016-12-08 15:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 14:35 [PATCH V1] pinctrl:pxa:pinctrl-pxa2xx:- No need of devm functions Arvind Yadav
2016-12-08 15:20 ` Robin Murphy
2016-12-08 15:25 ` Robin Murphy [this message]
2016-12-10 9:19 ` Robert Jarzmik
2016-12-11 8:04 ` arvind Yadav
2016-12-27 12:49 ` Linus Walleij
2016-12-29 7:20 ` Robert Jarzmik
2016-12-30 13:02 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef260e14-c785-cac6-b8c1-d3c5cfeb44fc@arm.com \
--to=robin.murphy@arm.com \
--cc=arvind.yadav.cs@gmail.com \
--cc=daniel@zonque.org \
--cc=haojian.zhuang@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robert.jarzmik@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox