Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3119794rdh; Thu, 28 Sep 2023 03:19:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUuqC1+Y2I9jTFzzBsRY8Fm3sauNEIpmBbgpCG9U5+F8ZRPSbRqGfzbKkAM9K2lxeKus+y X-Received: by 2002:a67:ec87:0:b0:44e:8ef9:3371 with SMTP id h7-20020a67ec87000000b0044e8ef93371mr568839vsp.8.1695896351223; Thu, 28 Sep 2023 03:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695896351; cv=none; d=google.com; s=arc-20160816; b=JmsabB/nXo3mjdZzL12HQXZHBsH2DJ4xRpmUC7OdZl87d/AmMenu1pkv8V3ObIVs6d mhLW9kJOZmfNYVJEu3IRRoa5avu5ROMBDZ+qd2sOgAnm92XKHzjSTGUVEjRTwtgvtwO+ 9mAg6Lc4xqbyZHg7m6hVnfzt/umE1hVCYQphrGDJ6COgqPCMOVRjEQ3j2m5BeKuTSWBJ QNHT0IyLhBU5q19nnWPyyJC2n0AEE7bLyRT/EyQSr4+kM8CFTpGY3Z9xSjiM7nUMzvFM istCYwnqSYFjJbH4fyKmiMIGI797zTOYXtdyBmFlT31/tXjzNM51TbR/hAZ6e0nmcEox Sr0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iZCl/bgW7YG/BPj0M0aPLzVLr3yvYyzD/QJzJYlPtnE=; fh=CnQBB6Ftqk9bebJVVTwS0omEriTocO3IqLY7kUEn/jY=; b=W1xmuel7HU7rDOUPx4D6EDFl7h3+aYNglXDt06A82Ja+ZiTIpx2ufAYL+OEqp3hUI8 WyVFLcHz8z1ol22Q22HB7+E7cpRO9bwAEinnpVqTgNEX9nFOYc7tvgeAHkUryxVZoekY 5i4qdjqxAevfeSN6aCu5Y74NgzxxdEcm+drydWn9+/+qRIPx+vmxh8VOgGQhBgZVPgif LN0YXINC3w+ZFfQKHHdHyAJFqRr8zm8adJCSfQYuOMZ+1pueXeIzbRaekOgYO9Y4Q38R r1XxjbmHgie58aP9OByAmjBCVCmv6Nu7QmDSuL92qB8HYWkk3/TpEqI7MME1VHBYNUh8 7ijA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mdKT26sK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i7-20020a636d07000000b0057745b2d018si15601590pgc.390.2023.09.28.03.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 03:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mdKT26sK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3CD728065EDA; Thu, 28 Sep 2023 01:17:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231200AbjI1IRs (ORCPT + 99 others); Thu, 28 Sep 2023 04:17:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjI1IRr (ORCPT ); Thu, 28 Sep 2023 04:17:47 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FE6BAC; Thu, 28 Sep 2023 01:17:45 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06C89C433C9; Thu, 28 Sep 2023 08:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695889065; bh=f0Py5KsQnV1kllOtBgaMRjOqXMqsVEKHE9P7jkmTxLc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mdKT26sKpwvKyVxjrAM3SwSFoLqZQ3Ap9kIl3LPvUuGJri7B/UskSlNUv3pTUlydj +cKEq+FCaDatZOay9enVHnlVG0SmJU+tjbwN50C51rL/jz5Bn9ZRZiqPTS+5QBN0F+ U5KdvwyZuPYLoyKpkGLGxI7c0lpnWRHDl84zjW4w= Date: Thu, 28 Sep 2023 10:17:40 +0200 From: Greg Kroah-Hartman To: Max Filippov Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, devicetree@vger.kernel.org, Jiri Slaby , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ilpo =?iso-8859-1?Q?J=E4rvinen?= Subject: Re: [PATCH v2 1/5] serial: core: tidy invalid baudrate handling in uart_get_baud_rate Message-ID: <2023092835-applied-shakable-f5dc@gregkh> References: <20230920022644.2712651-1-jcmvbkbc@gmail.com> <20230920022644.2712651-2-jcmvbkbc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230920022644.2712651-2-jcmvbkbc@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 01:17:58 -0700 (PDT) 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 > --- > 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