Skip to content

Commit 043c8a7

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: n_tty: use do-while in n_tty_check_{,un}throttle()
This change gets rid of the complicated exit from the loops. It can be done much easier using do-while loops. 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 c2b0fb9 commit 043c8a7

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

drivers/tty/n_tty.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,12 @@ static void n_tty_check_throttle(struct tty_struct *tty)
249249
if (ldata->icanon && ldata->canon_head == ldata->read_tail)
250250
return;
251251

252-
while (1) {
253-
int throttled;
252+
do {
254253
tty_set_flow_change(tty, TTY_THROTTLE_SAFE);
255254
if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE)
256255
break;
257-
throttled = tty_throttle_safe(tty);
258-
if (!throttled)
259-
break;
260-
}
256+
} while (tty_throttle_safe(tty));
257+
261258
__tty_set_flow_change(tty, 0);
262259
}
263260

@@ -279,16 +276,14 @@ static void n_tty_check_unthrottle(struct tty_struct *tty)
279276
* we won't get any more characters.
280277
*/
281278

282-
while (1) {
283-
int unthrottled;
279+
do {
284280
tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE);
285281
if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
286282
break;
283+
287284
n_tty_kick_worker(tty);
288-
unthrottled = tty_unthrottle_safe(tty);
289-
if (!unthrottled)
290-
break;
291-
}
285+
} while (tty_unthrottle_safe(tty));
286+
292287
__tty_set_flow_change(tty, 0);
293288
}
294289

0 commit comments

Comments
 (0)