Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9586868rwp; Thu, 20 Jul 2023 07:06:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlFuB6P/UGNyqCmHAo/PVfcv2W21KMoeDZQI68zW3ZjhKgbi2u6qc9VIubO3eIK3f55FiT3p X-Received: by 2002:a17:90b:1644:b0:262:f449:4497 with SMTP id il4-20020a17090b164400b00262f4494497mr5182535pjb.2.1689861990487; Thu, 20 Jul 2023 07:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689861990; cv=none; d=google.com; s=arc-20160816; b=C6gV9FMUtwFs1Xd4VdLxxQ+6tSk4EHNvCC+docP81Ek9C8fqVN/F8P+4EV0TwMivYs z2PihH7mlVqW2hL4WCw8/Za0hoH6cBURoko1VlfCKo/uQ+eWxflzb9f04vqGxSstg40B CDR6AyuJSGuIu9aCOoPwDPDlN+zgdVDMX59qK2YEqQqUTrAo/38vQMZenZuPHYVtu2Ze 7jlsBff0q1Eu8rDw3brmBTcBFQRAr+KR+Rh328ZjB0PNWEfrb+AkpooWXn8tl7qqggoZ FM5+0sFNAmwKewObXiq3OqiprPUyBfzS22KClxFp36GGd350MxgI7hV9yc4LJvyqjqwL 2XIA== 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=HaqKCi7sSQh/1JrlK9qdKLM+NIctVIYsKjkb5kTjbnI=; fh=Gjjx0WBt6GlsVECr6l5IdZoubnahyYC4rhBY7lBbLsk=; b=YBJwMcm8H4lRknQSvCMNw1DC68dCwbw1e5sMAHd/KrLlQqgVHD6pLYAHC0xqvsfS4y lodk+4NmwEO68hOot5He9Z3Lv3r822goA3sq1M22cmcOX7DebeiRLebmDLXlB03Cx5/f DlOHSbl57IozxMAeyhLsFyjnLzrOaNDMt7kiRWmDxT9Gy0f2TUDI1IIjkQ7E9NoAGqUd Ps4UwBdCwRj5oYp2cRnyAaJLGFv9hahOPNpjfKQqalhVcnilJZr/y2prZd4z22Kn2rwi CEY2kf2jp6dczEOlsutufzTgyf5CAoKdhGtusbElReMFRBvlapeeKl84fT2eEM1IItdg /v2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o6YH0LUf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk1-20020a17090b4a0100b0024e47fae466si1215376pjb.180.2023.07.20.07.06.14; Thu, 20 Jul 2023 07:06:30 -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=@kernel.org header.s=k20201202 header.b=o6YH0LUf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231480AbjGTNwO (ORCPT + 99 others); Thu, 20 Jul 2023 09:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231405AbjGTNwN (ORCPT ); Thu, 20 Jul 2023 09:52:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9EE2122; Thu, 20 Jul 2023 06:52:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8317F61ADE; Thu, 20 Jul 2023 13:52:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5AA9C433C7; Thu, 20 Jul 2023 13:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689861128; bh=7qMBM2O1eJyO65YYQrFbKbYLInUaocfLwQBu0lo73lM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o6YH0LUfb24M65v9ROoNvDh8Qv9ongsj8EZseujrAh9lDOgvB30wCbr2YrQeb9BJg kn2VrBEcezhPPaylGcSJPlvdML6oyab9cxkBiaLZLSceFVEYYqjbqOkQptMjGan/zG V/tuQxem6P07BjaGDC5FPbrbcsoSsGcKzGlWoUV4Xj8+esVugPL4c3NMHDZV6auttH juVxunPlaDKV9YjJ0oHZxD9LfYJeJAR6wYvMTmsVFAhjtF6AMIKvtmh6i7H1qSBTuy 4up25ZwO0yfWB2efP0qDYlUZzh2cPptHOu4rqJQAT6Q3hWVedXzuPymbi3ae/hjwTh w9uqRSbCZ6clg== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qMU4m-0007v3-1f; Thu, 20 Jul 2023 15:52:17 +0200 Date: Thu, 20 Jul 2023 15:52:16 +0200 From: Johan Hovold To: Jarkko Sonninen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5] USB: serial: xr: Add TIOCGRS485 and TIOCSRS485 ioctls Message-ID: References: <20230708145651.1860565-1-kasper@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230708145651.1860565-1-kasper@iki.fi> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 On Sat, Jul 08, 2023 at 05:56:50PM +0300, Jarkko Sonninen wrote: > Exar devices like XR21B1411 can control an RS485 transceiver by > automatically asserting the RTS#/RS485 pin before sending data > and deasserting it when the last stop bit has been transmitted. > The polarity of the RST#/RS485 signal is configurable and the > hardware also supports half-duplex turn-around delay and > address matching mode. > > Add support for enabling and disabling RS-485 mode and > configuring the RST#/RS485 signal polarity using the TIOCGRS485 > and TIOCSRS485 ioctls. Support for half-duplex turn-around delay > and address matching mode are left unimplemented for now. > > User enables RS-485 mode by setting SER_RS485_ENABLED flag in > struct serial_rs485 flags. User should also set either > SER_RS485_RTS_ON_SEND or SER_RS485_RTS_AFTER_SEND to select the > behaviour of the RTS#/RS485 pin. Setting SER_RS485_RTS_AFTER_SEND > will drive RTS#/RS485 high during transmission. As this is the > typical application described by Exar, it is selected when > user sets neither or both flags. > > Signed-off-by: Jarkko Sonninen > --- > Changes in v3: > - In this version only rs485.flags are stored to state. > - There is no locking as only one bit of the flags is used. > - ioctl returns -ENOIOCTLCMD as the actual error handling is in tty code. > Changes in v4: > - Store struct rs485 to data > - Add mutex to protect data->rs485. > - Implement SER_RS485_RTS_ON_SEND or SER_RS485_RTS_AFTER_SEND flags > - SER_RS485_RTS_ON_SEND is the default like in serial_core.c > Change in v5: > - Use tty->termios_rwsem semaphore instead of own mutex > - Set SER_RS485_RTS_AFTER_SEND as the default > - Fix XR_GPIO_MODE_RS485_TX_H setting with SER_RS485_RTS_ON_SEND > - Add missing __user directives I've applied this one now but with the small change I just mentioned that makes SER_RS485_RTS_ON_SEND determine SER_RS485_RTS_AFTER_SEND. Since this sets SER_RS485_RTS_AFTER_SEND when neither flag is set, I believe you get the behaviour you preferred (even if SER_RS485_RTS_AFTER_SEND is now cleared when both flags are set). Let me know otherwise and we'll discuss it. Here's the result: https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial.git/commit/?h=usb-next&id=974e2f6a0554685493cc44406bc7d8ba0a3b0e33 Thanks for sticking with. I think the end result looks really good. Johan