Message ID | 20230920022644.2712651-2-jcmvbkbc@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3848717vqi; Tue, 19 Sep 2023 20:32:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqBI+YCFGKyO7PqhDOE1QoshLjDEZIR8x7Ady1mhh12a9vSZriHf7LETK85Vj3LhQTbKSZ X-Received: by 2002:a17:902:efce:b0:1bc:6dd9:82c3 with SMTP id ja14-20020a170902efce00b001bc6dd982c3mr970845plb.37.1695180753833; Tue, 19 Sep 2023 20:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695180753; cv=none; d=google.com; s=arc-20160816; b=r1Fv7NJnFbtbpSnuj7RWiaawcYtq5cbbXGkMVdj93UG0i9dBDw11jnHDEEBxUFehLT f62A2P3U1o5487ffuogY07FbNr363MzIVuB9zoobSPNkXrOflWc5YZxnuMUbYz1LcQKz /AeK7fZfVkGSN3O+hN55SWZm08aIHbZAIjBFlYmf+6SwicvUGxj3sRKZ9ANX66RMejcO D5icEajjtDunCYkMbWZ+E0zjo3AWRU0SSwI4OberlCfsXSIB+YXUNuzDjIMgWRbhMnRF iinoLZGy8ypKBTqcE9CTJroa0VIxRkxmRhyDtQkNQ4sCODxGe0sNKOj61NfsXZKu6rlM GURg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fa6uFbknqzj199lmh6a4GX+0E1qDjG74urk1D5Bo0C8=; fh=oqMYt5FzSjXDp/dSMFfnsNSIER/pF2eV0abPard7Ac0=; b=NUCGvDuPtxppC3VvrQ4ySiT3Uqrc+H7th0o23nDMjOmEmZ6IPdgTmeH/hhHzPqmC1G cCHf4JGN2wOefvck5wnSdMLAJdKTLDlz5KdP1t04U+Iz9jCNhvlxWcu+pO3e76YR+X6j QJfwABKqGQX7iXIJP76csNvD7tlq7LKeWK72E6WWV6wzbV3D532vEtC9tWyShiOJ9C4p YrTe3bFP9i6X/sM/qb7Gp4kf0dM7ZOUO2wjJf1m8gLKQ4OTYM59NwDDK2NxMpjYjLnBq ElhAzLwQaEdzuqJypqQUmGnngFbQdPc7b23j0iquTibLpOfVzgaj7wWRunhI6l8m8L/D yqHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jBHiTZ+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ks15-20020a170903084f00b001bc2fd76db1si10423949plb.65.2023.09.19.20.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 20:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jBHiTZ+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 8FED3827D0CA; Tue, 19 Sep 2023 19:27:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbjITC1L (ORCPT <rfc822;toshivichauhan@gmail.com> + 26 others); Tue, 19 Sep 2023 22:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbjITC1H (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 19 Sep 2023 22:27:07 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B194DC6; Tue, 19 Sep 2023 19:27:01 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-59bfb0825efso57102217b3.3; Tue, 19 Sep 2023 19:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695176820; x=1695781620; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fa6uFbknqzj199lmh6a4GX+0E1qDjG74urk1D5Bo0C8=; b=jBHiTZ+Ex9586TBVmGyUZ86g8+TpbQADy+uujvG4Zrl9cnZhpW0QK3bZnvoTq/fdPY kZ1zkZQSImAtuudl3VidbXQIVIuvizyS7sQ7kD/KVnkL3ppJwTyxxrAXXxgfXfaFfWMM P86DQGZjQntWNN8uwVQ5uDlPdMnz/L3Wy4wP3+upZ2pNyQFU9t2GcETWhAg93VfZ397n 32VjdPHWZ5cZ4hgmR8Uxh8pb9TCQCXF2H7aQBhFrYw+Wlg1u7OHAzOXxDrDnE2+xulsD YmLeKoeQ+HCldAphaX9aHS5OPPD5g9q4zk8Ff2Eev5ZbzbsGP1VSoI7xNU6/Ih26++xf aymw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695176820; x=1695781620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fa6uFbknqzj199lmh6a4GX+0E1qDjG74urk1D5Bo0C8=; b=JOp9D6FNteVz0reV41tSWLnofwJKcvDg43Z6FIYVHy0x1+8Nl0yAD18Acmqzv9109M LDuF0Q6Gfj8JPZ3y/7gJLEMItxQXBefLMlMO3C0idwJHf/dfxh/ObZY/3oxML6XT6GC5 eTHM1wKc2u0tC3dKB6GgiIT+ivhQh/ky8TEo2qh7VKWyVsGa3jxkBajb59yH4nfg5bLB zLxvK6yK5z1oQD9t8MQf4iJHgwfBDasd0d1wbFwV4PfAmfngj6iywPGMQ9inPxiandMN uuaK9M33OIIIRM+SFj7dNaA44f3v9R6eE6GK0UdRfX5pzYjeDnHWwip5K4seueeGs+GB Vvog== X-Gm-Message-State: AOJu0Yy7T2sue3QP6WzuyE3hzoCFkCRZkafjr4gNLlP52IXgNRsn8ZoB 0b0xuGrGK+eY4Cxwg1zGFHdjNmwawds= X-Received: by 2002:a0d:e84f:0:b0:59b:cde8:fc35 with SMTP id r76-20020a0de84f000000b0059bcde8fc35mr1366263ywe.24.1695176820490; Tue, 19 Sep 2023 19:27:00 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net ([2601:646:a201:19d0:9ca3:318f:421e:68cb]) by smtp.gmail.com with ESMTPSA id p15-20020a62ab0f000000b0067aea93af40sm9224757pff.2.2023.09.19.19.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 19:26:59 -0700 (PDT) From: Max Filippov <jcmvbkbc@gmail.com> To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, devicetree@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>, Max Filippov <jcmvbkbc@gmail.com> Subject: [PATCH v2 1/5] serial: core: tidy invalid baudrate handling in uart_get_baud_rate Date: Tue, 19 Sep 2023 19:26:40 -0700 Message-Id: <20230920022644.2712651-2-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230920022644.2712651-1-jcmvbkbc@gmail.com> References: <20230920022644.2712651-1-jcmvbkbc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, FROM_LOCAL_NOVOWEL,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 19:27:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777525854071371012 X-GMAIL-MSGID: 1777525854071371012 |
Series |
serial: add drivers for the ESP32xx serial devices
|
|
Commit Message
Max Filippov
Sept. 20, 2023, 2:26 a.m. UTC
uart_get_baud_rate has input parameters 'min' and 'max' limiting the
range of acceptable baud rates from the caller's perspective. If neither
current or old termios structures have acceptable baud rate setting and
9600 is not in the min/max range either the function returns 0 and
issues a warning.
However for a UART that does not support speed of 9600 baud this is
expected behavior.
Clarify that 0 can be (and always could be) returned from the
uart_get_baud_rate. Don't issue a warning in that case.
Move the warinng to the uart_get_divisor instead, which is often called
with the uart_get_baud_rate return value.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
drivers/tty/serial/serial_core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
On Tue, Sep 19, 2023 at 07:26:40PM -0700, Max Filippov wrote: > uart_get_baud_rate has input parameters 'min' and 'max' limiting the > range of acceptable baud rates from the caller's perspective. If neither > current or old termios structures have acceptable baud rate setting and > 9600 is not in the min/max range either the function returns 0 and > issues a warning. > However for a UART that does not support speed of 9600 baud this is > expected behavior. > Clarify that 0 can be (and always could be) returned from the > uart_get_baud_rate. Don't issue a warning in that case. > Move the warinng to the uart_get_divisor instead, which is often called > with the uart_get_baud_rate return value. > > Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> > --- > drivers/tty/serial/serial_core.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index 7bdc21d5e13b..a8e2915832e8 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -431,7 +431,7 @@ EXPORT_SYMBOL(uart_update_timeout); > * baud. > * > * If the new baud rate is invalid, try the @old termios setting. If it's still > - * invalid, we try 9600 baud. > + * invalid, we try 9600 baud. If that is also invalid 0 is returned. > * > * The @termios structure is updated to reflect the baud rate we're actually > * going to be using. Don't do this for the case where B0 is requested ("hang > @@ -515,8 +515,6 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, > max - 1, max - 1); > } > } > - /* Should never happen */ > - WARN_ON(1); I'm ok with this removal, but: > return 0; > } > EXPORT_SYMBOL(uart_get_baud_rate); > @@ -539,6 +537,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud) > { > unsigned int quot; > > + WARN_ON(baud == 0); Why is this needed? If this isn't happening today, then there's no need to check for this here. Or if it can happen, we should return an error, not cause a possible reboot of the system if panic-on-warn is enabled. thanks, greg k-h
On Thu, Sep 28, 2023 at 1:17 AM Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote: > On Tue, Sep 19, 2023 at 07:26:40PM -0700, Max Filippov wrote: > > @@ -539,6 +537,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud) > > { > > unsigned int quot; > > > > + WARN_ON(baud == 0); > > Why is this needed? If this isn't happening today, then there's no need > to check for this here. I'll drop it then.
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 7bdc21d5e13b..a8e2915832e8 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -431,7 +431,7 @@ EXPORT_SYMBOL(uart_update_timeout); * baud. * * If the new baud rate is invalid, try the @old termios setting. If it's still - * invalid, we try 9600 baud. + * invalid, we try 9600 baud. If that is also invalid 0 is returned. * * The @termios structure is updated to reflect the baud rate we're actually * going to be using. Don't do this for the case where B0 is requested ("hang @@ -515,8 +515,6 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, max - 1, max - 1); } } - /* Should never happen */ - WARN_ON(1); return 0; } EXPORT_SYMBOL(uart_get_baud_rate); @@ -539,6 +537,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud) { unsigned int quot; + WARN_ON(baud == 0); /* * Old custom speed handling. */