[2/2] pinctrl: mediatek: mtk-common: Use devm_kcalloc at appropriate places
diff mbox

Message ID 1426168412.30920.3.camel@phoenix
State New
Headers show

Commit Message

Axel Lin March 12, 2015, 1:53 p.m. UTC
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(-)

Comments

Hongzhou Yang March 13, 2015, 7:47 p.m. UTC | #1
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

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij March 18, 2015, 12:08 p.m. UTC | #2
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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

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;