pinctrl: mediatek: mtk-common: Remove kfree for memory allocated by devm_kzalloc
Subsystems (4)
PATCH 1/2 pinctrl: mediatek: mtk-common: Remove kfree for memory allocated by devm_kzalloc
--- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +2 -4
@@ -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:
Signature · 1 line
1.9.1
PATCH 2/2 pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places
Prefer devm_kcalloc over devm_kzalloc with multiply.
--- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +7 -10
@@ -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;
Signature · 1 line
1.9.1
Re: [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places
Quoted 43 lines · Axel Lin
Prefer
devm_kcallocoverdevm_kzallocwith multiply.Signed-off-by Axel Lin <[email protected]>--- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)drivers/pinctrl/mediatek/pinctrl-mtk-common.c +5
-8@@ -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 ;
drivers/pinctrl/mediatek/pinctrl-mtk-common.c int mtk_pctrl_init(struct platform_device *pdev, · line 1215
Quoted 10 lines
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +2
-2@@ -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.
Hongzhou
Re: [PATCH 2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places
In reply to Axel LinQuoted 3 lines · Axel Lin
Prefer
devm_kcallocoverdevm_kzallocwith multiply.Signed-off-by Axel Lin <[email protected]>
Patch applied.
Yours,
Linus Walleij
Quoted 28 lines · Axel Lin
Signed-off-by Axel Lin <[email protected]>--- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/pinctrl/mediatek/pinctrl-mtk-common.c +2
-2@@ -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);
drivers/pinctrl/mediatek/pinctrl-mtk-common.c int mtk_pctrl_init(struct platform_device *pdev, · line 1253
Quoted 8 lines
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +0
-2@@ -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 :)
Joe.C
Quoted 1 line · Axel Lin
Signed-off-by Axel Lin <[email protected]>
Patch applied with Yingjoe's ACK.
Yours,
Linus Walleij