Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: switch tty_{,un}throttle_safe() to return a bool

They return 0 or 1 -- a boolean value, so make it clear than noone
should expect negative or other values.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230919085156.1578-7-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
c2a36609 043c8a7c

+10 -12
+8 -10
drivers/tty/tty_ioctl.c
··· 124 124 * conditions when throttling is conditional on factors evaluated prior to 125 125 * throttling. 126 126 * 127 - * Returns 0 if tty is throttled (or was already throttled) 127 + * Returns false if tty is throttled (or was already throttled) 128 128 */ 129 - 130 - int tty_throttle_safe(struct tty_struct *tty) 129 + bool tty_throttle_safe(struct tty_struct *tty) 131 130 { 132 - int ret = 0; 131 + bool ret = false; 133 132 134 133 mutex_lock(&tty->throttle_mutex); 135 134 if (!tty_throttled(tty)) { 136 135 if (tty->flow_change != TTY_THROTTLE_SAFE) 137 - ret = 1; 136 + ret = true; 138 137 else { 139 138 set_bit(TTY_THROTTLED, &tty->flags); 140 139 if (tty->ops->throttle) ··· 154 155 * unthrottle due to race conditions when unthrottling is conditional 155 156 * on factors evaluated prior to unthrottling. 156 157 * 157 - * Returns 0 if tty is unthrottled (or was already unthrottled) 158 + * Returns false if tty is unthrottled (or was already unthrottled) 158 159 */ 159 - 160 - int tty_unthrottle_safe(struct tty_struct *tty) 160 + bool tty_unthrottle_safe(struct tty_struct *tty) 161 161 { 162 - int ret = 0; 162 + bool ret = false; 163 163 164 164 mutex_lock(&tty->throttle_mutex); 165 165 if (tty_throttled(tty)) { 166 166 if (tty->flow_change != TTY_UNTHROTTLE_SAFE) 167 - ret = 1; 167 + ret = true; 168 168 else { 169 169 clear_bit(TTY_THROTTLED, &tty->flags); 170 170 if (tty->ops->unthrottle)
+2 -2
include/linux/tty.h
··· 416 416 unsigned int tty_write_room(struct tty_struct *tty); 417 417 void tty_driver_flush_buffer(struct tty_struct *tty); 418 418 void tty_unthrottle(struct tty_struct *tty); 419 - int tty_throttle_safe(struct tty_struct *tty); 420 - int tty_unthrottle_safe(struct tty_struct *tty); 419 + bool tty_throttle_safe(struct tty_struct *tty); 420 + bool tty_unthrottle_safe(struct tty_struct *tty); 421 421 int tty_do_resize(struct tty_struct *tty, struct winsize *ws); 422 422 int tty_get_icount(struct tty_struct *tty, 423 423 struct serial_icounter_struct *icount);