From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380152; b=lVKBXuA+Q74tZGvJqGNTvGy354rXZTx0RUSMwFPehhGeG9X6J4GXgtZTtozsrx0VKQxW 0Yjwn6w1MwpHsPtMBFHhgGV0NOchh79ItV7B0YuQqPeoT8SIbqGgIuRR8u4qcpCkgG3Jt i7L2AVJhETQQxq5mvwGdj3ZGLNMothabxzhLEGFHSCe1LlmBd4EYVBIBH7z66VszeTZMv /mZcQzMw2BTrOZaVrgGLXxcF5kzxEjAwZlSEa+rryqvoz07OEoznG3Bwh9JSbGnOP7jCA 7xOxVY7w9v7JHH6u9Z9JBB8yAiG/1iyVu98jT/7WxyhKQW/47AT8201sBXbhoghaScA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380152; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: References:In-Reply-To:To:Cc:X-Mailer; bh=wQd2y5d3c9Xle1BZoXd9DRgnl2+Av/870a5uei8ZYeo=; b=c1uinD12zElyS8K0L2Dhz3iC9q5zM+EtyIimkIEDQb2zJUAfjNV/GTNAVLmLXx8qzBvZ Azlur2v9UCIlDYBmVPOycDv0yIP0+UuBqHFL4ctK8wQHDQMfT2ui4jF3g8gnCsYDJGut+ WCWcdxUpizqJDPhjsh+Eq6Vmr8BR9aw6YCJtdKA4QjXCZRhA9jRp5xBNRLs/2a92xw0qg 138FK/T3GzVonc8t3UpHeo42Eewwj7bDyQJxodJoBKIqoKocv1Ac8dzQwPewX1UIewLdi 63nqtXpkEE/DoJFAXFh3ujszmeTSBTVFmHmmQkYydWjqV01HVvm/AHMO5kpb97ZnX+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=cITw8sRS; arc=none smtp.remote-ip=209.85.210.48 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36C05606A6B5 for ; Fri, 4 Dec 2026 10:29:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 36C05606A6B5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=cITw8sRS Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-8470d7d430fso427935a34.3 for ; Fri, 04 Dec 2026 02:29:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796380151; x=1796984951; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wQd2y5d3c9Xle1BZoXd9DRgnl2+Av/870a5uei8ZYeo=; b=cITw8sRSJVcWF/Qf4o3qXX+M5pg7N8aaoVLhwVo7BvAt1nn8ds9xkDVcMFL/FQkrtO i9y/gRLLyIohMMUmiCDDjoPun5LeCzyplOfu/O9H22NBIFxOAbkgboqrZqTDHyQ+XpJg bz6mVI7ws654aggyUdgTYY/9nvb/7tnAWiyGcvqBTOH0ajaSit0rCN9UeJd2xeGOVCK2 7T1LPDBPmnUSd6o67RVIPheq1bw64HGVFyQ2YhDs7kekEa+ZaKI0xxY6gwXt2lezu314 RUgvbSNBnb6Mu/UW8TWDh11fV5X2KNaYBG6tTAZdNPYh4a0srfe54tYddvs0hW4equY1 MV3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796380151; x=1796984951; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=wQd2y5d3c9Xle1BZoXd9DRgnl2+Av/870a5uei8ZYeo=; b=oS/3HTTAsveG22vCxg4TaQB+n9wRmlfwKG9W1G1di3b9M7TsDZQnLhpnJJ/oHcvy4N 8h+KyWj4Ef3QkhmU+yy2SEti9LoQ7hTvoPKqmnb8rWPaMEXEE0u8P2C74mkq18ioFDIk vKRW/e938Y8HiDniWXecKjdWWIyUMX5B8Nvrrs6EU4mnhVH4JGGH/nFS60BUh0lk0NrP mBgQmu9cWoJ7wPgegM3Z5JP0YW7RnVfvv6l3EzdnIGWjqs59oubA5ph7gqr8/vn/WYd5 Dw1m/CPKVQns5wdzjXJKk0AWcWdl+kJwNH43IuvkTYbAGaPUqWFVQvNtoKcAX8Kwgxz9 1F4w== X-Gm-Message-State: APuU4Z9y2z3KHDtfM5moOxbhuDLgd2PBai0tGBCtag1yKlr8xPCrRfLD OEZGYvEMoJNrhOwqLo/H1Rtz+8KADa1TecKrV8h8KXnsdn5mAm9PXRoW X-Gm-Gg: AZFdTZdsmVjTNbNchNVJ+2gxZlrwuQThxPpqbR+v18FhRm3VB+NQWoeTTg7IonaBhhA rGVUPZcLd8awuTUAto/jHPJ0RJwY4hb6fEglTTivnFSnYLhH/qAEB9YYg6YHHW/SZZy5yU1i6Yc fyj2kGnh9Bc0s8UE74A997+an4NTMJR5319szYytDYWh3Lrm+HTDPF25lufzxRAwB4ev2bI+imm dgwPYEHw50vOFVDvy+bc7lyiBDRplSb5+By3wO1uxiwXCtuPU5sszXfnujkjImeFkDxTsPbhRyX xUQJbMpmDHsWXbk4R/ofjqA8JomHHf/qoHTSmQaETJzHZKeYtZEAZtpvwfYsyPv59//yRmsPHPI bXrgL8S+QIHZWrX7p2Ohq+SAGYpFhVoo4iH42+ZRz43T4oPOoENEpr0VQRU5pZZCZSwDU5GnBce kKb0TzN4XXNWRtXOU/EF95GROUQ9+6GkemDBbjBOq6/x3aqVLpf2dyVoEc6iBzRX6qXS6YLgwCc t+KQiZ+UiD1Uai6mWes3uu+HjkC0BkU6YyL2UQj2ZK1QjXw5BBfkyV0L0u477pWNW/pBnOUTqqD yID7Gs9fq4s9zvr4tR37/GKPsZrhZzELPuB+mxaF+6S2mLhrl6kkL4fpHC4dik9fisAxX3DzClh VpIdm7z2jj9pGMxxrq+9kdYsrP+Bg6Ogx2r5KmoS3fQeiIZj02jKwqugJz1if3N2U2Y9LMWXZvC iNsmk/INNvOrsm7idiLkgsfRpTpchKAcspr2Krm/C1i1AjVS2FnvNZVA== X-Received: by 2002:a05:6830:918:b0:829:8a9b:de79 with SMTP id 46e09a7af769-863f8911452mr1858017a34.4.1796380151213; Fri, 04 Dec 2026 02:29:11 -0800 (PST) Received: from [127.0.1.1] (174-29-20-82.hlrn.qwest.net. [174.29.20.82]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f81fad14sm1747533a34.9.2026.12.04.02.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 02:29:10 -0800 (PST) From: James Hilliard Date: Fri, 04 Dec 2026 03:28:49 -0700 Subject: [PATCH v10 04/11] serial: 8250: share the RX trigger conversion helper X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20261204-submit-h616-uart-fifo-v1-v10-4-1a9fb4f79635@gmail.com> References: <20261204-submit-h616-uart-fifo-v1-v10-0-1a9fb4f79635@gmail.com> In-Reply-To: <20261204-submit-h616-uart-fifo-v1-v10-0-1a9fb4f79635@gmail.com> To: Andy Shevchenko , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Greg Kroah-Hartman , Jiri Slaby , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, James Hilliard X-Mailer: b4 0.17-dev Drivers can supply receive-trigger thresholds through the RX trigger callbacks without adding a legacy port type to uart_config[]. Extract the threshold search into serial8250_bytes_to_fcr() so those drivers can use the same conversion as the generic 8250 implementation. Keep the implementation in 8250_port.c and share it within 8250_base. Include the unsupported-table check and preserve the existing nearest-lower selection and highest-encoding fallback. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Reviewed-by: Ilpo Järvinen Signed-off-by: James Hilliard --- drivers/tty/serial/8250/8250.h | 2 ++ drivers/tty/serial/8250/8250_port.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 939b7d4209f1..8729619160ea 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -73,6 +73,8 @@ struct serial8250_config { unsigned int flags; }; +int serial8250_bytes_to_fcr(const u16 *rxtrig_bytes, u16 bytes); + enum uart_port_type { /* Internal 8250 only */ UART_PORT_AIROHA = 124, diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 452851815ffc..73bc9e7ab703 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -3015,16 +3015,15 @@ static int fcr_get_rxtrig_bytes(struct uart_8250_port *up) return bytes ? bytes : -EOPNOTSUPP; } -static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, u16 bytes) +int serial8250_bytes_to_fcr(const u16 *rxtrig_bytes, u16 bytes) { - const struct serial8250_config *conf_type = &uart_config[up->port.type]; int i; - if (!conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(UART_FCR_R_TRIG_00)]) + if (!rxtrig_bytes[UART_FCR_R_TRIG_BITS(UART_FCR_R_TRIG_00)]) return -EOPNOTSUPP; for (i = 1; i < UART_FCR_R_TRIG_MAX_STATE; i++) { - if (bytes < conf_type->rxtrig_bytes[i]) + if (bytes < rxtrig_bytes[i]) /* Use the nearest lower value */ return (--i) << UART_FCR_R_TRIG_SHIFT; } @@ -3032,6 +3031,13 @@ static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, u16 bytes) return UART_FCR_R_TRIG_11; } +static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, u16 bytes) +{ + const struct serial8250_config *conf_type = &uart_config[up->port.type]; + + return serial8250_bytes_to_fcr(conf_type->rxtrig_bytes, bytes); +} + static int do_get_rxtrig(struct tty_port *port) { struct uart_state *state = container_of(port, struct uart_state, port); -- 2.53.0