gpio: tegra: Prefer kcalloc() over kzalloc() with multiplies
authorThierry Reding <treding@nvidia.com>
Mon, 24 Jul 2017 14:55:06 +0000 (16:55 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 14 Aug 2017 13:01:13 +0000 (15:01 +0200)
Rather than manually compute the size of an array, pass the number and
element size to kcalloc().

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-tegra.c

index c68455b..17a6641 100644 (file)
@@ -622,10 +622,10 @@ static int tegra_gpio_probe(struct platform_device *pdev)
        if (tgi->soc->debounce_supported)
                tgi->gc.set_config = tegra_gpio_set_config;
 
-       tgi->bank_info = devm_kzalloc(&pdev->dev, tgi->bank_count *
+       tgi->bank_info = devm_kcalloc(&pdev->dev, tgi->bank_count,
                                      sizeof(*tgi->bank_info), GFP_KERNEL);
        if (!tgi->bank_info)
-               return -ENODEV;
+               return -ENOMEM;
 
        tgi->irq_domain = irq_domain_add_linear(pdev->dev.of_node,
                                                tgi->gc.ngpio,