Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp507934rdb; Tue, 19 Sep 2023 01:59:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn53n0uOzmQI3XPev+VO+a2B9LG3MBbggs0LaFMnQPqXbvHsatDXSs3RTtL6oIuqd4htl4 X-Received: by 2002:a05:6870:f59e:b0:1c8:bf19:e1df with SMTP id eh30-20020a056870f59e00b001c8bf19e1dfmr12624032oab.13.1695113958152; Tue, 19 Sep 2023 01:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695113958; cv=none; d=google.com; s=arc-20160816; b=UFcGby1/5bbUh3m2LoCewPascM+DOrR+yrVh5crhdseHBA94nkFAVjBM9FDjOxWys2 +c9m1c7CRh1ELWYem4cbFL7RvvJxdYb06ygfIp9EPBm4NgToeikAoZA/YRluawCIs2sR KCfUbh/4Hp7jUDEwZqJtPpUZ6mwGaWjcVACpixhIHjnLHWFJJGSfoWTY4BilSyI7mbOH SMIDIeNj4oS+23aPDf8Ysa2E6jM4Y8qDRxWSPIhdESwwfdvLGXlgIqM3N8q35itSWvju UTss3RZKNyYNR+aWokJaQEozDvoIUrPd1MqIG28uep5tBBkv35iS/P679NEldq/TMMqM CO9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XLkCRnvEwhFQL7oqfqurA17DWllIZboOViAMZZcL8GU=; fh=1YNwm5KBWetjB3qGkhgLqh/dZnCTsWuqRk83JW6hjgE=; b=aoSjUd/AaNgs7bAcmMXEf3u2a82bD8F9ifCBS5/Zb6cKECAReRucaC8gNJOx7w7Clh rkyogwL4JXWiaIgHAIN5QEO1/WE+1kH0J58wyqnCfY301B5ABNRnw1Wv5tjIHB/8GGJh 8undQXAhlgmTyF8wtaeeL8Wp+i0gRF28x+F66QhSkLSxv3J7LV60D/GsSBgwOiBdc1VG LQtStTQOMohZuO3W58iy/gwD42Cj0CYOV+S2ferGdIRUrV5Liji+lptbUaeGnxxJ6Adk u6y3bR2wKBL/QD14PiCcmVbQI/Ii13EWP0u00x0Vkky+o5Ny3OFIfwioKkJS+B4pN34B H+7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PE6RZu4E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0057017abe776si9649939pgu.677.2023.09.19.01.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 01:59:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PE6RZu4E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 369F780330F8; Tue, 19 Sep 2023 01:52:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbjISIwf (ORCPT + 99 others); Tue, 19 Sep 2023 04:52:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231163AbjISIw0 (ORCPT ); Tue, 19 Sep 2023 04:52:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FB9C13E; Tue, 19 Sep 2023 01:52:10 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FD4AC433CB; Tue, 19 Sep 2023 08:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695113530; bh=T0UlL4dJ7nKnPYDQUpzwfarotHSS6h+uw/UVfPjepWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PE6RZu4E2pHbBCyV6pom97I/g08Z5+9CF0+PhG4Sd9PnLRqDq8H8zZ3/UvP5E2yms PZGunZIKGSXoHRbR74wzns9/QL+snkgYWuTzdMfp30wIgtPoMsklFb/pBdA1sBXq3p UrKIbIpcyUxyQce0X2qfi5LLzl1+3GteLzz9pEoZX0i0/0vNVI1R4SS11tfBmF11gd aV4gjNsg8F0sSU8DSvaeIjuPBr6aziz0tGieVfhrwd6ubAiNGKFRUXvineKNRl843m FozkykZ+Tlw7cO76HFdzg8uS6J9Jh2ckIIrIxi+RnLpNkulXq503LbnZsu6xgRR/m7 wCldGiQyJo2Nw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 07/15] tty: invert return values of tty_{,un}throttle_safe() Date: Tue, 19 Sep 2023 10:51:48 +0200 Message-ID: <20230919085156.1578-8-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 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 19 Sep 2023 01:52:49 -0700 (PDT) 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) --- drivers/tty/n_tty.c | 4 ++-- drivers/tty/tty_ioctl.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index b34e6612aef6..f252d0b5a434 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -253,7 +253,7 @@ static void n_tty_check_throttle(struct tty_struct *tty) tty_set_flow_change(tty, TTY_THROTTLE_SAFE); if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE) break; - } while (tty_throttle_safe(tty)); + } while (!tty_throttle_safe(tty)); __tty_set_flow_change(tty, 0); } @@ -282,7 +282,7 @@ static void n_tty_check_unthrottle(struct tty_struct *tty) break; n_tty_kick_worker(tty); - } while (tty_unthrottle_safe(tty)); + } while (!tty_unthrottle_safe(tty)); __tty_set_flow_change(tty, 0); } diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index ba60fcf518e0..fb2f1ac5172f 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -124,16 +124,16 @@ EXPORT_SYMBOL(tty_unthrottle); * conditions when throttling is conditional on factors evaluated prior to * throttling. * - * Returns false if tty is throttled (or was already throttled) + * Returns true if tty is throttled (or was already throttled) */ bool tty_throttle_safe(struct tty_struct *tty) { - bool ret = false; + bool ret = true; mutex_lock(&tty->throttle_mutex); if (!tty_throttled(tty)) { if (tty->flow_change != TTY_THROTTLE_SAFE) - ret = true; + ret = false; else { set_bit(TTY_THROTTLED, &tty->flags); if (tty->ops->throttle) @@ -154,16 +154,16 @@ bool tty_throttle_safe(struct tty_struct *tty) * unthrottle due to race conditions when unthrottling is conditional * on factors evaluated prior to unthrottling. * - * Returns false if tty is unthrottled (or was already unthrottled) + * Returns true if tty is unthrottled (or was already unthrottled) */ bool tty_unthrottle_safe(struct tty_struct *tty) { - bool ret = false; + bool ret = true; mutex_lock(&tty->throttle_mutex); if (tty_throttled(tty)) { if (tty->flow_change != TTY_UNTHROTTLE_SAFE) - ret = true; + ret = false; else { clear_bit(TTY_THROTTLED, &tty->flags); if (tty->ops->unthrottle) -- 2.42.0