gpio/aspeed: Fix incorrect number of banks
Subsystems (2)
PATCH v3 2/5 gpio/aspeed: Fix incorrect number of banks
The current calculation for the number of GPIO banks is only correct if the number of GPIOs is a multiple of 32 (if there were 31 GPIOs we would currently say there are 0 banks, which is incorrect).
Fixes 361b79119a4b7 ('gpio: Add Aspeed driver')
Signed-off-by Rashmica Gupta <[email protected]>
Reviewed-by Andrew Jeffery <[email protected]>
--- drivers/gpio/gpio-aspeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-aspeed.c +1 -1
@@ -1165,7 +1165,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) gpio->chip.base =-1 ;/* Allocate a cache of the output registers */ - banks = gpio->config->nr_gpios >>5 ; + banks =DIV_ROUND_UP (gpio->config->nr_gpios,32 ); gpio->dcache =devm_kcalloc (&pdev->dev, banks,sizeof (u32),GFP_KERNEL );if (!gpio->dcache)
Signature · 1 line
2.20.1
Quoted 9 lines · Rashmica Gupta
The current calculation for the number of GPIO banks is only correct if the number of GPIOs is a multiple of 32 (if there were 31 GPIOs we would currently say there are 0 banks, which is incorrect).
Fixes 361b79119a4b7 ('gpio: Add Aspeed driver')Signed-off-by Rashmica Gupta <[email protected]>Reviewed-by Andrew Jeffery <[email protected]>
Reviewed-by Joel Stanley <[email protected]>
Quoted 20 lines
--- drivers/gpio/gpio-aspeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpio/gpio-aspeed.c +1
-2@@ -1165,7 +1165,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) gpio->chip.base =-1 ;/* Allocate a cache of the output registers */ - banks = gpio->config->nr_gpios >>5 ; + banks =DIV_ROUND_UP (gpio->config->nr_gpios,32 ); gpio->dcache =devm_kcalloc (&pdev->dev, banks,sizeof (u32),GFP_KERNEL );if (!gpio->dcache) --2.20.1
Quoted 8 lines · Rashmica Gupta
The current calculation for the number of GPIO banks is only correct if the number of GPIOs is a multiple of 32 (if there were 31 GPIOs we would currently say there are 0 banks, which is incorrect).
Fixes 361b79119a4b7 ('gpio: Add Aspeed driver')Signed-off-by Rashmica Gupta <[email protected]>Reviewed-by Andrew Jeffery <[email protected]>
Patch applied.
Yours,
Linus Walleij