summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Lee <steven_lee@aspeedtech.com>2021-07-12 13:03:16 +0300
committerJae Hyun Yoo <jae.hyun.yoo@linux.intel.com>2021-10-20 01:10:40 +0300
commit5d0476de3fbcc8d01f25c65633af0f16f6d930ec (patch)
treeb4f2004f0f5818e8f0c58b1d6e5a13ebe21d473e
parent20c2d21d82385ae7ea2f832393eeaed607a168dc (diff)
downloadlinux-5d0476de3fbcc8d01f25c65633af0f16f6d930ec.tar.xz
gpio: gpio-aspeed-sgpio: Return error if ngpios is not multiple of 8.
Add an else-if condition in the probe function to check whether ngpios is multiple of 8. Per AST datasheet, numbers of available serial GPIO pins in Serial GPIO Configuration Register must be n bytes. For instance, if n = 1, it means AST SoC supports 8 GPIO pins. Signed-off-by: Steven Lee <steven_lee@aspeedtech.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
-rw-r--r--drivers/gpio/gpio-aspeed-sgpio.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-aspeed-sgpio.c b/drivers/gpio/gpio-aspeed-sgpio.c
index b3d05fc724f0..191b82a2560c 100644
--- a/drivers/gpio/gpio-aspeed-sgpio.c
+++ b/drivers/gpio/gpio-aspeed-sgpio.c
@@ -537,6 +537,10 @@ static int __init aspeed_sgpio_probe(struct platform_device *pdev)
if (rc < 0) {
dev_err(&pdev->dev, "Could not read ngpios property\n");
return -EINVAL;
+ } else if (nr_gpios % 8) {
+ dev_err(&pdev->dev, "Number of GPIOs not multiple of 8: %d\n",
+ nr_gpios);
+ return -EINVAL;
}
rc = device_property_read_u32(&pdev->dev, "bus-frequency", &sgpio_freq);