From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>, Rob Herring <robh+dt@kernel.org>,
"Matwey V. Kornilov" <matwey@sai.msu.ru>,
Giulio Benetti <giulio.benetti@micronovasrl.com>,
Heiko Stuebner <heiko@sntech.de>,
Christoph Muellner <christoph.muellner@theobroma-systems.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
devicetree@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH 4/4] serial: 8250: Support rs485 bus termination GPIO
Date: Wed, 6 May 2020 13:06:17 +0300 [thread overview]
Message-ID: <20200506100617.GC185537@smile.fi.intel.com> (raw)
In-Reply-To: <20200506062943.qugqwhnkismnnkrb@wunner.de>
On Wed, May 06, 2020 at 08:29:43AM +0200, Lukas Wunner wrote:
> On Tue, May 05, 2020 at 07:10:35PM +0300, Andy Shevchenko wrote:
> > On Tue, May 05, 2020 at 04:42:04PM +0200, Lukas Wunner wrote:
...
> > > + devm_gpiod_put(dev, port->rs485_term_gpio);
> >
> > > + port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term",
> >
> > Using devm_*() in uart_get_rs485_mode() seems not right.
> > Why do you need this?
>
> uart_get_rs485_mode() is called from a driver's ->probe() hook and we
> do not have a corresponding function that is called from a ->remove()
> hook where we'd be able to relinquish rs485 resources we've acquired
> on probe.
>
> Of course I could add that but it would be more heavy-weight compared
> to simply using devm_*(). Do you disagree?
>
> devm_gpiod_put() isn't strictly necessary here. It is only necessary
> if one of the drivers would invoke uart_get_rs485_mode() multiple
> times, which none of them does AFAICS. It's just a safety measure.
> I can drop it if that is preferred.
I think putting and re-requesting here is also racy. Somebody can request the
very same GPIO in between (for example crazy user space tool).
Setting the same value many times won't hurt.
> > > + GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT);
> >
> > Parameter has a specific macro GPIOD_OUT_HIGH.
>
> Good point. It's also occurred to me now that reading the GPIO's
> value after changing its direction to output is nonsense. If anything
> it ought to be read *before* changing the direction to output.
It's not a complete nonsense, depends what you actually want to achieve here.
> That would make sense in case the board has a pullup or pulldown on
> the Termination Enable pin. In other cases the pin may just float
> and the value will be unpredictable. However if I do not read the
> pin, I'd have to choose either high or low as initial state. Hm.
> Let me check back with our hardware engineers today and see what they
> recommend.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2020-05-06 10:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 14:42 [PATCH 0/4] rs485 bus termination GPIO Lukas Wunner
2020-05-05 14:42 ` [PATCH 1/4] serial: 8250: Avoid error message on reprobe Lukas Wunner
2020-05-05 16:01 ` Andy Shevchenko
2020-05-06 6:06 ` Lukas Wunner
2020-05-06 10:01 ` Andy Shevchenko
2020-05-06 11:54 ` Lukas Wunner
2020-05-05 14:42 ` [PATCH 2/4] serial: Allow uart_get_rs485_mode() to return errno Lukas Wunner
2020-05-05 14:42 ` [PATCH 3/4] dt-bindings: serial: Add binding for rs485 bus termination GPIO Lukas Wunner
2020-05-05 14:42 ` [PATCH 4/4] serial: 8250: Support " Lukas Wunner
2020-05-05 16:10 ` Andy Shevchenko
2020-05-06 6:29 ` Lukas Wunner
2020-05-06 10:06 ` Andy Shevchenko [this message]
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=20200506100617.GC185537@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=christoph.muellner@theobroma-systems.com \
--cc=devicetree@vger.kernel.org \
--cc=giulio.benetti@micronovasrl.com \
--cc=gregkh@linuxfoundation.org \
--cc=heiko@sntech.de \
--cc=jan.kiszka@siemens.com \
--cc=jslaby@suse.com \
--cc=linux-serial@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=matwey@sai.msu.ru \
--cc=robh+dt@kernel.org \
/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).