Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp506197rdb; Tue, 19 Sep 2023 01:54:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWInBTPTHnIH/PnshBfgcqwVKn4y45aV/FFCdWht6X0ItmPfWkl94RqxLBkbQ/o8CtLC9y X-Received: by 2002:a05:6a21:3d82:b0:155:bff3:ea1d with SMTP id bj2-20020a056a213d8200b00155bff3ea1dmr9526613pzc.58.1695113662314; Tue, 19 Sep 2023 01:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695113662; cv=none; d=google.com; s=arc-20160816; b=MkmmyDsGEqBtlRU7lG9E40jNArHeXueYmppwRRVQFVEw2eT36jJjXgEhha+I2/pVYv wskROJl5lGvG3a1a3wLheYQsYY+YFg1obt1/fzT6dXb5vrhsy70DeixBCInp78WF0AG7 mz1WErcmd/xgwkOSiOlKn4D8EiZnP35KNB3YP8JPBD2bsDLZK3ZsaPbp/AaiA6nDSFd/ LnBwJPTGzbFJkJuUTKUmYz6l4xHlcmT1jiyAz2aBtPZ7WK5NASwniNxuKoatecI+cFxS FgtljGL2d+DepyQYHwwdgGM7onAb4grnwmA8Jj5IrixyBtzxuHQpZVXxycjZTlJwfrDG x+5g== 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=9p0wQJr0sITmXGDufzHnUj34Dn8vnViMdRFg9LGK9Dw=; fh=1YNwm5KBWetjB3qGkhgLqh/dZnCTsWuqRk83JW6hjgE=; b=xnKw5kACycVc8Bq0ZoA+D6nhoHl1E1rZQhvP3Q5h9uYFIKInA5KvGAdEwv5lycr08T JpyyoRVvdvgtsg4gcsGNUNRK1EuiWgOTQA2XrBB+B1yK7k7zlo2eTpF61wVP6FzNW7e2 r0W1KyFNGoFv5/ZTRF0KHfbwiQFfwJim4bIBthIERWBRktvHDZQvb0y670EoU2Y8wsUJ 2pHJ+RnpPalDiUiKpJwMI0lCVhdwXVYZtg5tZVKKsikS+Lc6mwP4XJtFFwhF9xzxySvt DmJxm1/6B99PlUmwyhTi8LHfUJOR3vUUULpiobwicOKwOR+X5+eHEU6CAm0wKab0Kh3T lKuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fSkQCk2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b12-20020a170903228c00b001bda18ea0e1si9769602plh.80.2023.09.19.01.54.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 01:54:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fSkQCk2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 95030819BB5B; Tue, 19 Sep 2023 01:53:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231176AbjISIwd (ORCPT + 99 others); Tue, 19 Sep 2023 04:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbjISIwZ (ORCPT ); Tue, 19 Sep 2023 04:52:25 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A8412E; Tue, 19 Sep 2023 01:52:08 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89BC7C433C8; Tue, 19 Sep 2023 08:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695113528; bh=ZSeRU/J9vOcRgycVzT++vhk9dRRkV/hU87U+8mdV2zI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSkQCk2aWWRAJBU7+hY1DaVrqtoJcJgLtaF6RZCMlcLkASGNr8Ta3RC0W1MAXNUe7 fiatGtAZkrVuRGI4DlmejZ2vmQnuwuw46F8uiQEPYclrjiRCJj/vHoOpv3I+xLZsn4 DJgwBtGkmDmEbmP+guVImbr1D4JGBXJZrv3qeAKmt7dAzerI6/780gCme4Q6xgmtJe r0CIDN84H8S4hu0s14XeGPuX9E6ySsOYBtYotXPce21m1rmQQlUCdAQeVjGs3hsEUa IiQhEWUnfEV9r05ygb5EEjA+2IokWFGMmZO5lwt1cGefQ4Q124D15J6upEqVWBuBnX JY8IhF4fLj2gA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 06/15] tty: switch tty_{,un}throttle_safe() to return a bool Date: Tue, 19 Sep 2023 10:51:47 +0200 Message-ID: <20230919085156.1578-7-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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 01:53:30 -0700 (PDT) They return 0 or 1 -- a boolean value, so make it clear than noone should expect negative or other values. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/tty_ioctl.c | 18 ++++++++---------- include/linux/tty.h | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index 7958bf6d27c4..ba60fcf518e0 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -124,17 +124,16 @@ EXPORT_SYMBOL(tty_unthrottle); * conditions when throttling is conditional on factors evaluated prior to * throttling. * - * Returns 0 if tty is throttled (or was already throttled) + * Returns false if tty is throttled (or was already throttled) */ - -int tty_throttle_safe(struct tty_struct *tty) +bool tty_throttle_safe(struct tty_struct *tty) { - int ret = 0; + bool ret = false; mutex_lock(&tty->throttle_mutex); if (!tty_throttled(tty)) { if (tty->flow_change != TTY_THROTTLE_SAFE) - ret = 1; + ret = true; else { set_bit(TTY_THROTTLED, &tty->flags); if (tty->ops->throttle) @@ -155,17 +154,16 @@ int tty_throttle_safe(struct tty_struct *tty) * unthrottle due to race conditions when unthrottling is conditional * on factors evaluated prior to unthrottling. * - * Returns 0 if tty is unthrottled (or was already unthrottled) + * Returns false if tty is unthrottled (or was already unthrottled) */ - -int tty_unthrottle_safe(struct tty_struct *tty) +bool tty_unthrottle_safe(struct tty_struct *tty) { - int ret = 0; + bool ret = false; mutex_lock(&tty->throttle_mutex); if (tty_throttled(tty)) { if (tty->flow_change != TTY_UNTHROTTLE_SAFE) - ret = 1; + ret = true; else { clear_bit(TTY_THROTTLED, &tty->flags); if (tty->ops->unthrottle) diff --git a/include/linux/tty.h b/include/linux/tty.h index f002d0f25db7..59d675f345e9 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -416,8 +416,8 @@ unsigned int tty_chars_in_buffer(struct tty_struct *tty); unsigned int tty_write_room(struct tty_struct *tty); void tty_driver_flush_buffer(struct tty_struct *tty); void tty_unthrottle(struct tty_struct *tty); -int tty_throttle_safe(struct tty_struct *tty); -int tty_unthrottle_safe(struct tty_struct *tty); +bool tty_throttle_safe(struct tty_struct *tty); +bool tty_unthrottle_safe(struct tty_struct *tty); int tty_do_resize(struct tty_struct *tty, struct winsize *ws); int tty_get_icount(struct tty_struct *tty, struct serial_icounter_struct *icount); -- 2.42.0