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: invert return values of tty_{,un}throttle_safe()

If tty_{,un}throttle_safe() returned true on success (similar to
*_trylock()), it would make the conditions in callers more obvious. So
perform the switch to these inverted values (and fix the callers).

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

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
5b4f9cf3 c2a36609

+8 -8
+2 -2
drivers/tty/n_tty.c
··· 253 253 tty_set_flow_change(tty, TTY_THROTTLE_SAFE); 254 254 if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE) 255 255 break; 256 - } while (tty_throttle_safe(tty)); 256 + } while (!tty_throttle_safe(tty)); 257 257 258 258 __tty_set_flow_change(tty, 0); 259 259 } ··· 282 282 break; 283 283 284 284 n_tty_kick_worker(tty); 285 - } while (tty_unthrottle_safe(tty)); 285 + } while (!tty_unthrottle_safe(tty)); 286 286 287 287 __tty_set_flow_change(tty, 0); 288 288 }
+6 -6
drivers/tty/tty_ioctl.c
··· 124 124 * conditions when throttling is conditional on factors evaluated prior to 125 125 * throttling. 126 126 * 127 - * Returns false if tty is throttled (or was already throttled) 127 + * Returns true if tty is throttled (or was already throttled) 128 128 */ 129 129 bool tty_throttle_safe(struct tty_struct *tty) 130 130 { 131 - bool ret = false; 131 + bool ret = true; 132 132 133 133 mutex_lock(&tty->throttle_mutex); 134 134 if (!tty_throttled(tty)) { 135 135 if (tty->flow_change != TTY_THROTTLE_SAFE) 136 - ret = true; 136 + ret = false; 137 137 else { 138 138 set_bit(TTY_THROTTLED, &tty->flags); 139 139 if (tty->ops->throttle) ··· 154 154 * unthrottle due to race conditions when unthrottling is conditional 155 155 * on factors evaluated prior to unthrottling. 156 156 * 157 - * Returns false if tty is unthrottled (or was already unthrottled) 157 + * Returns true if tty is unthrottled (or was already unthrottled) 158 158 */ 159 159 bool tty_unthrottle_safe(struct tty_struct *tty) 160 160 { 161 - bool ret = false; 161 + bool ret = true; 162 162 163 163 mutex_lock(&tty->throttle_mutex); 164 164 if (tty_throttled(tty)) { 165 165 if (tty->flow_change != TTY_UNTHROTTLE_SAFE) 166 - ret = true; 166 + ret = false; 167 167 else { 168 168 clear_bit(TTY_THROTTLED, &tty->flags); 169 169 if (tty->ops->unthrottle)