Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2186760iog; Sun, 26 Jun 2022 08:50:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v5Uq6eHV5U7w2ij86suqiF3qlbDhKJcL3ekk7lnADp5aV5/u7QKtlehWv9Lr0mw96kI9f4 X-Received: by 2002:a17:907:6e9f:b0:711:d2cb:63d8 with SMTP id sh31-20020a1709076e9f00b00711d2cb63d8mr8973553ejc.232.1656258653046; Sun, 26 Jun 2022 08:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656258653; cv=none; d=google.com; s=arc-20160816; b=wjfW0U9YR76frri6l6dq8JA31D2arnpSqn5Uj4aSg1Ca4W+0CK3INSFc9nhwVN8vh/ 2dMlxgRzROBRgN/Jnp4yGyCAE072v9kj6bSiDAA2jLGsOgDoItzNw6En/NFNtELJKGDO +V1GItO3Rnf1ssjSfDXzJ7TaDjJXS8YxrBuzb6Wa3wfalcuRpWTtuqa2RsIhV1ceCb5M /JhGmwOy2+QosUkQ2K5/iiCfUtat3AafFpIHh0wvio7pNZCB0wFPZ8hNsvLQyKwTT3FE /b9d9PhixGde4oRRBpf4aAmSa6/GHRLSgS3UDYx7DCNmbCz9AdQltiSRtqY125OP1Ysp Exvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=zWjs3nJIkkorVLNc2AfzSTWrJH9xFPp97kCOBPgdKJE=; b=K2TD9ejAmY1fZ3eesWtUoYM5RBz3lu7LnaJHl/8+v4HPecWHuRtJUHi3HHo6aGISh8 SE0Sb0oVxWaADoUa7V0NdYwmJw9/QFzywqGg2pHoAGkUEZMsKY80Ev+RRHYPQSwbLa+P S3ht6cUf6MbVa1QHwszktnJQKAE0wMChawc9iSYudAebbCGoNYAwb4DIdEjSxd3GINmw 67bhwnjXX1ZqM6zeRSo9zKYq2mAQfB0DYqUi1vGDEirWVKWjHaxtjpXlAZAK7hXC5lt/ dUBOJGvs8eaIhGPs+MYPNfSIv9ogROMEv0t6MwyO+Oj/wJ2BM1PwdFKboLLKXZ/h3crY bInA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=SHlhQLJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020aa7c3c8000000b004358f58a77dsi6797432edr.63.2022.06.26.08.50.29; Sun, 26 Jun 2022 08:50:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=SHlhQLJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231563AbiFZPmB (ORCPT + 99 others); Sun, 26 Jun 2022 11:42:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbiFZPmA (ORCPT ); Sun, 26 Jun 2022 11:42:00 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F39EDFDB; Sun, 26 Jun 2022 08:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656258099; bh=9wnn2viNtYo2HS4a6b8V2lbF+SSHfd4WFAFaclgRsso=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=SHlhQLJT8dgGcqR+X5nHvn7Yjw4el0brNLtT897XUkjePIvV7HSm8fOECnfOBmutl x6KPuUYG554QgIvtaUVlD7FQ+d0+i/+9+eK0kxF/jy2xDFddJR5rmueyp6NRelRDzk wCOCGuqjgcXIdlJrmnUVtAgIv3A+7RhI+qgSCuuA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.0.33] ([46.223.2.248]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M7b6b-1o0Ef93eAf-0085OH; Sun, 26 Jun 2022 17:41:38 +0200 Subject: Re: [PATCH 2/8] serial: core, 8250: set RS485 termination gpio in serial core To: =?UTF-8?Q?Ilpo_J=c3=a4rvinen?= Cc: Greg Kroah-Hartman , Jiri Slaby , robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, Andy Shevchenko , vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial , LKML , lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> <20220622154659.8710-3-LinoSanfilippo@gmx.de> <83762813-70ec-93c3-4015-5676ce9534fd@linux.intel.com> From: Lino Sanfilippo Message-ID: Date: Sun, 26 Jun 2022 17:41:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <83762813-70ec-93c3-4015-5676ce9534fd@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:cyIQlMtZ+G8jaNtEoKMkpMf21pMZu7+zmG4ZsrBrWfjfJ8shTgY pupK7k4b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6UU6MaBCRVlkNp LYkOPRUGYyrFZpctUonaYlx4cWvaMifyDxhe7g2aXBjPtjkuYPHWmy7YLxxuAhiugVFmkKaQW eRtw+y89NGeDycpISmXxIdc2u4mt12L3+LMCMwc8cGaaHYbekAAvdjIiVBL+aJJswjPSnc8c5 FCwh/4nmH8Ruo8qTnNeSjZqJKOXWJ+/i9ftc7HxCGup0W2J/vsr64f1jZwObNz6n4/i7UdFNN eepTFF5kuDkJc12KYI927EsBzYxv0oAaKKj7n9hqdRjENbw/9nZfNcuPg== X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 25.06.22 at 12:40, Ilpo J=C3=A4rvinen wrote: >> + >> int uart_rs485_config(struct uart_port *port) >> { >> struct serial_rs485 *rs485 =3D &port->rs485; >> int ret; >> >> uart_sanitize_serial_rs485(port, rs485); >> + uart_set_rs485_termination(port, rs485); >> >> ret =3D port->rs485_config(port, rs485); >> if (ret) >> @@ -1400,6 +1411,7 @@ static int uart_set_rs485_config(struct uart_port= *port, >> if (ret) >> return ret; >> uart_sanitize_serial_rs485(port, &rs485); >> + uart_set_rs485_termination(port, &rs485); >> >> spin_lock_irqsave(&port->lock, flags); >> ret =3D port->rs485_config(port, &rs485); > > When port->rs485_config(port, &rs485) returns non-zero, the input got > partially applied? > > The thing is we dont know what the state of the termination GPIO (asserted= or deasserted) was before we set it and port->rs485_config() failed, so we cannot restore= it. We could read the GPIO before we change it but AFAIK this is unsafe since = it is an output pin. Maybe add a boolean variable "rs485_termination_gpio_asserted" to uar= t_port to track the current state? Regards, Lino