From: Tapio Reijonen <tapio.reijonen@vaisala.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Markus Probst <markus.probst@posteo.de>
Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, "Lukas Wunner" <lukas@wunner.de>,
"Christoph Niedermaier" <cniedermaier@dh-electronics.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Lino Sanfilippo" <l.sanfilippo@kunbus.com>,
"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
"Tapio Reijonen" <tapio.reijonen@vaisala.com>,
stable@vger.kernel.org
Subject: [PATCH 1/7] serial: max310x: Look up all channels before adding any port
Date: Wed, 11 Nov 2026 12:28:00 +0000 [thread overview]
Message-ID: <20261111-serial-transceiver-supply-v1-1-40bad0f912f2@vaisala.com> (raw)
In-Reply-To: <20261111-serial-transceiver-supply-v1-0-40bad0f912f2@vaisala.com>
The probe reads each channel's RS485 properties with
uart_get_rs485_mode() and adds the port in the same loop. The GPIO
lookups in uart_get_rs485_mode() can return -EPROBE_DEFER, and for
channel N > 0 that happens after channels 0..N-1 were added, with
their serial_base child devices bound. A probe must not defer after
creating child devices: the bound children re-trigger deferred probing
at once, so the probe runs in a loop for as long as the GPIO provider
is missing, see Documentation/driver-api/driver-model/driver.rst.
Read the properties of all channels first and add the ports in a
second loop. An error in the first loop goes to out_clk: no line is
assigned yet, so out_uart would test line 0 for every channel.
Fixes: bed094602ffb ("serial: max310x: honour rs485 properties from per-channel DT subnode")
Cc: stable@vger.kernel.org
Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
---
drivers/tty/serial/max310x.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index a0ed70185555eed745d905b36c8b8f162468dd6f..bdfdf4a9000bbd18509746bbfd8ed0ade8164598 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -2010,18 +2010,11 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
goto out_uart;
#endif
+ /* Look up every channel before registering any: lookups may defer */
for (i = 0; i < devtype->nr; i++) {
struct fwnode_handle *saved_fwnode = dev_fwnode(dev);
struct device_node *port_np = NULL;
struct device_node *child;
- unsigned int line;
-
- line = find_first_zero_bit(max310x_lines, MAX310X_UART_NRMAX);
- if (line == MAX310X_UART_NRMAX) {
- ret = -ERANGE;
- goto out_uart;
- }
- s->p[i].port.line = line;
/* Locate the matching "serial@i" DT subnode, if any. */
for_each_available_child_of_node(dev->of_node, child) {
@@ -2050,12 +2043,23 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
device_set_node(dev, saved_fwnode);
of_node_put(port_np);
if (ret)
- goto out_uart;
+ goto out_clk;
} else if (devtype->nr == 1) {
ret = uart_get_rs485_mode(&s->p[i].port);
if (ret)
- goto out_uart;
+ goto out_clk;
}
+ }
+
+ for (i = 0; i < devtype->nr; i++) {
+ unsigned int line;
+
+ line = find_first_zero_bit(max310x_lines, MAX310X_UART_NRMAX);
+ if (line == MAX310X_UART_NRMAX) {
+ ret = -ERANGE;
+ goto out_uart;
+ }
+ s->p[i].port.line = line;
/* Register port */
ret = uart_add_one_port(&max310x_uart, &s->p[i].port);
--
2.47.3
next prev parent reply other threads:[~2026-11-11 12:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 12:27 [PATCH 0/7] serial: core: Power the line transceiver with the port Tapio Reijonen
2026-11-11 12:28 ` Tapio Reijonen [this message]
2026-11-11 12:28 ` [PATCH 2/7] dt-bindings: serial: Add the line transceiver enable GPIO Tapio Reijonen
2026-11-23 8:03 ` Krzysztof Kozlowski
2026-11-23 8:08 ` Krzysztof Kozlowski
2026-11-11 12:28 ` [PATCH 3/7] dt-bindings: serial: sc16is7xx: Disallow transceiver GPIO on dual parts Tapio Reijonen
2026-11-23 8:00 ` Krzysztof Kozlowski
2026-11-11 12:28 ` [PATCH 4/7] serial: core: Power the line transceiver with the port Tapio Reijonen
2026-11-11 12:28 ` [PATCH 5/7] serial: max310x: Request the line transceiver per port Tapio Reijonen
2026-11-11 12:28 ` [PATCH 6/7] dt-bindings: serial: max310x: Add maxim,tristate-when-closed Tapio Reijonen
2026-11-23 8:05 ` Krzysztof Kozlowski
2026-11-11 12:28 ` [PATCH 7/7] serial: max310x: Three-state TX and RTS while the port is closed Tapio Reijonen
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=20261111-serial-transceiver-supply-v1-1-40bad0f912f2@vaisala.com \
--to=tapio.reijonen@vaisala.com \
--cc=cniedermaier@dh-electronics.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hvilleneuve@dimonoff.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=l.sanfilippo@kunbus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=markus.probst@posteo.de \
--cc=robh@kernel.org \
--cc=stable@vger.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
all inboxes | Powered by JetHome®