Commit 6ec9249a authored by Lokesh Vutla's avatar Lokesh Vutla Committed by Linus Walleij

gpio: davinci: Fix the number of controllers allocated

Driver only needs to allocate for [ngpio / 32] controllers,
as each controller handles 32 gpios. But the current driver
allocates for ngpio of which the extra allocated are unused.
Fix it be registering only the required number of controllers.
Signed-off-by: default avatarLokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: default avatarKeerthy <j-keerthy@ti.com>
Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 310a7e60
...@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc, ...@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc,
static int davinci_gpio_probe(struct platform_device *pdev) static int davinci_gpio_probe(struct platform_device *pdev)
{ {
int i, base; int i, base;
unsigned ngpio; unsigned ngpio, nbank;
struct davinci_gpio_controller *chips; struct davinci_gpio_controller *chips;
struct davinci_gpio_platform_data *pdata; struct davinci_gpio_platform_data *pdata;
struct davinci_gpio_regs __iomem *regs; struct davinci_gpio_regs __iomem *regs;
...@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev) ...@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
if (WARN_ON(ARCH_NR_GPIOS < ngpio)) if (WARN_ON(ARCH_NR_GPIOS < ngpio))
ngpio = ARCH_NR_GPIOS; ngpio = ARCH_NR_GPIOS;
nbank = DIV_ROUND_UP(ngpio, 32);
chips = devm_kzalloc(dev, chips = devm_kzalloc(dev,
ngpio * sizeof(struct davinci_gpio_controller), nbank * sizeof(struct davinci_gpio_controller),
GFP_KERNEL); GFP_KERNEL);
if (!chips) if (!chips)
return -ENOMEM; return -ENOMEM;
......
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