Commit 5f289514 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

n_hdlc: invert conditions in n_hdlc_tty_close and n_hdlc_tty_poll



This makes the functions return immediatelly on invalid state. And we
can push the indent of the later code one level left.

Pass "-w" to "git show" to see we are changing only the conditions (and
whitespace).

Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200219084118.26491-8-jslaby@suse.cz


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 30fafd92
Loading
Loading
Loading
Loading
+38 −34
Original line number Diff line number Diff line
@@ -258,7 +258,9 @@ static void n_hdlc_tty_close(struct tty_struct *tty)
{
	struct n_hdlc *n_hdlc = tty2n_hdlc (tty);

	if (n_hdlc != NULL) {
	if (!n_hdlc)
		return;

	if (n_hdlc->magic != HDLC_MAGIC) {
		printk(KERN_WARNING "n_hdlc: trying to close unopened tty!\n");
		return;
@@ -276,7 +278,6 @@ static void n_hdlc_tty_close(struct tty_struct *tty)
	} else {
		n_hdlc_release (n_hdlc);
	}
	}
}	/* end of n_hdlc_tty_close() */

/**
@@ -737,10 +738,13 @@ static __poll_t n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
	struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
	__poll_t mask = 0;

	if (n_hdlc && n_hdlc->magic == HDLC_MAGIC && tty == n_hdlc->tty) {
		/* queue current process into any wait queue that */
		/* may awaken in the future (read and write) */
	if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || tty != n_hdlc->tty)
		return 0;

	/*
	 * queue the current process into any wait queue that may awaken in the
	 * future (read and write)
	 */
	poll_wait(filp, &tty->read_wait, wait);
	poll_wait(filp, &tty->write_wait, wait);

@@ -754,7 +758,7 @@ static __poll_t n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
	if (!tty_is_writelocked(tty) &&
			!list_empty(&n_hdlc->tx_free_buf_list.list))
		mask |= EPOLLOUT | EPOLLWRNORM;	/* writable */
	}

	return mask;
}	/* end of n_hdlc_tty_poll() */