gpio: sysfs: demote warning messages on invalid user input to debug
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 21 Oct 2024 18:57:17 +0000 (20:57 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thu, 31 Oct 2024 12:34:13 +0000 (13:34 +0100)
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().

Link: https://lore.kernel.org/r/20241021185717.96449-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib-sysfs.c

index 0c713baa77840310d2506dfc1e28a95fee1aaf4c..203fc3394afefcf71e399bcfa667c87674e717b9 100644 (file)
@@ -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;
        }