Skip to content

Commit 6ec9249

Browse files
lokeshvutlalinusw
authored andcommitted
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: Lokesh Vutla <[email protected]> Signed-off-by: Keerthy <[email protected]> Reviewed-by: Grygorii Strashko <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 310a7e6 commit 6ec9249

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpio/gpio-davinci.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc,
195195
static int davinci_gpio_probe(struct platform_device *pdev)
196196
{
197197
int i, base;
198-
unsigned ngpio;
198+
unsigned ngpio, nbank;
199199
struct davinci_gpio_controller *chips;
200200
struct davinci_gpio_platform_data *pdata;
201201
struct davinci_gpio_regs __iomem *regs;
@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
224224
if (WARN_ON(ARCH_NR_GPIOS < ngpio))
225225
ngpio = ARCH_NR_GPIOS;
226226

227+
nbank = DIV_ROUND_UP(ngpio, 32);
227228
chips = devm_kzalloc(dev,
228-
ngpio * sizeof(struct davinci_gpio_controller),
229+
nbank * sizeof(struct davinci_gpio_controller),
229230
GFP_KERNEL);
230231
if (!chips)
231232
return -ENOMEM;

0 commit comments

Comments
 (0)