From: Lino Sanfilippo <LinoSanfilippo@gmx.de>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
vz@mleia.com, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org,
linux-serial <linux-serial@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Lukas Wunner <lukas@wunner.de>,
p.rosenberger@kunbus.com,
Lino Sanfilippo <l.sanfilippo@kunbus.com>
Subject: Re: [PATCH v2 1/9] serial: core: only get RS485 termination GPIO if supported
Date: Mon, 4 Jul 2022 17:07:03 +0200 [thread overview]
Message-ID: <f318294d-2641-5a38-6d9c-ec96f3ec2b5f@gmx.de> (raw)
In-Reply-To: <9bc128a9-7ce3-d1e-dad6-ca91a5564ea8@linux.intel.com>
On 04.07.22 11:55, Ilpo Järvinen wrote:
> On Sun, 3 Jul 2022, Lino Sanfilippo wrote:
>
>> From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
>>
>> In uart_get_rs485_mode() only try to get a termination GPIO if RS485 bus
>> termination is supported by the driver. This prevents from allocating
>> and holding a GPIO descriptor for the drivers lifetimg that will never be
>> used.
>>
>> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
>> ---
>>
>> NOTE:
>> This patch follows the design decision that "rs485_supported" is
>> set by the driver at initialization and cannot be modified
>> afterwards. However the better approach would be to let the serial
>> core modify the termination GPIO support setting based on the
>> existence of a termination GPIO. If "rs485_supported" is not a
>> read-only value any more in future the logic implemented in this
>> patch should be adjusted accordingly.
>>
>> drivers/tty/serial/serial_core.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
>> index 85ef7ef00b82..3768663dfa4d 100644
>> --- a/drivers/tty/serial/serial_core.c
>> +++ b/drivers/tty/serial/serial_core.c
>> @@ -3404,6 +3404,16 @@ int uart_get_rs485_mode(struct uart_port *port)
>> */
>> port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term",
>> GPIOD_OUT_LOW);
>> +
>> + if (port->rs485_term_gpio &&
>> + !(port->rs485_supported->flags & SER_RS485_TERMINATE_BUS)) {
>> + dev_warn(port->dev,
>> + "%s (%d): RS485 termination gpio not supported by driver\n",
>> + port->name, port->line);
>> + devm_gpiod_put(dev, port->rs485_term_gpio);
>> + port->rs485_term_gpio = NULL;
>> + }
>> +
>> if (IS_ERR(port->rs485_term_gpio)) {
>> ret = PTR_ERR(port->rs485_term_gpio);
>> port->rs485_term_gpio = NULL;
>
> I sent a series to embed supported_rs485 to uart_port and manage
> SER_RS485_TERMINATE_BUS properly so I think this won't be necessary
> with that?
>
>
This is why I wrote the "NOTE" above. But yes, this patch is not needed
any more. I will drop it in the next version.
Regards,
Lino
next prev parent reply other threads:[~2022-07-04 15:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-03 17:00 [PATCH v2 0/9] Fixes and cleanup for RS485 Lino Sanfilippo
2022-07-03 17:00 ` [PATCH v2 1/9] serial: core: only get RS485 termination GPIO if supported Lino Sanfilippo
2022-07-03 18:27 ` Andy Shevchenko
2022-07-04 9:01 ` Lino Sanfilippo
2022-07-04 9:55 ` Ilpo Järvinen
2022-07-04 15:07 ` Lino Sanfilippo [this message]
2022-07-03 17:00 ` [PATCH v2 2/9] serial: core, 8250: set RS485 termination gpio in serial core Lino Sanfilippo
2022-07-03 18:31 ` Andy Shevchenko
2022-07-04 9:25 ` Lino Sanfilippo
2022-07-04 9:51 ` Ilpo Järvinen
2022-07-04 15:13 ` Lino Sanfilippo
2022-07-03 17:00 ` [PATCH v2 3/9] serial: core: move sanitizing of RS485 delays into own function Lino Sanfilippo
2022-07-03 17:00 ` [PATCH v2 4/9] serial: core: sanitize RS485 delays read from device tree Lino Sanfilippo
2022-07-03 18:34 ` Andy Shevchenko
2022-07-04 9:08 ` Lino Sanfilippo
2022-07-03 17:00 ` [PATCH v2 5/9] dt_bindings: rs485: Correct delay values Lino Sanfilippo
2022-07-03 18:36 ` Andy Shevchenko
2022-07-05 20:38 ` Rob Herring
2022-07-03 17:00 ` [PATCH v2 6/9] serial: 8250_dwlib: remove redundant sanity check for RS485 flags Lino Sanfilippo
2022-07-03 17:00 ` [PATCH v2 7/9] serial: ar933x: Fix check for RS485 support Lino Sanfilippo
2022-07-03 18:39 ` Andy Shevchenko
2022-07-04 9:21 ` Lino Sanfilippo
2022-07-04 9:53 ` Ilpo Järvinen
2022-07-03 17:00 ` [PATCH v2 8/9] serial: ar933x: Remove redundant assignment in rs485_config Lino Sanfilippo
2022-07-03 17:00 ` [PATCH v2 9/9] serial: 8250: lpc18xx: Remove redundant sanity check for RS485 flags Lino Sanfilippo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f318294d-2641-5a38-6d9c-ec96f3ec2b5f@gmx.de \
--to=linosanfilippo@gmx.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=l.sanfilippo@kunbus.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=p.rosenberger@kunbus.com \
--cc=robh+dt@kernel.org \
--cc=vz@mleia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).