Skip to contentSkip to conversation

gpio: just plain warning when nonexisting gpio requested

PATCH In review Enrico Weigelt, metux IT consult 2 participants 2 messages Dec 2, 2020 – Dec 5, 2020 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpio: just plain warning when nonexisting gpio requested

From: Enrico Weigelt <[email protected]>

When trying to export an nonexisting gpio ID, the kernel prints out 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.

changes v2: drop defining pr_fmt()

---
 drivers/gpio/gpiolib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib.c +2 -1
index 089ddcaa9bc6..6639e7b77d6c 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+
 #include <linux/bitmap.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -119,7 +120,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;
 }
Signature · 1 line
2.11.0
#1 lore raw
Quoted 11 lines · metux IT consult

From: Enrico Weigelt <[email protected]>

When trying to export an nonexisting gpio ID, the kernel prints out 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.

changes v2: drop defining pr_fmt()

Hm hm. It would mainly happen if someone was using the sysfs ABI right? I don't mind if sysfs feels scary to use.

But I see it can happen for other code using the old GPIO symbols so OK I applied it.

Yours,
Linus Walleij