From d6a0791098bedea41e813db646d21c9ba30004ec Mon Sep 17 00:00:00 2001 From: "Jiri Slaby (SUSE)" Date: Tue, 13 Oct 2026 08:48:51 +0200 Subject: serial: 8250: make port operations work on struct uart_8250_port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Cc: "Ilpo Järvinen" Assisted-by: LLM Link: https://patch.msgid.link/c59fa203f325e0fe7601ea0fbc0d222c8b37f9eb.1791873876.git.jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman --- include/linux/serial_8250.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index eeb868e93e15..d91c0477be9d 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -186,10 +186,10 @@ static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up) return container_of(up, struct uart_8250_port, port); } -int serial8250_register_8250_port(const struct uart_8250_port *); -void serial8250_unregister_port(int line); -void serial8250_suspend_port(int line); -void serial8250_resume_port(int line); +struct uart_8250_port *serial8250_register_8250_port(const struct uart_8250_port *); +void serial8250_unregister_port(struct uart_8250_port *); +void serial8250_suspend_port(struct uart_8250_port *); +void serial8250_resume_port(struct uart_8250_port *); int early_serial_setup(struct uart_port *port); int early_serial8250_setup(struct earlycon_device *device, const char *options); -- cgit v1.2.3