diff mbox series

gpio: just plain warning when nonexisting gpio requested

Message ID 1564410993-22101-1-git-send-email-info@metux.net
State New
Headers show
Series gpio: just plain warning when nonexisting gpio requested | expand

Commit Message

Enrico Weigelt, metux IT consult July 29, 2019, 2:36 p.m. UTC
From: Enrico Weigelt <info@metux.net>

When trying to export an nonexisting gpio ID, the kernel prints
outs a big warning w/ stacktrace, sounding like a huge problem.
In fact it's a pretty normal situation, like file or device not
found.

So, just print a more relaxed warning instead.

Signed-off-by: Enrico Weigelt <info@metux.net>
---
 drivers/gpio/gpiolib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Bartosz Golaszewski July 30, 2019, 8:19 a.m. UTC | #1
pon., 29 lip 2019 o 16:41 Enrico Weigelt, metux IT consult
<info@metux.net> napisaƂ(a):
>
> From: Enrico Weigelt <info@metux.net>
>
> When trying to export an nonexisting gpio ID, the kernel prints
> outs a big warning w/ stacktrace, sounding like a huge problem.
> In fact it's a pretty normal situation, like file or device not
> found.
>
> So, just print a more relaxed warning instead.
>
> Signed-off-by: Enrico Weigelt <info@metux.net>
> ---
>  drivers/gpio/gpiolib.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 3ee99d0..06eeedd 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1,4 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +

While adding pr_fmt would make sense for gpiolib in general, it
changes all the already existing pr_* log messages in gpiolib.c. This
has nothing to do with this patch. Please use a regular pr_warn() and
then we can think about simplifying the messages in general.

Bart

>  #include <linux/bitmap.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> @@ -121,7 +124,7 @@ struct gpio_desc *gpio_to_desc(unsigned gpio)
>         spin_unlock_irqrestore(&gpio_lock, flags);
>
>         if (!gpio_is_valid(gpio))
> -               WARN(1, "invalid GPIO %d\n", gpio);
> +               pr_warn("invalid GPIO %d\n", gpio);
>
>         return NULL;
>  }
> --
> 1.9.1
>
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 3ee99d0..06eeedd 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1,4 +1,7 @@ 
 // SPDX-License-Identifier: GPL-2.0
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/bitmap.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -121,7 +124,7 @@  struct gpio_desc *gpio_to_desc(unsigned gpio)
 	spin_unlock_irqrestore(&gpio_lock, flags);
 
 	if (!gpio_is_valid(gpio))
-		WARN(1, "invalid GPIO %d\n", gpio);
+		pr_warn("invalid GPIO %d\n", gpio);
 
 	return NULL;
 }