From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33F59CD54AC for ; Tue, 19 Sep 2023 08:52:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230502AbjISIw0 (ORCPT ); Tue, 19 Sep 2023 04:52:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbjISIwP (ORCPT ); Tue, 19 Sep 2023 04:52:15 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71300102; Tue, 19 Sep 2023 01:52:07 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F31AC433C7; Tue, 19 Sep 2023 08:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695113527; bh=OjwKIBmFPVUbsZin5q6xLKXnnlWzbN3in7M3kjyOOwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhAfZq9aAM+DqMYLnxK4AQzV0iit37kY24wGkl6tBr386M+RHgG5r7gctFeka/q27 jXIL6cHNzfzhf6yeVKWiW+tUfvn5DiKUSm8rDcWouhipBDn6Qv1N/4ixOh9+fuyEwL 63N7ZrVIkZ0h8PYG8lrMEmE5wkjRCN1qcuwPoEE3nH7uHbaaaUgKT4BnX1CRcP80FC Lo+zi+gXB5J6qbKg9p9KwL4or57Tle7itLfqKmqMxSlYydKWGwgM4YmdGP5jAKxAyu /MpOIOiZ9CL1OxohhWpZiNMgd+W8CoA2ODuyRLraCtEjf1mqCvXa7y3iuG3GSyDD7W zJn5Na/RmvHYg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 05/15] tty: n_tty: use do-while in n_tty_check_{,un}throttle() Date: Tue, 19 Sep 2023 10:51:46 +0200 Message-ID: <20230919085156.1578-6-jirislaby@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230919085156.1578-1-jirislaby@kernel.org> References: <20230919085156.1578-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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) --- drivers/tty/n_tty.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 922fb61b587a..b34e6612aef6 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -249,15 +249,12 @@ static void n_tty_check_throttle(struct tty_struct *tty) if (ldata->icanon && ldata->canon_head == ldata->read_tail) return; - while (1) { - int throttled; + do { tty_set_flow_change(tty, TTY_THROTTLE_SAFE); if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE) break; - throttled = tty_throttle_safe(tty); - if (!throttled) - break; - } + } while (tty_throttle_safe(tty)); + __tty_set_flow_change(tty, 0); } @@ -279,16 +276,14 @@ static void n_tty_check_unthrottle(struct tty_struct *tty) * we won't get any more characters. */ - while (1) { - int unthrottled; + do { tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) break; + n_tty_kick_worker(tty); - unthrottled = tty_unthrottle_safe(tty); - if (!unthrottled) - break; - } + } while (tty_unthrottle_safe(tty)); + __tty_set_flow_change(tty, 0); } -- 2.42.0