From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: Hugo Villeneuve <hvilleneuve@dimonoff.com>,
John Ogness <john.ogness@linutronix.de>,
Atsushi Nemoto <anemo@mba.ocn.ne.jp>, Alan Cox <alan@redhat.com>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: [PATCH v1 1/6] serial: txx9: Drop noop probe function and dangerous remove callback
Date: Fri, 31 Jul 2026 11:39:04 +0200 [thread overview]
Message-ID: <25e2b1d699652b095ee69be030850c8818bf78d8.1785489518.git.ukleinek@kernel.org> (raw)
In-Reply-To: <cover.1785489518.git.ukleinek@kernel.org>
The only platform device that can be bound to the driver is allocated by
the driver itself. That device doesn't have platdata, so the probe
function only consists of a loop that is never run and thus can be
dropped without loss of functionality.
The remove function then should better not undo things that were not
done in the first place. That happens because serial_txx9_init() calls
serial_txx9_register_ports() with the created platform device and so
up->dev == &dev->dev evaluates to true and uart_remove_one_port() is
called twice for each port.
So let serial_txx9_exit() undo exactly what serial_txx9_init() does and
remove the useless respectively wrong functions.
Fixes: 0970769aceb9 ("[SERIAL] serial_txx9 driver update")
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
---
drivers/tty/serial/serial_txx9.c | 55 ++------------------------------
1 file changed, 3 insertions(+), 52 deletions(-)
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index 4ae9a45c8e3a..5ed20129b44b 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -1009,7 +1009,8 @@ static void serial_txx9_unregister_port(int line)
struct uart_port *uart = &serial_txx9_ports[line];
mutex_lock(&serial_txx9_mutex);
- uart_remove_one_port(&serial_txx9_reg, uart);
+ if (up->iobase || up->mapbase)
+ uart_remove_one_port(&serial_txx9_reg, uart);
uart->flags = 0;
uart->type = PORT_UNKNOWN;
uart->iobase = 0;
@@ -1019,52 +1020,6 @@ static void serial_txx9_unregister_port(int line)
mutex_unlock(&serial_txx9_mutex);
}
-/*
- * Register a set of serial devices attached to a platform device.
- */
-static int serial_txx9_probe(struct platform_device *dev)
-{
- struct uart_port *p = dev_get_platdata(&dev->dev);
- struct uart_port port;
- int ret, i;
-
- memset(&port, 0, sizeof(struct uart_port));
- for (i = 0; p && p->uartclk != 0; p++, i++) {
- port.iobase = p->iobase;
- port.membase = p->membase;
- port.irq = p->irq;
- port.uartclk = p->uartclk;
- port.iotype = p->iotype;
- port.flags = p->flags;
- port.mapbase = p->mapbase;
- port.dev = &dev->dev;
- port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_TXX9_CONSOLE);
- ret = serial_txx9_register_port(&port);
- if (ret < 0) {
- dev_err(&dev->dev, "unable to register port at index %d "
- "(IO%lx MEM%llx IRQ%d): %d\n", i,
- p->iobase, (unsigned long long)p->mapbase,
- p->irq, ret);
- }
- }
- return 0;
-}
-
-/*
- * Remove serial ports registered against a platform device.
- */
-static void serial_txx9_remove(struct platform_device *dev)
-{
- int i;
-
- for (i = 0; i < UART_NR; i++) {
- struct uart_port *up = &serial_txx9_ports[i];
-
- if (up->dev == &dev->dev)
- serial_txx9_unregister_port(i);
- }
-}
-
#ifdef CONFIG_PM
static int serial_txx9_suspend(struct platform_device *dev, pm_message_t state)
{
@@ -1096,8 +1051,6 @@ static int serial_txx9_resume(struct platform_device *dev)
#endif
static struct platform_driver serial_txx9_plat_driver = {
- .probe = serial_txx9_probe,
- .remove = serial_txx9_remove,
#ifdef CONFIG_PM
.suspend = serial_txx9_suspend,
.resume = serial_txx9_resume,
@@ -1251,9 +1204,7 @@ static void __exit serial_txx9_exit(void)
platform_driver_unregister(&serial_txx9_plat_driver);
platform_device_unregister(serial_txx9_plat_devs);
for (i = 0; i < UART_NR; i++) {
- struct uart_port *up = &serial_txx9_ports[i];
- if (up->iobase || up->mapbase)
- uart_remove_one_port(&serial_txx9_reg, up);
+ serial_txx9_unregister_port(i);
}
uart_unregister_driver(&serial_txx9_reg);
--
2.55.0.11.g153666a7d9bb
next prev parent reply other threads:[~2026-07-31 9:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 9:39 [PATCH v1 0/6] serial: Some yak shaving Uwe Kleine-König
2026-07-31 9:39 ` Uwe Kleine-König [this message]
2026-07-31 9:39 ` [PATCH v1 2/6] serial: txx9: Drop usage of uart_match_port() Uwe Kleine-König
2026-08-03 14:46 ` Greg Kroah-Hartman
2026-08-03 18:57 ` Uwe Kleine-König
2026-08-03 17:27 ` Ilpo Järvinen
2026-08-03 18:59 ` Uwe Kleine-König
2026-07-31 9:39 ` [PATCH v1 3/6] serial: 8250: Make uart_match_port() a 8250 specific function Uwe Kleine-König
2026-08-03 17:23 ` Ilpo Järvinen
2026-08-03 19:22 ` Hugo Villeneuve
2026-07-31 9:39 ` [PATCH v1 4/6] serial: 8250: Fix corner case for port matching Uwe Kleine-König
2026-07-31 9:39 ` [PATCH v1 5/6] serial: 8250: hub6: Add cleanup code Uwe Kleine-König
2026-07-31 9:39 ` [PATCH v1 6/6] serial: 8250: pnp: Annotate init and exit functions for conditional discarding Uwe Kleine-König
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=25e2b1d699652b095ee69be030850c8818bf78d8.1785489518.git.ukleinek@kernel.org \
--to=ukleinek@kernel.org \
--cc=alan@redhat.com \
--cc=anemo@mba.ocn.ne.jp \
--cc=gregkh@linuxfoundation.org \
--cc=hvilleneuve@dimonoff.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@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®