Fail the probe and print a warning if SoC specific drivers have
more GPIOs than there can be accounted for in the static bitmaps.
This should avoid silent corruption/failures in the future.

Cc: Bjorn Andersson <bjorn.anders...@sonymobile.com>
Signed-off-by: Stephen Boyd <sb...@codeaurora.org>
---
 drivers/pinctrl/pinctrl-msm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-msm.c b/drivers/pinctrl/pinctrl-msm.c
index ac7223dab4a3..19b0de89dc07 100644
--- a/drivers/pinctrl/pinctrl-msm.c
+++ b/drivers/pinctrl/pinctrl-msm.c
@@ -882,10 +882,14 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
        int ret;
        int i;
        int r;
+       unsigned ngpio = pctrl->soc->ngpios;
+
+       if (WARN_ON(ngpio > MAX_NR_GPIO))
+               return -EINVAL;
 
        chip = &pctrl->chip;
        chip->base = 0;
-       chip->ngpio = pctrl->soc->ngpios;
+       chip->ngpio = ngpio;
        chip->label = dev_name(pctrl->dev);
        chip->dev = pctrl->dev;
        chip->owner = THIS_MODULE;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to