]> Git Repo - linux.git/commitdiff
tty: use pr_warn_ratelimited() for deprecated serial flags
authorJohan Hovold <[email protected]>
Wed, 7 Apr 2021 09:52:04 +0000 (11:52 +0200)
committerGreg Kroah-Hartman <[email protected]>
Sat, 10 Apr 2021 08:36:34 +0000 (10:36 +0200)
Use pr_warn_ratelimited() when warning about deprecated serial flags
instead of open coding.

Signed-off-by: Johan Hovold <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/tty/tty_io.c

index 7738514a15fe2601075eaa526f5cd2dc5a386a2b..e00efd299abd9e444871dc303fac232a9da5d7a5 100644 (file)
@@ -2626,9 +2626,6 @@ static int tty_tiocgicount(struct tty_struct *tty, void __user *arg)
 
 static int tty_tiocsserial(struct tty_struct *tty, struct serial_struct __user *ss)
 {
-       static DEFINE_RATELIMIT_STATE(depr_flags,
-                       DEFAULT_RATELIMIT_INTERVAL,
-                       DEFAULT_RATELIMIT_BURST);
        char comm[TASK_COMM_LEN];
        struct serial_struct v;
        int flags;
@@ -2638,9 +2635,9 @@ static int tty_tiocsserial(struct tty_struct *tty, struct serial_struct __user *
 
        flags = v.flags & ASYNC_DEPRECATED;
 
-       if (flags && __ratelimit(&depr_flags))
-               pr_warn("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n",
-                       __func__, get_task_comm(comm, current), flags);
+       if (flags)
+               pr_warn_ratelimited("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n",
+                               __func__, get_task_comm(comm, current), flags);
        if (!tty->ops->set_serial)
                return -ENOTTY;
        return tty->ops->set_serial(tty, &v);
@@ -2841,9 +2838,6 @@ struct serial_struct32 {
 static int compat_tty_tiocsserial(struct tty_struct *tty,
                struct serial_struct32 __user *ss)
 {
-       static DEFINE_RATELIMIT_STATE(depr_flags,
-                       DEFAULT_RATELIMIT_INTERVAL,
-                       DEFAULT_RATELIMIT_BURST);
        char comm[TASK_COMM_LEN];
        struct serial_struct32 v32;
        struct serial_struct v;
@@ -2860,9 +2854,9 @@ static int compat_tty_tiocsserial(struct tty_struct *tty,
 
        flags = v.flags & ASYNC_DEPRECATED;
 
-       if (flags && __ratelimit(&depr_flags))
-               pr_warn("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n",
-                       __func__, get_task_comm(comm, current), flags);
+       if (flags)
+               pr_warn_ratelimited("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n",
+                               __func__, get_task_comm(comm, current), flags);
        if (!tty->ops->set_serial)
                return -ENOTTY;
        return tty->ops->set_serial(tty, &v);
This page took 0.052414 seconds and 4 git commands to generate.