Skip to contentSkip to conversation

gpio: sysfs: demote warning messages on invalid user input to debug

PATCH Applied Bartosz Golaszewski 1 participant 2 messages Oct 21, 2024 – Oct 31, 2024 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: sysfs: demote warning messages on invalid user input to debug

From: Bartosz Golaszewski <[email protected]>

We should not emit a non-ratelimited warning everytime a user passes an invalid value to /sys/class/gpio/export as it's an easy way to spam the kernel log. Change the relevant messages to pr_debug_ratelimited().

---
 drivers/gpio/gpiolib-sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib-sysfs.c +3 -3
index 0c713baa7784..203fc3394afe 100644
@@ -463,7 +463,7 @@ static ssize_t export_store(const struct class *class,
 	desc = gpio_to_desc(gpio);
 	/* reject invalid GPIOs */
 	if (!desc) {
-		pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
+		pr_debug_ratelimited("%s: invalid GPIO %ld\n", __func__, gpio);
 		return -EINVAL;
 	}
 
@@ -473,7 +473,7 @@ static ssize_t export_store(const struct class *class,
 
 	offset = gpio_chip_hwgpio(desc);
 	if (!gpiochip_line_is_valid(guard.gc, offset)) {
-		pr_warn("%s: GPIO %ld masked\n", __func__, gpio);
+		pr_debug_ratelimited("%s: GPIO %ld masked\n", __func__, gpio);
 		return -EINVAL;
 	}
 
@@ -520,7 +520,7 @@ static ssize_t unexport_store(const struct class *class,
 	desc = gpio_to_desc(gpio);
 	/* reject bogus commands (gpiod_unexport() ignores them) */
 	if (!desc) {
-		pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
+		pr_debug_ratelimited("%s: invalid GPIO %ld\n", __func__, gpio);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.43.0
author Applied
#1 lore raw

From: Bartosz Golaszewski <[email protected]>

Quoted 5 lines · Bartosz Golaszewski

We should not emit a non-ratelimited warning everytime a user passes an invalid value to /sys/class/gpio/export as it's an easy way to spam the kernel log. Change the relevant messages to pr_debug_ratelimited().

Applied, thanks!

[1/1] gpio: sysfs: demote warning messages on invalid user input to debug

      commit: 37d5a6d6f406322ed0850fc2af1d377aced16340

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>