From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: gregkh@linuxfoundation.org, linux-serial@vger.kernel.org,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Vadim Fedorenko" <vadim.fedorenko@linux.dev>,
"Richard Cochran" <richardcochran@gmail.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Joel Stanley" <joel@jms.id.au>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Ryan Chen" <ryan_chen@aspeedtech.com>,
"Billy Tsai" <billy_tsai@aspeedtech.com>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Broadcom internal kernel review list"
<bcm-kernel-feedback-list@broadcom.com>,
"Ray Jui" <ray.jui@broadcom.com>,
"Scott Branden" <scott.branden@broadcom.com>,
"Al Cooper" <alcooperx@gmail.com>,
"Paul Cercueil" <paul@crapouillou.net>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Chaitanya Vadrevu" <chaitanya.vadrevu@emerson.com>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Helge Deller" <deller@gmx.de>,
"Kumaravel Thiagarajan" <kumaravel.thiagarajan@microchip.com>,
"Thierry Reding" <thierry.reding@kernel.org>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Kunihiko Hayashi" <hayashi.kunihiko@socionext.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Kees Cook" <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org,
linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-parisc@vger.kernel.org,
linux-tegra@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2 6/6] serial: 8250: make port operations work on struct uart_8250_port
Date: Tue, 13 Oct 2026 10:33:10 +0300 [thread overview]
Message-ID: <as3etnbZatn4sbfx@ashevche-desk.local> (raw)
In-Reply-To: <c59fa203f325e0fe7601ea0fbc0d222c8b37f9eb.1791873876.git.jirislaby@kernel.org>
On Tue, Oct 13, 2026 at 08:48:51AM +0200, Jiri Slaby (SUSE) wrote:
> serial8250_register_8250_port() returns a line number and the other
> port operations (serial8250_unregister_port(), serial8250_suspend_port(),
> serial8250_resume_port()) accept it. Many drivers then convert the line
> back to the port using serial8250_get_port() anyway.
>
> Switch the interface to struct uart_8250_port:
> * serial8250_register_8250_port() now returns the registered port, or
> an ERR_PTR() on failure.
> * serial8250_unregister_port(), serial8250_suspend_port() and
> serial8250_resume_port() accept the port.
>
> Convert all users accordingly. Drivers store the port pointer instead
> of the line number. Several drivers kept a private struct only to hold
> the line (airoha, dfl, em, fsl, ioc3); these are dropped and the port
> is stored as drvdata directly.
>
> This also fixes two latent issues:
> * For a CIR port, serial8250_register_8250_port() used to return 0.
> Callers stored this as the line, so a later unregister/suspend/resume
> operated on ttyS0. Now the CIR port itself is returned.
> * 8250_acorn checked ports[i] > 0 on removal, so a port registered as
> line 0 was never unregistered.
>
> There are no more users of serial8250_get_port() outside of the 8250
> core, so drop its EXPORT.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Why not having Ilpo's Cc in the below list?
> Assisted-by: LLM
> ---
> Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Andrew Lunn <andrew+netdev@lunn.ch>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@kernel.org>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Andrew Jeffery <andrew@codeconstruct.com.au>
> Cc: Ryan Chen <ryan_chen@aspeedtech.com>
> Cc: Billy Tsai <billy_tsai@aspeedtech.com>
> Cc: Florian Fainelli <florian.fainelli@broadcom.com>
> Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
> Cc: Ray Jui <ray.jui@broadcom.com>
> Cc: Scott Branden <scott.branden@broadcom.com>
> Cc: Al Cooper <alcooperx@gmail.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Paul Cercueil <paul@crapouillou.net>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Chaitanya Vadrevu <chaitanya.vadrevu@emerson.com>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
> Cc: Thierry Reding <thierry.reding@kernel.org>
> Cc: Jonathan Hunter <jonathanh@nvidia.com>
> Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Kees Cook <kees@kernel.org>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
> Cc: netdev@vger.kernel.org
> Cc: linux-serial@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-aspeed@lists.ozlabs.org
> Cc: linux-rpi-kernel@lists.infradead.org
> Cc: linux-mips@vger.kernel.org
> Cc: linux-mediatek@lists.infradead.org
> Cc: linux-parisc@vger.kernel.org
> Cc: linux-tegra@vger.kernel.org
> Cc: linux-hardening@vger.kernel.org
> [v2] include err.h (Ilpo)
> ---
...
> seq_printf(s, "%7s: /dev/ptp%d\n", "PTP", ptp_clock_index(bp->ptp));
> for (i = 0; i < __PORT_COUNT; i++) {
What about
struct uart_8250_port *uport = bp->port[i].uport;
here and use it accordingly in the below code?
> - if (bp->port[i].line != -1)
> + if (bp->port[i].uport)
> seq_printf(s, "%7s: /dev/ttyS%d\n", ptp_ocp_tty_port_name(i),
> - bp->port[i].line);
> + bp->port[i].uport->port.line);
> }
...
> for (i = 0; i < __PORT_COUNT; i++)
> - if (bp->port[i].line != -1)
> - serial8250_unregister_port(bp->port[i].line);
> + if (bp->port[i].uport)
> + serial8250_unregister_port(bp->port[i].uport);
Since it takes a pointer now, make it error pointer and NULL-aware
if (IS_ERR_OR_NULL(...))
return;
there. With that being done, all this redundant NULL-checks will gone.
...
> static void serial_card_remove(struct expansion_card *ec)
> ecard_set_drvdata(ec, NULL);
>
> for (i = 0; i < info->num_ports; i++)
> - if (info->ports[i] > 0)
> + if (!IS_ERR_OR_NULL(info->ports[i]))
> serial8250_unregister_port(info->ports[i]);
See my point?
...
> static int aspeed_vuart_probe(struct platform_device *pdev)
> if (of_property_read_bool(np, "auto-flow-control"))
> port.capabilities |= UART_CAP_AFE;
>
> - rc = serial8250_register_8250_port(&port);
> - if (rc < 0)
> + struct uart_8250_port *uport = serial8250_register_8250_port(&port);
> + if (IS_ERR(uport)) {
> + rc = PTR_ERR(uport);
> goto err_sysfs_remove;
> + }
You can get rid of these {} by using PTR_ERR_OR_ZERO(). Also do not define
variables in the middle of the code (it's only allowed for auto cleanup
variables and for-loop iterators).
...
I stopped here, I believe there are many similar cases which may be amended in
the same way as pointed out above.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-10-13 7:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1791873876.git.jirislaby@kernel.org>
2026-10-13 6:48 ` [PATCH v2 6/6] serial: 8250: make port operations work on struct uart_8250_port Jiri Slaby (SUSE)
2026-10-13 7:33 ` 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=as3etnbZatn4sbfx@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=alcooperx@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@codeconstruct.com.au \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=billy_tsai@aspeedtech.com \
--cc=chaitanya.vadrevu@emerson.com \
--cc=davem@davemloft.net \
--cc=deller@gmx.de \
--cc=edumazet@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=hayashi.kunihiko@socionext.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=joel@jms.id.au \
--cc=jonathanh@nvidia.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=kumaravel.thiagarajan@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mhiramat@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paul@crapouillou.net \
--cc=ray.jui@broadcom.com \
--cc=richardcochran@gmail.com \
--cc=ryan_chen@aspeedtech.com \
--cc=scott.branden@broadcom.com \
--cc=thierry.reding@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=vadim.fedorenko@linux.dev \
/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