Commit 81600e92 authored by Jiri Slaby (SUSE)'s avatar Jiri Slaby (SUSE) Committed by Greg Kroah-Hartman
Browse files

mxser: use tty_port_tty guard() in mxser_port_isr()



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: default avatar"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250814072456.182853-7-jirislaby@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 88d65e22
Loading
Loading
Loading
Loading
+29 −33
Original line number Diff line number Diff line
@@ -1600,25 +1600,16 @@ 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);

@@ -1644,10 +1635,15 @@ static bool mxser_port_isr(struct mxser_port *port)
				mxser_transmit_chars(tty, port);
		}

put_tty:
	tty_kref_put(tty);
		return false;
	}

	return error;
	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 true;
}

/*