diff mbox series

gpiolib: devprop: Warn if gpio-line-names is too long

Message ID 20200423203416.133274-1-swboyd@chromium.org
State New
Headers show
Series gpiolib: devprop: Warn if gpio-line-names is too long | expand

Commit Message

Stephen Boyd April 23, 2020, 8:34 p.m. UTC
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>
---
 drivers/gpio/gpiolib-devprop.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Bartosz Golaszewski April 24, 2020, 7:10 a.m. UTC | #1
czw., 23 kwi 2020 o 22:34 Stephen Boyd <swboyd@chromium.org> napisaƂ(a):
>
> 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>
> ---
>  drivers/gpio/gpiolib-devprop.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib-devprop.c b/drivers/gpio/gpiolib-devprop.c
> index 53781b253986..26741032fa9e 100644
> --- a/drivers/gpio/gpiolib-devprop.c
> +++ b/drivers/gpio/gpiolib-devprop.c
> @@ -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)
> --
> Sent by a computer, using git, on the internet
>

Patch applied, thanks!

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-devprop.c b/drivers/gpio/gpiolib-devprop.c
index 53781b253986..26741032fa9e 100644
--- a/drivers/gpio/gpiolib-devprop.c
+++ b/drivers/gpio/gpiolib-devprop.c
@@ -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)