Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4480944pxb; Mon, 21 Feb 2022 22:51:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcpxq95hZxmgrOQufR9LCIXnD05pdbbazz1opcPgBpW7tDmXt6NdTcQgHYwEfPSlnsb8+/ X-Received: by 2002:a17:902:bd43:b0:14b:4534:76d6 with SMTP id b3-20020a170902bd4300b0014b453476d6mr22192231plx.0.1645512711275; Mon, 21 Feb 2022 22:51:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645512711; cv=none; d=google.com; s=arc-20160816; b=sUYc43TtGf5WGR3BKGUK1asYGsQeW1Xvvw+o02GN6RNpRl5HG5beHZGa6nyoPG71l5 NFnQuWA9w4c1Eu8GLJiytVA/9KdTUV8qnSDSPBdHla9nBwDxnKtoLPmHWzTPfh26duHL U5Nuyroy6V8z8CNcO4okqay8zQssl55fDTwIlnfRvBuv8L07eS0eYOKypc/YAADxy65y XsiwvXUu1euplllcG2Q6yfRLLI4B3g58vhXQHel8AZnHe4d2TdJGe9eN2ftQuuPw6eeo +Q2DxJnTiOdWTN4+5pjN/V6Nu6C+EU2pwy60GIXAF/voJJGewe+v4FhJg0zzA1VtGwMA e4Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=bR8Q0QY9SX7TEWCLjuX9Gl0qDTq1gqx2gu8NIUCvNZY=; b=NXC4BKPYSqK2lVqjDQPRlhV12VsqsHXycdY1LLrOMOTsYNJ3iTfPQzYmGi7XOaPt4j WZZ5qIrf6PRYNFPVDlepa51Wj7zQG0BXFT0z+63jWZZvNR9ViHhjs9DC7KMnEbozVWWY lsPUQrM10G2InoF0He4W/MO02GvaUUBvJkVn2jZl1KKrvdy/p97M6528s/qm6rtdNdaH O2xxUd+kRItXSmJfxBcWGNtGVxilubY/o1kYTIFGoKWUY+/L+lPnJbNMXYLlYpvcVjuq dy4ujwLP0ewl2Y7QGZKMLkjUHq5Ox3gX8LRSjaosqmhpzqVFEBQEt7sru3dKbvN4zJBM Y8xw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b8si3192154plh.468.2022.02.21.22.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 22:51:51 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D65D9B1AAA; Mon, 21 Feb 2022 22:51:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbiBVGwJ (ORCPT + 99 others); Tue, 22 Feb 2022 01:52:09 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:37036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229867AbiBVGwI (ORCPT ); Tue, 22 Feb 2022 01:52:08 -0500 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C23827B10; Mon, 21 Feb 2022 22:51:43 -0800 (PST) Received: by mail-ed1-f53.google.com with SMTP id z22so34480327edd.1; Mon, 21 Feb 2022 22:51:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=bR8Q0QY9SX7TEWCLjuX9Gl0qDTq1gqx2gu8NIUCvNZY=; b=oqiGuTD3Dl1pZGMyO1xCU/U2c0AfNgqoHtki+0Fz2rXhoyIQddoecfd46DyhrVmXpM qh7ixkWDUN5AR9JntSvDcvf8UGuHrvmuyP3KxLzJ0XEwID2FwIXYqe/glRi6i83+D5kO i6466vUz6vZe6JSSS3v+PfghJiRA0JuXHUqWWGiYC6HEJfVA/s5fiLLX1PE5LThlcAPO +DH5xnn0CGX7FrfTN/9erfg74WxmINNoeX85mqJapwfxj+VZa2xfmXvTY0Gt32qkpoXK G0sTahFvs+dXlF5lnEOvvIzQyRHfm+YBg9HXE/NV06B2VAw8q7x+zgvfMpvb9kizjnNm IQ/Q== X-Gm-Message-State: AOAM533FDThjVnEvALDP83vr2FPhEqJ3WN31G6ngxAA5XR9GqMbxq/3T 1UstFFa79342DwPqJPmY0+Y= X-Received: by 2002:a05:6402:1e8b:b0:3da:58e6:9a09 with SMTP id f11-20020a0564021e8b00b003da58e69a09mr25358130edf.155.1645512701870; Mon, 21 Feb 2022 22:51:41 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id x6sm9348611edv.109.2022.02.21.22.51.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Feb 2022 22:51:41 -0800 (PST) Message-ID: Date: Tue, 22 Feb 2022 07:51:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH v3 1/9] serial: core: move RS485 configuration tasks from drivers into core Content-Language: en-US To: Lino Sanfilippo , gregkh@linuxfoundation.org, u.kleine-koenig@pengutronix.de Cc: linux@armlinux.org.uk, richard.genoud@gmail.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, lukas@wunner.de, p.rosenberger@kunbus.com References: <20220222011433.8761-1-LinoSanfilippo@gmx.de> <20220222011433.8761-2-LinoSanfilippo@gmx.de> From: Jiri Slaby In-Reply-To: <20220222011433.8761-2-LinoSanfilippo@gmx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 22. 02. 22, 2:14, Lino Sanfilippo wrote: > Several drivers that support setting the RS485 configuration via userspace > implement one or more of the following tasks: > > - in case of an invalid RTS configuration (both RTS after send and RTS on > send set or both unset) fall back to enable RTS on send and disable RTS > after send > > - nullify the padding field of the returned serial_rs485 struct > > - copy the configuration into the uart port struct > > - limit RTS delays to 100 ms > > Move these tasks into the serial core to make them generic and to provide > a consistent behaviour among all drivers. > > Signed-off-by: Lino Sanfilippo > --- > drivers/tty/serial/serial_core.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index 846192a7b4bf..2b3afe038c1c 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -42,6 +42,11 @@ static struct lock_class_key port_lock_key; > > #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) > > +/* > + * Max time with active RTS before/after data is sent. > + */ > +#define RS485_MAX_RTS_DELAY 100 /* msecs */ > + > static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, > struct ktermios *old_termios); > static void uart_wait_until_sent(struct tty_struct *tty, int timeout); > @@ -1282,8 +1287,32 @@ static int uart_set_rs485_config(struct uart_port *port, > if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) > return -EFAULT; > > + /* pick sane settings if the user hasn't */ > + if (!(rs485.flags & SER_RS485_RTS_ON_SEND) == > + !(rs485.flags & SER_RS485_RTS_AFTER_SEND)) { > + pr_warn("invalid RTS setting, using RTS_ON_SEND instead\n"); Can't we have a device prefix here, so that everyone knows what device is affected? Without that, it's not that useful. At least port->name & port->line could be printed. The uart core uses dev_* prints, but prints also line as uport->dev can be NULL sometimes. Hm, we could introduce uart_print family (to print something like what is in uart_report_port). thanks, -- js suse labs