From nobody Fri Dec 19 20:42:08 2025 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 81727C32771 for ; Mon, 26 Sep 2022 11:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237861AbiIZL1X (ORCPT ); Mon, 26 Sep 2022 07:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237675AbiIZL0b (ORCPT ); Mon, 26 Sep 2022 07:26:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5B8069F6F; Mon, 26 Sep 2022 03:40:53 -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 ams.source.kernel.org (Postfix) with ESMTPS id 20FD1B8068A; Mon, 26 Sep 2022 10:40:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64F59C433D6; Mon, 26 Sep 2022 10:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188834; bh=yPR+aSuoNrFsZhZZCkn3ZC1acLKJnWnud/6ONVX08PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=llnUN3/2R4m5q5ff/AGPCm14Yk0JxvuRSX6CWv7ZvVfOMzwjgGDw7xUK+StSTWpIF ZPiPlPR6ZYAixu5GfwBg0xuGAhpjw8ER+SP6FQVmRJOtuAAtVneN1B5np/KORzLEiU 5brxEaw/DkhzUY/0pg+sWHsUfezmJgGPWgtr7N2o= 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.15 119/148] serial: Create uart_xmit_advance() Date: Mon, 26 Sep 2022 12:12:33 +0200 Message-Id: <20220926100800.598374044@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100756.074519146@linuxfoundation.org> References: <20220926100756.074519146@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilpo J=C3=A4rvinen 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=C3=A4rvinen Link: https://lore.kernel.org/r/20220901143934.8850-2-ilpo.jarvinen@linux.i= ntel.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 @@ -300,6 +300,23 @@ struct uart_state { /* number of characters left in xmit buffer before we ask for more */ #define WAKEUP_CHARS 256 =20 +/** + * 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 ch= ars) +{ + struct circ_buf *xmit =3D &up->state->xmit; + + xmit->tail =3D (xmit->tail + chars) & (UART_XMIT_SIZE - 1); + up->icount.tx +=3D chars; +} + struct module; struct tty_driver; =20