Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1737326rdb; Wed, 16 Aug 2023 23:56:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKNUts9WPRGCgidWhp9+JT8+xX+xv3DGn58BlLKvwkr0o+Z3on5xBOsEn/baJAkXoqSlof X-Received: by 2002:a17:906:8a73:b0:99c:ad52:b06 with SMTP id hy19-20020a1709068a7300b0099cad520b06mr3144441ejc.10.1692255368088; Wed, 16 Aug 2023 23:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692255368; cv=none; d=google.com; s=arc-20160816; b=XPFPlBTtgVu6IAcJXdhnaRlcEKXHv/xhqTlJir/t8+S7mY73tWIXMVEH1R+4mlOy9t GWvPiymWYz0txQ1QqGW53U/TN3HjW7puM5YqCvUEOaRVZuGnAh951c1afheCvBKhxC7A mdluY6qs/vDdCiT/nYcW9HOzE9i6YwlXZtDZ2y1473zd3MViGxS5Ia5KEWVSAS8jIOD3 3rSNTEkhPlQ2q3BwsN1RKwyiQTeP2CKAoX2tmDmpPm661gg1JUOkOlqqFud+R1maPbi/ XbCoznZqv6l4jqtA7B6fy/3Dj4kiXiUTLmiHqV5vEIUoMaShMl2Ef9BYFnvZP1JG9Egw vnPw== 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=aeNiSMfrzOYm4TPfk97kVpfR4MGjlR6IfxntJegt/CE=; fh=k7XzfpyqnKqnwxpqVF0NftrWa2FIpeAcHVbykF5xarA=; b=NTUWOcsLYLLNy6A8xO492W/8iaRVg+n6RARfn9Oi0avMFlQWzuYMNM26Je1VaMLKNx d6ZAyEBxr0kbEyj4zDAL6LM0/nxhMUO/bylYxoYAtNR+e499BO6uiesMMpHe4vfjALDJ xKqkd2pB/QM+ramzNWyqmEDuxa83QEnlgjn3rQ1y/kAWCUBb0w8D5d0jtaE/VptIANs5 UTC7EOMOG36yFC2rRZpvZpwmxsHxTG71MsXppmCMCVvri5yuQXncXvpGRxQG/jPpCBSp 8GSWPzyI73Crwsx7HIYm+Phd6DcSKB3Iue8sKDihCVQYAmOSnvwkrysCqqPnU2mZONy/ x0PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c9J1eLhh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa27-20020a170906edbb00b00993ebae9929si12308865ejb.708.2023.08.16.23.55.41; Wed, 16 Aug 2023 23:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c9J1eLhh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244279AbjHPK4P (ORCPT + 99 others); Wed, 16 Aug 2023 06:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244113AbjHPKzq (ORCPT ); Wed, 16 Aug 2023 06:55:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C23313E; Wed, 16 Aug 2023 03:55:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B1FA864FFF; Wed, 16 Aug 2023 10:55:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10BB9C433CA; Wed, 16 Aug 2023 10:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692183344; bh=BTplnn7EuC4UzkRD7loDFaPokm16ysj8tGKZLoZSkcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9J1eLhh0K2OgPBGL5wyV4iSoeO+gbdgIACG7mORSBB0F22o1mGrxixfvTK6IAeyR I69Q5FEE7+0mT7rO2Dt7NNBTyuz+/YV7MWmILvGUs+udpxQ2trH1t/J6XDFC3NyOx2 Zp2FeKR5epl64hLtMaHRdsZ3OKFDsjY+ASoC5a0TKHvr568gScFTDUfunBHJMYAliR Pv24rECuYbblzKJdin+FYYTxG7/+ud/cZk5URiB1SeSu8ZGR27xTV4lVIInSsZhf4J r2PJAZz+LIT9+rs8BnlDWaJXljdWHbRBGyPbfzfo2ajkSUrrPgxMwP3jhllf5exM9K NrwJvAwb2Q2IA== 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/10] tty: tty_buffer: use __tty_insert_flip_string_flags() in tty_insert_flip_char() Date: Wed, 16 Aug 2023 12:55:27 +0200 Message-ID: <20230816105530.3335-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230816105530.3335-1-jirislaby@kernel.org> References: <20230816105530.3335-1-jirislaby@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use __tty_insert_flip_string_flags() for the slow path of tty_insert_flip_char(). The former is generic enough, so there is no reason to reimplement the injection once again. So now we have a single function stuffing into tty buffers. Signed-off-by: Jiri Slaby (SUSE) --- Documentation/driver-api/tty/tty_buffer.rst | 3 ++- drivers/tty/tty_buffer.c | 26 --------------------- include/linux/tty_flip.h | 12 +++++++--- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/Documentation/driver-api/tty/tty_buffer.rst b/Documentation/driver-api/tty/tty_buffer.rst index 774dc119c312..4b5ca1776d4f 100644 --- a/Documentation/driver-api/tty/tty_buffer.rst +++ b/Documentation/driver-api/tty/tty_buffer.rst @@ -15,11 +15,12 @@ Flip Buffer Management ====================== .. kernel-doc:: drivers/tty/tty_buffer.c - :identifiers: tty_prepare_flip_string __tty_insert_flip_char + :identifiers: tty_prepare_flip_string tty_flip_buffer_push tty_ldisc_receive_buf .. kernel-doc:: include/linux/tty_flip.h :identifiers: tty_insert_flip_string_fixed_flag tty_insert_flip_string_flags + tty_insert_flip_char ---- diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 4f84466498f7..e162318d6c31 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -343,32 +343,6 @@ size_t __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars, } EXPORT_SYMBOL(__tty_insert_flip_string_flags); -/** - * __tty_insert_flip_char - add one character to the tty buffer - * @port: tty port - * @ch: character - * @flag: flag byte - * - * Queue a single byte @ch to the tty buffering, with an optional flag. This is - * the slow path of tty_insert_flip_char(). - */ -int __tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag) -{ - struct tty_buffer *tb; - bool flags = flag != TTY_NORMAL; - - if (!__tty_buffer_request_room(port, 1, flags)) - return 0; - - tb = port->buf.tail; - if (tb->flags) - *flag_buf_ptr(tb, tb->used) = flag; - *char_buf_ptr(tb, tb->used++) = ch; - - return 1; -} -EXPORT_SYMBOL(__tty_insert_flip_char); - /** * tty_prepare_flip_string - make room for characters * @port: tty port diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index efd03d9c11f8..af4fce98f64e 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h @@ -15,7 +15,6 @@ size_t __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars, size_t size); size_t tty_prepare_flip_string(struct tty_port *port, u8 **chars, size_t size); void tty_flip_buffer_push(struct tty_port *port); -int __tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag); /** * tty_insert_flip_string_fixed_flag - add characters to the tty buffer @@ -55,7 +54,14 @@ static inline size_t tty_insert_flip_string_flags(struct tty_port *port, return __tty_insert_flip_string_flags(port, chars, flags, true, size); } - +/** + * tty_insert_flip_char - add one character to the tty buffer + * @port: tty port + * @ch: character + * @flag: flag byte + * + * Queue a single byte @ch to the tty buffering, with an optional flag. + */ static inline size_t tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag) { struct tty_buffer *tb = port->buf.tail; @@ -68,7 +74,7 @@ static inline size_t tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag) *char_buf_ptr(tb, tb->used++) = ch; return 1; } - return __tty_insert_flip_char(port, ch, flag); + return __tty_insert_flip_string_flags(port, &ch, &flag, false, 1); } static inline size_t tty_insert_flip_string(struct tty_port *port, -- 2.41.0