Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7059578rdb; Wed, 3 Jan 2024 03:20:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXm0u8dwwCkL1dNEhaG5P/EuUzV+lGmUWVo0qffbe+CWNqFmL3vNU/vEnZqwAfvOyr1dZm X-Received: by 2002:a05:6512:e98:b0:50e:7b20:3df3 with SMTP id bi24-20020a0565120e9800b0050e7b203df3mr6679591lfb.76.1704280802491; Wed, 03 Jan 2024 03:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704280802; cv=none; d=google.com; s=arc-20160816; b=0ZLTgvr/ilgplpjE/IGJwMsjV0x0g0rlUqByYeCfGQh/x/9UUFWMSbSnqll/xtpIH8 wAcQ6oMkijRqZdRPAPLeiZJezgxWo656l6ApGz/kE6bn1ZuQUb4GceXGYkyY4/2iQosu lZKfrypJPcdegxsYD9qyJdHDLdQOkLHGTEc+g5RIEdOBt6QS6WZk7ohwTn/jvfPLsziH i0i4Tnzg5zoX8+fnPC44CMpF4eFF2JQ7p24YozDgpd/wW28o2UxjRLBwY8z9Rsf1QJAK e7uhPY73C375XStuVj5FYd2ecNcW4QHUCigvdIh8gK6P6RG7Nfhswt+nv5R3pQ4oMrhH m8Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=ZM+zXcZ3D06QRTV9zsV9cUImQIHRGauXzfaH1HXtjoo=; fh=J2p/IaSan4b5TVxOcXtJf9+aXWiRnmjNtwEvl/6JCH8=; b=AsRb4huwQpHlzE7tqBCfFENQ7mVOn9eRqypnF4OeFA0WnZ99Ac9oFA+5dnAcdUJf/I HG9ggKbJ29IMnn43DDsYAdP2anjQpJIpeiuxWqOMVWR1+BkwY2uD2NKWILL9DCJH/n6b s6+o2rDndIzw0O7bTycRQMWYbedPrE7jiuxcjXQNBuc1ul6GvIFuVTuWGoXaMsTZRm6z EHHKDh6R+E9wPkQv0dVnTi/XFsXbNHSNNiRdXvCW3owfQV9Bys8pS1MD5ZV1qF7U2iqw rY1xfscfep14tWcjcT1El1rWfnhSiO3GzjWaFwlO4jGg3gRAP8Hjf3uTmjz7Lmpzl+1O Z/kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iUJmz+cW; spf=pass (google.com: domain of linux-kernel+bounces-15436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f19-20020a0564021e9300b00553059ffc89si12291446edf.530.2024.01.03.03.20.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 03:20:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iUJmz+cW; spf=pass (google.com: domain of linux-kernel+bounces-15436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3EC021F23C7E for ; Wed, 3 Jan 2024 11:20:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70E4A18E23; Wed, 3 Jan 2024 11:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iUJmz+cW" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 EA7BA18E0C; Wed, 3 Jan 2024 11:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704280791; x=1735816791; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=BN4G4B17WwmtxZfwQRC+8qZ6+KYHHxYIaVabnY6Z5v8=; b=iUJmz+cWf8c7u5PdHvduyBhBFPFAAm+/XQRH+fYHjodr8SQczYKYG+yI zrk90iGdwroZlrYMSNdr3//gwjy6RuS2utsvsK6DmHOI7OkUYEoGDGOfa rfUl5ZsSS2G0zSRePRGRiT6ZaFNLHIUEHLONaIiG2Mo5hz0GjeN3lL/QS Dy4VKsTroa5y4CHXpOTfjUaa8NaNowBr+2QfemDVA6APjdeszpzZYE+lT neRt/ILFJLFPO5fGnpdLadtPNG+9nGr2Oieq6ILcocbcP83idzvpsoSfH MelfZX2fteDou96ojWhzAFg4OJjjCrS0bEq1mr9EgNH8z0dx8qJmDQQyE g==; X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="4342999" X-IronPort-AV: E=Sophos;i="6.04,327,1695711600"; d="scan'208";a="4342999" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2024 03:19:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="779965501" X-IronPort-AV: E=Sophos;i="6.04,327,1695711600"; d="scan'208";a="779965501" Received: from bergbenj-mobl1.ger.corp.intel.com ([10.251.211.32]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2024 03:19:45 -0800 Date: Wed, 3 Jan 2024 13:19:43 +0200 (EET) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Lino Sanfilippo cc: Greg Kroah-Hartman , Jiri Slaby , u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, hugo@hugovil.com, m.brock@vanmierlo.com, LKML , linux-serial , LinoSanfilippo@gmx.de, Lukas Wunner , p.rosenberger@kunbus.com, stable@vger.kernel.org Subject: Re: [PATCH v7 5/7] serial: core, imx: do not set RS485 enabled if it is not supported In-Reply-To: <20240103061818.564-6-l.sanfilippo@kunbus.com> Message-ID: <75c0cbd4-7cec-a415-bfba-376f035f76@linux.intel.com> References: <20240103061818.564-1-l.sanfilippo@kunbus.com> <20240103061818.564-6-l.sanfilippo@kunbus.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-84096764-1704280789=:1706" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-84096764-1704280789=:1706 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Wed, 3 Jan 2024, Lino Sanfilippo wrote: > If the imx driver cannot support RS485 it nullifies the ports > rs485_supported structure. But it still calls uart_get_rs485_mode() which > may set the RS485_ENABLED flag nevertheless. > > This may lead to an attempt to configure RS485 even if it is not supported > when the flag is evaluated in uart_configure_port() at port startup. > > Avoid this by bailing out of uart_get_rs485_mode() if the RS485_ENABLED > flag is not supported by the caller. > > With this fix a check for RTS availability is now obsolete in the imx > driver, since it can not evaluate to true any more. So remove this check. > > Furthermore the explicit nullifcation of rs485_supported is not needed, > since the memory has already been set to zeros at allocation. So remove > this, too. > > Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported") > Cc: Shawn Guo > Cc: Sascha Hauer > Cc: stable@vger.kernel.org > Suggested-by: Uwe Kleine-König > Signed-off-by: Lino Sanfilippo > --- > drivers/tty/serial/imx.c | 7 ------- > drivers/tty/serial/serial_core.c | 3 +++ > 2 files changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > index 9cffeb23112b..198ce7e7bc8b 100644 > --- a/drivers/tty/serial/imx.c > +++ b/drivers/tty/serial/imx.c > @@ -2206,7 +2206,6 @@ static enum hrtimer_restart imx_trigger_stop_tx(struct hrtimer *t) > return HRTIMER_NORESTART; > } > > -static const struct serial_rs485 imx_no_rs485 = {}; /* No RS485 if no RTS */ > static const struct serial_rs485 imx_rs485_supported = { > .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | > SER_RS485_RX_DURING_TX, > @@ -2290,8 +2289,6 @@ static int imx_uart_probe(struct platform_device *pdev) > /* RTS is required to control the RS485 transmitter */ > if (sport->have_rtscts || sport->have_rtsgpio) > sport->port.rs485_supported = imx_rs485_supported; > - else > - sport->port.rs485_supported = imx_no_rs485; > sport->port.flags = UPF_BOOT_AUTOCONF; > timer_setup(&sport->timer, imx_uart_timeout, 0); > > @@ -2328,10 +2325,6 @@ static int imx_uart_probe(struct platform_device *pdev) > return ret; > } > > - if (sport->port.rs485.flags & SER_RS485_ENABLED && > - (!sport->have_rtscts && !sport->have_rtsgpio)) > - dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); > - > /* > * If using the i.MX UART RTS/CTS control then the RTS (CTS_B) > * signal cannot be set low during transmission in case the > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index 28bcbc686c67..93e4e1693601 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -3600,6 +3600,9 @@ int uart_get_rs485_mode(struct uart_port *port) > u32 rs485_delay[2]; > int ret; > > + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) > + return 0; > + Reviewed-by: Ilpo Järvinen -- i. --8323329-84096764-1704280789=:1706--