From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25532C433F5 for ; Tue, 22 Feb 2022 06:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:To:Subject:MIME-Version: Date:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pJ9TPjMBjj6ER8n9h2PttGFOieJg7bEwHELvIBhsPg8=; b=rY+6LGoqHCZ6YH9lc6u+QeGtnV Y9SGZe3DmsjOUTCAV/TDPfrpWx7UUd5ULfW3qjwoWoqdQjTAheWeDWPauvyye0DMfaR1XNa2To0p+ 8YbXbc+Wz/SMf6O0cfmvJjop6RJ6efUSx6GUrPtMeKJI911vnoINKvYqUXtvHf6oW1OkEsKzq71Q4 EnngYN4vF0Ut503uE5RpfNuGFnCywUPY5W9pW4dpS3u63SZJIJePAAYu+AgY85b/tO7CfPmJMxNk4 s4D5IZk0XZ8rVEzelCSXG2d1fn5Qe+KUY3f85f4Q0srpwgLCi/7+q2XXSd320Ds1RGOoqB7EZsR/t NPXghgxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMP1Y-008CMT-TE; Tue, 22 Feb 2022 06:51:49 +0000 Received: from mail-ed1-f51.google.com ([209.85.208.51]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMP1V-008CLz-PG for linux-arm-kernel@lists.infradead.org; Tue, 22 Feb 2022 06:51:47 +0000 Received: by mail-ed1-f51.google.com with SMTP id x5so34377548edd.11 for ; Mon, 21 Feb 2022 22:51:44 -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=FnFeJ6sNtAz40nc5aLZsVwXvsXSlnWLJoaoK80Y76+ol2XdBVWPUuJYFJ6/N5g2Qn2 2O96su+BcgYUkIKdUvcHgNtiGKR3P4T2vQQVqVBCZmksb+pMbgp+ZpqLCQolEpOUiWBV KynmaEcC5MUrOS4B8fkZ7XUYenNgKOgObVoQ4PP7Y8l9z/NSwxXxl0ldOq96MR+AypEA sYuvLAzW7CSg4EcNzGJoh4ortiugvSmR7HG1wcUFiGJwEjZLEs1UwODijCM2ZVjzr2LN WlMl4LekhkY7dvXeFTbX6r//zU+3DOQbiPyQV1AGlTBTqRqzOUCfReKHcD8MOKIZ8YJy adKw== X-Gm-Message-State: AOAM533c9H9HF712j7HopKQxBIKHNd33MbpG7qP1ucHEfgUSUQHAgh6x c4un98T6xQ9tu5vJPSjJOVc= X-Google-Smtp-Source: ABdhPJybXoH/4IC5sxgRdrpiS40oI8K5YpOtI4ArFM9KXKTCbppArM6MONHlNQCHPNBdKQfXpU+8Ng== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220221_225145_863586_B8EC148A X-CRM114-Status: GOOD ( 21.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, alexandre.belloni@bootlin.com, mcoquelin.stm32@gmail.com, richard.genoud@gmail.com, festevam@gmail.com, s.hauer@pengutronix.de, linux@armlinux.org.uk, alexandre.torgue@foss.st.com, ludovic.desroches@microchip.com, lukas@wunner.de, linux-imx@nxp.com, kernel@pengutronix.de, linux-serial@vger.kernel.org, shawnguo@kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org, p.rosenberger@kunbus.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel