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: 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)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230919085156.1578-6-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

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

+7 -12
+7 -12
drivers/tty/n_tty.c
··· 249 249 if (ldata->icanon && ldata->canon_head == ldata->read_tail) 250 250 return; 251 251 252 - while (1) { 253 - int throttled; 252 + do { 254 253 tty_set_flow_change(tty, TTY_THROTTLE_SAFE); 255 254 if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE) 256 255 break; 257 - throttled = tty_throttle_safe(tty); 258 - if (!throttled) 259 - break; 260 - } 256 + } while (tty_throttle_safe(tty)); 257 + 261 258 __tty_set_flow_change(tty, 0); 262 259 } 263 260 ··· 276 279 * we won't get any more characters. 277 280 */ 278 281 279 - while (1) { 280 - int unthrottled; 282 + do { 281 283 tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); 282 284 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) 283 285 break; 286 + 284 287 n_tty_kick_worker(tty); 285 - unthrottled = tty_unthrottle_safe(tty); 286 - if (!unthrottled) 287 - break; 288 - } 288 + } while (tty_unthrottle_safe(tty)); 289 + 289 290 __tty_set_flow_change(tty, 0); 290 291 } 291 292