Skip to content

Commit 5b4f9cf

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
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)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c2a3660 commit 5b4f9cf

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/tty/n_tty.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static void n_tty_check_throttle(struct tty_struct *tty)
253253
tty_set_flow_change(tty, TTY_THROTTLE_SAFE);
254254
if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE)
255255
break;
256-
} while (tty_throttle_safe(tty));
256+
} while (!tty_throttle_safe(tty));
257257

258258
__tty_set_flow_change(tty, 0);
259259
}
@@ -282,7 +282,7 @@ static void n_tty_check_unthrottle(struct tty_struct *tty)
282282
break;
283283

284284
n_tty_kick_worker(tty);
285-
} while (tty_unthrottle_safe(tty));
285+
} while (!tty_unthrottle_safe(tty));
286286

287287
__tty_set_flow_change(tty, 0);
288288
}

drivers/tty/tty_ioctl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,16 @@ EXPORT_SYMBOL(tty_unthrottle);
124124
* conditions when throttling is conditional on factors evaluated prior to
125125
* throttling.
126126
*
127-
* Returns false if tty is throttled (or was already throttled)
127+
* Returns true if tty is throttled (or was already throttled)
128128
*/
129129
bool tty_throttle_safe(struct tty_struct *tty)
130130
{
131-
bool ret = false;
131+
bool ret = true;
132132

133133
mutex_lock(&tty->throttle_mutex);
134134
if (!tty_throttled(tty)) {
135135
if (tty->flow_change != TTY_THROTTLE_SAFE)
136-
ret = true;
136+
ret = false;
137137
else {
138138
set_bit(TTY_THROTTLED, &tty->flags);
139139
if (tty->ops->throttle)
@@ -154,16 +154,16 @@ bool tty_throttle_safe(struct tty_struct *tty)
154154
* unthrottle due to race conditions when unthrottling is conditional
155155
* on factors evaluated prior to unthrottling.
156156
*
157-
* Returns false if tty is unthrottled (or was already unthrottled)
157+
* Returns true if tty is unthrottled (or was already unthrottled)
158158
*/
159159
bool tty_unthrottle_safe(struct tty_struct *tty)
160160
{
161-
bool ret = false;
161+
bool ret = true;
162162

163163
mutex_lock(&tty->throttle_mutex);
164164
if (tty_throttled(tty)) {
165165
if (tty->flow_change != TTY_UNTHROTTLE_SAFE)
166-
ret = true;
166+
ret = false;
167167
else {
168168
clear_bit(TTY_THROTTLED, &tty->flags);
169169
if (tty->ops->unthrottle)

0 commit comments

Comments
 (0)