From: Hongzhou Yang <hongzhou.yang@mediatek.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Chaotian Jing <chaotian.jing@mediatek.com>,
Yingjoe Chen <yingjoe.chen@mediatek.com>,
Maoguang Meng <maoguang.meng@mediatek.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places
Date: Fri, 13 Mar 2015 12:47:55 -0700 [thread overview]
Message-ID: <1426276075.22708.7.camel@mussux00.eus.mediatek.inc> (raw)
In-Reply-To: <1426168412.30920.3.camel@phoenix>
On Thu, 2015-03-12 at 21:53 +0800, Axel Lin wrote:
> Prefer devm_kcalloc over devm_kzalloc with multiply.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 17 +++++++----------
> 1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> index f82f57a..493294c 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> @@ -1076,16 +1076,14 @@ static int mtk_pctrl_build_state(struct platform_device *pdev)
> pctl->ngroups = pctl->devdata->npins;
>
> /* Allocate groups */
> - pctl->groups = devm_kzalloc(&pdev->dev,
> - pctl->ngroups * sizeof(*pctl->groups),
> - GFP_KERNEL);
> + pctl->groups = devm_kcalloc(&pdev->dev, pctl->ngroups,
> + sizeof(*pctl->groups), GFP_KERNEL);
> if (!pctl->groups)
> return -ENOMEM;
>
> /* We assume that one pin is one group, use pin name as group name. */
> - pctl->grp_names = devm_kzalloc(&pdev->dev,
> - pctl->ngroups * sizeof(*pctl->grp_names),
> - GFP_KERNEL);
> + pctl->grp_names = devm_kcalloc(&pdev->dev, pctl->ngroups,
> + sizeof(*pctl->grp_names), GFP_KERNEL);
> if (!pctl->grp_names)
> return -ENOMEM;
>
> @@ -1152,8 +1150,7 @@ int mtk_pctrl_init(struct platform_device *pdev,
> return -EINVAL;
> }
>
> - pins = devm_kzalloc(&pdev->dev,
> - pctl->devdata->npins * sizeof(*pins),
> + pins = devm_kcalloc(&pdev->dev, pctl->devdata->npins, sizeof(*pins),
> GFP_KERNEL);
> if (!pins)
> return -ENOMEM;
> @@ -1211,8 +1208,8 @@ int mtk_pctrl_init(struct platform_device *pdev,
> goto chip_error;
> }
>
> - pctl->eint_dual_edges = devm_kzalloc(&pdev->dev,
> - sizeof(int) * pctl->devdata->ap_num, GFP_KERNEL);
> + pctl->eint_dual_edges = devm_kcalloc(&pdev->dev, pctl->devdata->ap_num,
> + sizeof(int), GFP_KERNEL);
> if (!pctl->eint_dual_edges) {
> ret = -ENOMEM;
> goto chip_error;
Hi Axel,
Thanks a lot.
Acked-by: Hongzhou Yang <hongzhou.yang@mediatek.com>
Hongzhou
next prev parent reply other threads:[~2015-03-13 19:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-12 13:52 [PATCH 1/2] pinctrl: mediatek: mtk-common: Remove kfree for memory allocated by devm_kzalloc Axel Lin
2015-03-12 13:53 ` [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places Axel Lin
2015-03-13 19:47 ` Hongzhou Yang [this message]
2015-03-18 12:08 ` Linus Walleij
2015-03-13 13:47 ` [PATCH 1/2] pinctrl: mediatek: mtk-common: Remove kfree for memory allocated by devm_kzalloc Yingjoe Chen
2015-03-18 11:58 ` 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=1426276075.22708.7.camel@mussux00.eus.mediatek.inc \
--to=hongzhou.yang@mediatek.com \
--cc=axel.lin@ingics.com \
--cc=chaotian.jing@mediatek.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=maoguang.meng@mediatek.com \
--cc=matthias.bgg@gmail.com \
--cc=yingjoe.chen@mediatek.com \
/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;
as well as URLs for NNTP newsgroup(s).