Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4481431pxb; Mon, 21 Feb 2022 22:52:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYirBr8Wui84XsjGQHCX+1yEjjiYqc7sF+nt7FLQKzEKhTAlCSDYykcRPY2hYFfQNs/+JJ X-Received: by 2002:a63:8249:0:b0:35d:9b89:1188 with SMTP id w70-20020a638249000000b0035d9b891188mr18836163pgd.614.1645512767688; Mon, 21 Feb 2022 22:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645512767; cv=none; d=google.com; s=arc-20160816; b=juwkdWIMvoVSS+Tlw4yLQiZm57NQEBWGXDJFDi4athUE3LjwqAR+BcXdVbkJGRDJ+l wsZE9RS6Ob16stSPwif9MiVUZRgZau5Dbqb/p5x5ExDVPiL09thO98VzJ4HuowKnWGfx kQv4i5ler+5V9XsBJ9jz9WzqSZjp42Bt0znSQY4KWEfAYfGaTuAW90uznlRD3xVRJg1w cO/Y48WlAmkKB0+HOIIiKpscBA4nCNalAMlZSFTgHOtwtxa2xBxv3w0i6uJ+Beze/cMD zVaQaYHU0t+ckWJyoebolKL7qoo8IoAfo8gLatZzq8BEcdBPmMB+XATUJmJ0dMhbP7Ig sJtg== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=3KiCNnYtMhTLO7dCmwg9IIrAqJrsqdSjvq0y9ThzW3A=; b=NZjQn5+DHyw+dmuwgw3CoZPv2QgTb8iJV4L48Z850e5vRkDUYvvY0SruX63prQYMOv FFxqXPldoioYkVFbhVP0O0W6+ajTdxvTXZGjp3BLPp92hbrMB3iDIYoWZl/SL+3aeisi fhlFqNQTbnXnUPdYFef8lnJI5OWViCb25Uf6wMxaKPBNYos72zlqqMtVCIVrekWBvbbN 9JZ0p+p6eSD+3UfvhKf1fePplaPa0Yo4xXkuKUg1I+AWeA9EwaewuQLH+axBWwVt+PGo UcOwWbdPca0ma/9ptvfWiD1wRrHy4v+OKEFt9c72nwAhJ5FA4dRmwW/SvtHAYhuUye1d yOqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bc14si4987561pgb.543.2022.02.21.22.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 22:52:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 2BEFC1110A3; Mon, 21 Feb 2022 22:52:46 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230302AbiBVGxG (ORCPT + 99 others); Tue, 22 Feb 2022 01:53:06 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:37850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230284AbiBVGxE (ORCPT ); Tue, 22 Feb 2022 01:53:04 -0500 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FCB9107093; Mon, 21 Feb 2022 22:52:40 -0800 (PST) Received: by mail-ej1-f42.google.com with SMTP id gb39so39867699ejc.1; Mon, 21 Feb 2022 22:52:40 -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:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=3KiCNnYtMhTLO7dCmwg9IIrAqJrsqdSjvq0y9ThzW3A=; b=q/n9mh0+hiON9h0IldQnRM29vWge+oirNXveVqjpB9YEMryS2iXov7lnRLLe28tigX GzH90/GBazpO1Mhb1sO2C4FhAJD/VhbvdD05LYkp7DhRueSgnrOXmxubILuSyX1XcFFk obwxsPTY07j+Qn9vAqSGe6rl5rbvCI5QFxu3deiBrvPB6a5GYXcgbaxG1QhQDSUjRe++ gmxFYrUVX62sJnPxxm71+C0D9FtOOvpfHZSM7sqpBZQDD6tAa4rUuJolfV1JdYEcmm5M KY/hIMw17V4y3CoWAYy69jeQ7HvXd4eNJLuuVxh0Y2NnC/BqvOXsF/PQI3hSvtU53pJU zCwg== X-Gm-Message-State: AOAM530RRnCU+bHqRuJ0QXX7N2tKZqSAu3n1GvgHrjRgF7YEmqfqLMP8 hnZIP6h5SO5xmeLtd/z+QnEc51Z6Y2Fw5Q== X-Received: by 2002:a17:906:8493:b0:6ce:710:3739 with SMTP id m19-20020a170906849300b006ce07103739mr18139821ejx.409.1645512758577; Mon, 21 Feb 2022 22:52:38 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id e27sm6089342ejm.18.2022.02.21.22.52.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Feb 2022 22:52:38 -0800 (PST) Message-ID: <8c65bc42-438e-bf3e-fb76-2a4cbc7296c0@kernel.org> Date: Tue, 22 Feb 2022 07:52:36 +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 From: Jiri Slaby 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> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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, 7:51, Jiri Slaby wrote: > 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. And this comes from userspace, so should be ratelimited. -- js suse labs