Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp85426rdb; Thu, 1 Feb 2024 02:56:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRWRL3ZyDnFaVMTSnvYbsewmBpb9mlgfgTimclVPHj7eHD+/VxWQIQieZ5VQDwluYqxGaa X-Received: by 2002:a05:620a:3956:b0:783:2a45:8329 with SMTP id qs22-20020a05620a395600b007832a458329mr2725484qkn.76.1706784969253; Thu, 01 Feb 2024 02:56:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706784969; cv=pass; d=google.com; s=arc-20160816; b=K6pOYtU5jFNXnxFmJNux4EzqsPn+z2UpOKL6xnFSJA/4WaLaxaXAViToWsbMv712JL S/6KCHL8OuFS7haSOFvidtAPMtU5BSjzsb1qCMW+hR2aAZ4oe8CmQH9DGHN+A69PrfYj QLMhe+jAqg/p4KZgVXK0m54npy6BKkP3yF/TjfxDxfhOrlisJtIzZsLK/EQvwhPyoXfH /eoxRL2pG591OifohAiudsWJ8uYfdL9Cdqnri2SDq2TUNQW/d8Lk7JYpjF2lq3tZkJGq flvAp1UlXmsCjUSFtXUe1HbOzzsg/8k0FfjDH6Lq8zVFHJ7LNknVgGSaMA2vC1PPC/iO EYNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=L+Xwd+C+cAluCHl1KWeJhjZou//dUR+pbJd4prPM+Os=; fh=vCt55AgZavKslOKdDtZED3Z1tIiDPQ/k+oVTWrhEITI=; b=JfgPnMLfSXAk9jyV9PZgk9qsny0j/rHSOqtNqGdJfnU6LqKGLNqj/EDTP/IZaOAEHM qlYQ5Z7DZbiWbrjPeN/52VFc3NWx6+Yk8mesPBCNSxwiiYyNmsTW8sEt6j8dJQYaBEIT /8uzOgJLwfXOpN9jlIm4TjgrAmV/Q58VGW8ZrWXNdeC4ZijoqkFZEC2kTA75Fxu/un9u OkfbL6eE6+pEH4TQZ792tRvZbuvyKjTUzym1xkeol/FH9eUawT7e9THN7XBlSxZj06kp ee3i5JFNmYJ2o/O+LRbGSdBqNl+8rJY7dBiTwSEp41zouej5QvA+JTPj8sqvNvOkmWZX m0yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jm3hRClr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCX1v2D49a6+sU20rP33oyAzcxxGiU0EbQeDyvMADb/Pm4Hfb/0uEn+VZP9CxfbdCVypqt9ce872rpu/0V9ciqijuMVerFeK35p34wprEA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o8-20020a05620a0d4800b0077f6ff697c6si9583696qkl.164.2024.02.01.02.56.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 02:56:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jm3hRClr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47991-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 03FFA1C22F5A for ; Thu, 1 Feb 2024 10:56:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE58315B990; Thu, 1 Feb 2024 10:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jm3hRClr" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2411A28; Thu, 1 Feb 2024 10:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706784961; cv=none; b=ONW8I8IHx5s4xf5obDO1GpCgre5ZFgejn3y1fV/ESe6uHrlgjOMBCrC1d46+JYmEbOckvifYobD1nfAcg2zfcn8nH7YOIn13jyfx4+GrXrPH/luMwViVGDbSGmxZUPcXTcRcDP+mxNxcGzDnKJO3JFg2lFoCYoqZqSwIxomi550= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706784961; c=relaxed/simple; bh=8xZUfd2otuKI9fuM5EHBBR4C7/ZhTByLG9LSNa2l4UE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dnp1iLaxQKdVZ1RTel6WK1AJwr8YjpFuuw92jbbLC/STxludBkvh1w99lzcgTMcqmjYJdnd7a8dfyA02S2UM5R6GLW9e8VEr+h90SeDaCi9AEq1sBOMy1Gb8bd+27Qe1jvHDxI/9Aorb7PYlSgcYwLLoEiIPXH/sa1sNkdu4C2g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jm3hRClr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0520FC433F1; Thu, 1 Feb 2024 10:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706784961; bh=8xZUfd2otuKI9fuM5EHBBR4C7/ZhTByLG9LSNa2l4UE=; h=From:To:Cc:Subject:Date:From; b=Jm3hRClreZUu5y+yJN+HH+aXnnZ8EdHuJI90VKlKqEoaAUd3jsbQ9klI6ewfQv3+R +/1Ps+qfOXne2oYtGCEkXoaXQfD8v08UtwGIji4D5MTgBDIcoQe9SrmxXPHXox1HBj /gbKg5qnvHhZN75Gmk2d/+VLPAUXmaJInF5/I6iuH/DBW3HreL1XIpNXWNWOTlQGzi flUYes2xnqYKp2uKU6OLz/S4FjDmyHxDzjT0XnNEExQCkfSKRxSc/ZGw5Y+4gi2cHP stsp/qGv9AYzDkuPyrwBSXWwo/cTF9yepX5uJztvSBJyn3P5Hbi9ufLqAghiTx8uhP GEQvCqZ6jRhrg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Emil Kronborg Subject: [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags() Date: Thu, 1 Feb 2024 11:55:56 +0100 Message-ID: <20240201105557.28043-1-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit And an enum with a flag: UART_TX_NOSTOP. To NOT call __port->ops->stop_tx() when the circular buffer is empty. mxs-uart needs this (see the next patch). Signed-off-by: Jiri Slaby (SUSE) Cc: Emil Kronborg --- Notes: [v2] fix/invert the condition include/linux/serial_core.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 536b2581d3e2..55b1f3ba48ac 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -748,8 +748,17 @@ struct uart_driver { void uart_write_wakeup(struct uart_port *port); -#define __uart_port_tx(uport, ch, tx_ready, put_char, tx_done, for_test, \ - for_post) \ +/** + * enum UART_TX_FLAGS -- flags for uart_port_tx_flags() + * + * @UART_TX_NOSTOP: don't call port->ops->stop_tx() on empty buffer + */ +enum UART_TX_FLAGS { + UART_TX_NOSTOP = BIT(0), +}; + +#define __uart_port_tx(uport, ch, flags, tx_ready, put_char, tx_done, \ + for_test, for_post) \ ({ \ struct uart_port *__port = (uport); \ struct circ_buf *xmit = &__port->state->xmit; \ @@ -777,7 +786,7 @@ void uart_write_wakeup(struct uart_port *port); if (pending < WAKEUP_CHARS) { \ uart_write_wakeup(__port); \ \ - if (pending == 0) \ + if (!((flags) & UART_TX_NOSTOP) && pending == 0) \ __port->ops->stop_tx(__port); \ } \ \ @@ -812,7 +821,7 @@ void uart_write_wakeup(struct uart_port *port); */ #define uart_port_tx_limited(port, ch, count, tx_ready, put_char, tx_done) ({ \ unsigned int __count = (count); \ - __uart_port_tx(port, ch, tx_ready, put_char, tx_done, __count, \ + __uart_port_tx(port, ch, 0, tx_ready, put_char, tx_done, __count, \ __count--); \ }) @@ -826,8 +835,21 @@ void uart_write_wakeup(struct uart_port *port); * See uart_port_tx_limited() for more details. */ #define uart_port_tx(port, ch, tx_ready, put_char) \ - __uart_port_tx(port, ch, tx_ready, put_char, ({}), true, ({})) + __uart_port_tx(port, ch, 0, tx_ready, put_char, ({}), true, ({})) + +/** + * uart_port_tx_flags -- transmit helper for uart_port with flags + * @port: uart port + * @ch: variable to store a character to be written to the HW + * @flags: %UART_TX_NOSTOP or similar + * @tx_ready: can HW accept more data function + * @put_char: function to write a character + * + * See uart_port_tx_limited() for more details. + */ +#define uart_port_tx_flags(port, ch, flags, tx_ready, put_char) \ + __uart_port_tx(port, ch, flags, tx_ready, put_char, ({}), true, ({})) /* * Baud rate helpers. */ -- 2.43.0