From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH 06/16] mxser: use tty_port_tty guard() in mxser_port_isr()
Date: Thu, 14 Aug 2025 09:24:46 +0200 [thread overview]
Message-ID: <20250814072456.182853-7-jirislaby@kernel.org> (raw)
In-Reply-To: <20250814072456.182853-1-jirislaby@kernel.org>
Use scoped_guard() and reorder the function. This is done separately
from the other changes, as it is slighly more intrusive: scoped_guard()
handles the have-tty case and returns. The non-tty case is done at the
end of the function.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/mxser.c | 62 +++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 33 deletions(-)
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 2fc13cc02cc5..b070ebf9f51a 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1600,54 +1600,50 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
static bool mxser_port_isr(struct mxser_port *port)
{
- struct tty_struct *tty;
u8 iir, status;
- bool error = false;
iir = inb(port->ioaddr + UART_IIR);
if (iir & UART_IIR_NO_INT)
return true;
iir &= MOXA_MUST_IIR_MASK;
- tty = tty_port_tty_get(&port->port);
- if (!tty) {
- status = inb(port->ioaddr + UART_LSR);
- outb(port->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
- port->ioaddr + UART_FCR);
- inb(port->ioaddr + UART_MSR);
- error = true;
- goto put_tty;
- }
+ scoped_guard(tty_port_tty, &port->port) {
+ struct tty_struct *tty = scoped_tty();
- status = inb(port->ioaddr + UART_LSR);
+ status = inb(port->ioaddr + UART_LSR);
- if (port->board->must_hwid) {
- if (iir == MOXA_MUST_IIR_GDA ||
- iir == MOXA_MUST_IIR_RDA ||
- iir == MOXA_MUST_IIR_RTO ||
- iir == MOXA_MUST_IIR_LSR)
- status = mxser_receive_chars(tty, port, status);
- } else {
- status &= port->read_status_mask;
- if (status & UART_LSR_DR)
- status = mxser_receive_chars(tty, port, status);
- }
+ if (port->board->must_hwid) {
+ if (iir == MOXA_MUST_IIR_GDA ||
+ iir == MOXA_MUST_IIR_RDA ||
+ iir == MOXA_MUST_IIR_RTO ||
+ iir == MOXA_MUST_IIR_LSR)
+ status = mxser_receive_chars(tty, port, status);
+ } else {
+ status &= port->read_status_mask;
+ if (status & UART_LSR_DR)
+ status = mxser_receive_chars(tty, port, status);
+ }
- mxser_check_modem_status(tty, port);
+ mxser_check_modem_status(tty, port);
- if (port->board->must_hwid) {
- if (iir == 0x02 && (status & UART_LSR_THRE))
- mxser_transmit_chars(tty, port);
- } else {
- if (status & UART_LSR_THRE)
- mxser_transmit_chars(tty, port);
+ if (port->board->must_hwid) {
+ if (iir == 0x02 && (status & UART_LSR_THRE))
+ mxser_transmit_chars(tty, port);
+ } else {
+ if (status & UART_LSR_THRE)
+ mxser_transmit_chars(tty, port);
+ }
+
+ return false;
}
-put_tty:
- tty_kref_put(tty);
+ status = inb(port->ioaddr + UART_LSR);
+ outb(port->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
+ port->ioaddr + UART_FCR);
+ inb(port->ioaddr + UART_MSR);
- return error;
+ return true;
}
/*
--
2.50.1
next prev parent reply other threads:[~2025-08-14 7:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 7:24 [PATCH 00/16] tty: use lock, rpm, and free guards Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 01/16] console: introduce console_lock guard()s Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 02/16] tty: introduce tty_port_tty guard() Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 03/16] serial: introduce uart_port_lock() guard()s Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 04/16] serial: 8250: introduce RPM guard()s Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 05/16] tty: tty_port: use guard()s Jiri Slaby (SUSE)
2025-08-14 7:24 ` Jiri Slaby (SUSE) [this message]
2025-08-14 7:24 ` [PATCH 07/16] mxser: " Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 08/16] serial: serial_core: " Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 09/16] serial: 8250: " Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 10/16] serial: 8250_core: use guard() in serial_unlink_irq_chain() Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 11/16] serial: 8250_omap: extract omap_8250_set_termios_atomic() Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 12/16] serial: 8250_omap: use guard()s Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 13/16] serial: 8250_rsa: " Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 14/16] tty/vt: use guard()s in con_font_set/get() and con_{set,get}_unimap() Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 15/16] tty/vt: use guard()s Jiri Slaby (SUSE)
2025-08-14 7:24 ` [PATCH 16/16] s390/char/con3270: use tty_port_tty guard() Jiri Slaby (SUSE)
2025-08-14 8:19 ` Heiko Carstens
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=20250814072456.182853-7-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--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®