gpiolib: devprop: Warn if gpio-line-names is too long
authorStephen Boyd <swboyd@chromium.org>
Thu, 23 Apr 2020 20:34:16 +0000 (13:34 -0700)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 24 Apr 2020 07:10:01 +0000 (09:10 +0200)
Some DT authors (including myself) have messed up the length of
gpio-line-names and made it longer than it should be. Add a warning here
so that developers can figure out that they've messed up their DT and
should fix it.

Cc: Alexandru M Stan <amstan@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
drivers/gpio/gpiolib-devprop.c

index 53781b2539867b26fb589d527b9524ad0450e5b4..26741032fa9e329868e35404567fc355c3c190e3 100644 (file)
@@ -37,8 +37,11 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip,
        if (count < 0)
                return;
 
-       if (count > gdev->ngpio)
+       if (count > gdev->ngpio) {
+               dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d",
+                        count, gdev->ngpio);
                count = gdev->ngpio;
+       }
 
        names = kcalloc(count, sizeof(*names), GFP_KERNEL);
        if (!names)