Commit 0206caa8 authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places

Prefer devm_kcalloc over devm_kzalloc with multiply.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarHongzhou Yang <hongzhou.yang@mediatek.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 0dae530c
...@@ -1076,16 +1076,14 @@ static int mtk_pctrl_build_state(struct platform_device *pdev) ...@@ -1076,16 +1076,14 @@ static int mtk_pctrl_build_state(struct platform_device *pdev)
pctl->ngroups = pctl->devdata->npins; pctl->ngroups = pctl->devdata->npins;
/* Allocate groups */ /* Allocate groups */
pctl->groups = devm_kzalloc(&pdev->dev, pctl->groups = devm_kcalloc(&pdev->dev, pctl->ngroups,
pctl->ngroups * sizeof(*pctl->groups), sizeof(*pctl->groups), GFP_KERNEL);
GFP_KERNEL);
if (!pctl->groups) if (!pctl->groups)
return -ENOMEM; return -ENOMEM;
/* We assume that one pin is one group, use pin name as group name. */ /* We assume that one pin is one group, use pin name as group name. */
pctl->grp_names = devm_kzalloc(&pdev->dev, pctl->grp_names = devm_kcalloc(&pdev->dev, pctl->ngroups,
pctl->ngroups * sizeof(*pctl->grp_names), sizeof(*pctl->grp_names), GFP_KERNEL);
GFP_KERNEL);
if (!pctl->grp_names) if (!pctl->grp_names)
return -ENOMEM; return -ENOMEM;
...@@ -1152,8 +1150,7 @@ int mtk_pctrl_init(struct platform_device *pdev, ...@@ -1152,8 +1150,7 @@ int mtk_pctrl_init(struct platform_device *pdev,
return -EINVAL; return -EINVAL;
} }
pins = devm_kzalloc(&pdev->dev, pins = devm_kcalloc(&pdev->dev, pctl->devdata->npins, sizeof(*pins),
pctl->devdata->npins * sizeof(*pins),
GFP_KERNEL); GFP_KERNEL);
if (!pins) if (!pins)
return -ENOMEM; return -ENOMEM;
...@@ -1211,8 +1208,8 @@ int mtk_pctrl_init(struct platform_device *pdev, ...@@ -1211,8 +1208,8 @@ int mtk_pctrl_init(struct platform_device *pdev,
goto chip_error; goto chip_error;
} }
pctl->eint_dual_edges = devm_kzalloc(&pdev->dev, pctl->eint_dual_edges = devm_kcalloc(&pdev->dev, pctl->devdata->ap_num,
sizeof(int) * pctl->devdata->ap_num, GFP_KERNEL); sizeof(int), GFP_KERNEL);
if (!pctl->eint_dual_edges) { if (!pctl->eint_dual_edges) {
ret = -ENOMEM; ret = -ENOMEM;
goto chip_error; goto chip_error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment