Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp824849rwb; Mon, 26 Sep 2022 06:23:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7NCbS0LleXKs71+IQpUb3XqTjb6VBXBh27jkXIR8xqgnhVVt5WWtDdq3GdixT9EkTaR7yx X-Received: by 2002:a17:906:ef8c:b0:77c:8d9a:9aed with SMTP id ze12-20020a170906ef8c00b0077c8d9a9aedmr19110772ejb.704.1664198590546; Mon, 26 Sep 2022 06:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198590; cv=none; d=google.com; s=arc-20160816; b=b0pTI2DCLkWfqBVcN6fkpPemd2Mo0pYlLv3moZhvnFvMiMIRVZ/BDlfJsUj2JuqvVf zAS3lQtBjA+2lJ3FM2rZudX9yPdDDgslL80gkFtgq8TdjQSDE+r9Fz4Fsw43uS2y5co0 ZcC4wrY/mlgzYxtoZ99eQPZ8+6MpEr0dmvSF8sa1TWTvOsazw8z1gnp0kL+H152/fD+s WJhPBgLj99musEpBv7WMjZbMPLfl1Pwl2Va48CCrdHLq2R2nuWjfklvmgGosZxOSO5Kr /UCqgNrq/5bKNA+tQNNNXZ7gD4iUfCPV1X5MXVap69q4xS+bSlb03g03MjuO5pLJoU9s atfw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NpLg9PPOO5L+RyOmPqed6tGC3WnQlEqNiEjhNudffrE=; b=Cqf+vXDbMUN6nS2oMMyJvjyDx6cer51VkVFnmJvTelx68bUkmt9k/LIDK+PvUqD2Oa 5Et/etREzht7qkUSFlNQf7RReb+3jYI7BJVjXoGiJUzA59UdvChLLrvyq1CdUtKplyGV lwNBdSJwEy+Jc17GJM5g5ngmen6O1PPnPwTWHgLZsOXDLnzKjxIqapXOhGs8GxhQARJU xq0iHqnqO1jNHIQXlPJzqCOw5Fstp93Q+8sBY+tBtq8G2H4VV7H62J7kny2AsTxbyxF5 cfRq3NSP2qptTmggPz+chVycMYuFBqC5If6VjNUixuumJIOZpohW6yyGC6FU7oD40DkC KHkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gv0RibuL; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn2-20020a17090794c200b007818378f560si16487982ejc.383.2022.09.26.06.22.43; Mon, 26 Sep 2022 06:23:10 -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=@linuxfoundation.org header.s=korg header.b=gv0RibuL; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236980AbiIZMOL (ORCPT + 99 others); Mon, 26 Sep 2022 08:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239512AbiIZMNf (ORCPT ); Mon, 26 Sep 2022 08:13:35 -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 64F2249B77; Mon, 26 Sep 2022 03:58:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F1BBD60B60; Mon, 26 Sep 2022 10:49:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03C11C433D6; Mon, 26 Sep 2022 10:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189361; bh=xMarRssPDX5kzxQMfKSIOrhgYAogBN3kRzzwyrV9xu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gv0RibuL7E2FlMPxr16C+iLs/UlKBgJ1aO3ncccRQw//ZSHs3huC/ykRmQuws8j/Q Hg5DikwJx+/mMmCT4Gf26f3ynEfLhJcTVB96AoKp++yanW0/Q63W4AtP9EWUKW0PTm x0W9HruUZXI/LGBomc3pZKwK5b8iPj6Wkh8MGUpo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , stable , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 5.19 161/207] serial: Create uart_xmit_advance() Date: Mon, 26 Sep 2022 12:12:30 +0200 Message-Id: <20220926100813.873806970@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Ilpo Järvinen commit e77cab77f2cb3a1ca2ba8df4af45bb35617ac16d upstream. A very common pattern in the drivers is to advance xmit tail index and do bookkeeping of Tx'ed characters. Create uart_xmit_advance() to handle it. Reviewed-by: Andy Shevchenko Cc: stable Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220901143934.8850-2-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- include/linux/serial_core.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -302,6 +302,23 @@ struct uart_state { /* number of characters left in xmit buffer before we ask for more */ #define WAKEUP_CHARS 256 +/** + * uart_xmit_advance - Advance xmit buffer and account Tx'ed chars + * @up: uart_port structure describing the port + * @chars: number of characters sent + * + * This function advances the tail of circular xmit buffer by the number of + * @chars transmitted and handles accounting of transmitted bytes (into + * @up's icount.tx). + */ +static inline void uart_xmit_advance(struct uart_port *up, unsigned int chars) +{ + struct circ_buf *xmit = &up->state->xmit; + + xmit->tail = (xmit->tail + chars) & (UART_XMIT_SIZE - 1); + up->icount.tx += chars; +} + struct module; struct tty_driver;