* [PATCH 1/2] pinctrl: mediatek: mtk-common: Remove kfree for memory allocated by devm_kzalloc @ 2015-03-12 13:52 Axel Lin 2015-03-12 13:53 ` [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places Axel Lin ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Axel Lin @ 2015-03-12 13:52 UTC (permalink / raw) To: Linus Walleij Cc: Matthias Brugger, Hongzhou Yang, Chaotian Jing, Yingjoe Chen, Maoguang Meng, linux-gpio@vger.kernel.org Signed-off-by: Axel Lin <axel.lin@ingics.com> --- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index b8f8bef..f82f57a 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -1222,7 +1222,7 @@ int mtk_pctrl_init(struct platform_device *pdev, if (!irq) { dev_err(&pdev->dev, "couldn't parse and map irq\n"); ret = -EINVAL; - goto free_edges; + goto chip_error; } pctl->domain = irq_domain_add_linear(np, @@ -1230,7 +1230,7 @@ int mtk_pctrl_init(struct platform_device *pdev, if (!pctl->domain) { dev_err(&pdev->dev, "Couldn't register IRQ domain\n"); ret = -ENOMEM; - goto free_edges; + goto chip_error; } mtk_eint_init(pctl); @@ -1248,8 +1248,6 @@ int mtk_pctrl_init(struct platform_device *pdev, set_irq_flags(irq, IRQF_VALID); return 0; -free_edges: - kfree(pctl->eint_dual_edges); chip_error: gpiochip_remove(pctl->chip); pctrl_error: -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places 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 ` Axel Lin 2015-03-13 19:47 ` Hongzhou Yang 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 2 siblings, 2 replies; 6+ messages in thread From: Axel Lin @ 2015-03-12 13:53 UTC (permalink / raw) To: Linus Walleij Cc: Matthias Brugger, Hongzhou Yang, Chaotian Jing, Yingjoe Chen, Maoguang Meng, linux-gpio@vger.kernel.org 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; -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places 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 2015-03-18 12:08 ` Linus Walleij 1 sibling, 0 replies; 6+ messages in thread From: Hongzhou Yang @ 2015-03-13 19:47 UTC (permalink / raw) To: Axel Lin Cc: Linus Walleij, Matthias Brugger, Chaotian Jing, Yingjoe Chen, Maoguang Meng, linux-gpio@vger.kernel.org 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places 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 @ 2015-03-18 12:08 ` Linus Walleij 1 sibling, 0 replies; 6+ messages in thread From: Linus Walleij @ 2015-03-18 12:08 UTC (permalink / raw) To: Axel Lin Cc: Matthias Brugger, Hongzhou Yang, Chaotian Jing, Yingjoe Chen, Maoguang Meng, linux-gpio@vger.kernel.org On Thu, Mar 12, 2015 at 2:53 PM, Axel Lin <axel.lin@ingics.com> wrote: > Prefer devm_kcalloc over devm_kzalloc with multiply. > > Signed-off-by: Axel Lin <axel.lin@ingics.com> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] pinctrl: mediatek: mtk-common: Remove kfree for memory allocated by devm_kzalloc 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 13:47 ` Yingjoe Chen 2015-03-18 11:58 ` Linus Walleij 2 siblings, 0 replies; 6+ messages in thread From: Yingjoe Chen @ 2015-03-13 13:47 UTC (permalink / raw) To: Axel Lin Cc: Linus Walleij, Matthias Brugger, Hongzhou Yang, Chaotian Jing, Maoguang Meng, linux-gpio@vger.kernel.org On Thu, 2015-03-12 at 21:52 +0800, Axel Lin wrote: > Signed-off-by: Axel Lin <axel.lin@ingics.com> > --- > drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c > index b8f8bef..f82f57a 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c > @@ -1222,7 +1222,7 @@ int mtk_pctrl_init(struct platform_device *pdev, > if (!irq) { > dev_err(&pdev->dev, "couldn't parse and map irq\n"); > ret = -EINVAL; > - goto free_edges; > + goto chip_error; > } > > pctl->domain = irq_domain_add_linear(np, > @@ -1230,7 +1230,7 @@ int mtk_pctrl_init(struct platform_device *pdev, > if (!pctl->domain) { > dev_err(&pdev->dev, "Couldn't register IRQ domain\n"); > ret = -ENOMEM; > - goto free_edges; > + goto chip_error; > } > > mtk_eint_init(pctl); > @@ -1248,8 +1248,6 @@ int mtk_pctrl_init(struct platform_device *pdev, > set_irq_flags(irq, IRQF_VALID); > return 0; > > -free_edges: > - kfree(pctl->eint_dual_edges); > chip_error: > gpiochip_remove(pctl->chip); > pctrl_error: Hi Axel, Thanks for fixing my bugs :) Acked-by: Yingjoe Chen <yingjoe.chen@mediatek.com> Joe.C ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] pinctrl: mediatek: mtk-common: Remove kfree for memory allocated by devm_kzalloc 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 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 2 siblings, 0 replies; 6+ messages in thread From: Linus Walleij @ 2015-03-18 11:58 UTC (permalink / raw) To: Axel Lin Cc: Matthias Brugger, Hongzhou Yang, Chaotian Jing, Yingjoe Chen, Maoguang Meng, linux-gpio@vger.kernel.org On Thu, Mar 12, 2015 at 2:52 PM, Axel Lin <axel.lin@ingics.com> wrote: > Signed-off-by: Axel Lin <axel.lin@ingics.com> Patch applied with Yingjoe's ACK. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-18 12:08 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).