Skip to content

Commit

Permalink
gpiolib: devprop: Warn if gpio-line-names is too long
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Boyd authored and Bartosz Golaszewski committed Apr 24, 2020
1 parent aa58a21 commit 9784c99
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/gpio/gpiolib-devprop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9784c99

Please sign in to comment.