Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp761564rwb; Mon, 26 Sep 2022 05:38:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5bWpqkhgcy5fuk+C/HYlbxtlUPjBUMhno3fJnsfqA+/Xn+Ry23AOwFqAqPV3qeiPVzb7Th X-Received: by 2002:a17:903:2309:b0:176:be6c:d4df with SMTP id d9-20020a170903230900b00176be6cd4dfmr21498089plh.4.1664195930531; Mon, 26 Sep 2022 05:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664195930; cv=none; d=google.com; s=arc-20160816; b=tzTPe/QTWedqD9XGX5QzJxE+0Wgq4rvpBlkVd1LWUVygt4qgrjii1c2X+gDi1Pu5C2 UGR8r0kN63znC3z0FkTPU3fQQofJ789jfNUStU+ggDsalsO8JI4djHY3ahuN2PNF4LOk /Rp/J/hi/PATd9rytsHkDaNtUPwPHdO+/NOMh3wXi338LnVuHTL710wzQ94wgeqb2p0f hy4ogm4IMidNJ7XCIdFM33hvTEg83o/oWFwF7t5yDzIy7eJQX2s65yI7ZixPuhGbKX6B Rni6XVgCZIbqVfWy/pgKgQjd8Q1Fia5gWK1F2VH5aXymCvwxn6h9WmzW9nSZ0+xmPAyh bmiQ== 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=3ZrHq+zJYZPlKFKQup2zpmcCRmkwJ+XBrGybMxQdmck=; b=n43MfYyHoknkNOWElPe7N7vVnq+rmbuZp9nOwqs5hZTgIZa6w49IT+2d71ToTxXwMg 9LWG4RY7uwv3yE2sSIs9JsuJs8xMnkUh9oCYZzECUjLayjtFJ/kKJOuacxa0JpeMIKdX Gkpmx4hGlovk6QBGyELpu2BtAju5KN9qbKt73CFi6KnUhZDpXCmbS+rUFQMSEPK2qcDw HxlZ9d2j3u1EzPKslXN+wYTJebK6nWaF2jyPQ6Pf+cmB7ml+5sswt+4dCNCcoAFgVD8N v3aFgXDaBFifX+WVDQf3OwiDaAv1NR/h6Q+vQq+M7Uwl36fFDF+GGqLxV6ERF7ECjOgc CIyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=klXYiK3T; 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 e14-20020a63544e000000b0043447486c84si17283289pgm.875.2022.09.26.05.38.39; Mon, 26 Sep 2022 05:38:50 -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=klXYiK3T; 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 S235884AbiIZKdK (ORCPT + 99 others); Mon, 26 Sep 2022 06:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235838AbiIZKcR (ORCPT ); Mon, 26 Sep 2022 06:32:17 -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 1BD2313D58; Mon, 26 Sep 2022 03:20:05 -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 3B4EC60C13; Mon, 26 Sep 2022 10:19:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C199C433B5; Mon, 26 Sep 2022 10:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187596; bh=7HBmAuhPb5o3FENGESmDLJQKWU/eOkJ36nJ8sQoppRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=klXYiK3TlpxPhR0kInrwPoLLnUPfee2vL+frQaBdwMW0Wpr4JinMQrmMU0iABwwma 43WOmchn9o1YATIJdGOY0zHOPBohP+nOufbG1uMHlOMrkbF4yCd8X7jr1/4VY1G2Sj f59Ungh/ALzkXOuZWTCNYf8WHqChcR7DX7UlA+Ag= 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 4.19 50/58] serial: Create uart_xmit_advance() Date: Mon, 26 Sep 2022 12:12:09 +0200 Message-Id: <20220926100743.282052924@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@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 @@ -306,6 +306,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;