summaryrefslogtreecommitdiffstats
path: root/sys/dev/uart
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2016-01-27 22:48:04 +0000
committermarius <marius@FreeBSD.org>2016-01-27 22:48:04 +0000
commit8a3d40f3e5425c839165d3e5d86dac78fc0b2fa9 (patch)
tree9f35e08c97350406026bf3cc3da682a658e8b035 /sys/dev/uart
parent9240aed7779eb28e8b36afbed9b59484fd2c6539 (diff)
downloadFreeBSD-src-8a3d40f3e5425c839165d3e5d86dac78fc0b2fa9.zip
FreeBSD-src-8a3d40f3e5425c839165d3e5d86dac78fc0b2fa9.tar.gz
MFC: r294362, r294414, r294753
- Fix tty_drain() and, thus, TIOCDRAIN of the current tty(4) incarnation to actually wait until the TX FIFOs of UARTs have be drained before returning. This is done by bringing the equivalent of the TS_BUSY flag found in the previous implementation back in an ABI-preserving way. Reported and tested by: Patrick Powell - Make the code consistent with itself style-wise and bring it closer to style(9). - Mark unused arguments as such. - Make the ttystates table const.
Diffstat (limited to 'sys/dev/uart')
-rw-r--r--sys/dev/uart/uart_tty.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/sys/dev/uart/uart_tty.c b/sys/dev/uart/uart_tty.c
index e676d50..c42fe7a 100644
--- a/sys/dev/uart/uart_tty.c
+++ b/sys/dev/uart/uart_tty.c
@@ -57,6 +57,16 @@ static cn_putc_t uart_cnputc;
static cn_grab_t uart_cngrab;
static cn_ungrab_t uart_cnungrab;
+static tsw_open_t uart_tty_open;
+static tsw_close_t uart_tty_close;
+static tsw_outwakeup_t uart_tty_outwakeup;
+static tsw_inwakeup_t uart_tty_inwakeup;
+static tsw_ioctl_t uart_tty_ioctl;
+static tsw_param_t uart_tty_param;
+static tsw_modem_t uart_tty_modem;
+static tsw_free_t uart_tty_free;
+static tsw_busy_t uart_tty_busy;
+
CONSOLE_DRIVER(uart);
static struct uart_devinfo uart_console;
@@ -157,7 +167,7 @@ uart_tty_close(struct tty *tp)
struct uart_softc *sc;
sc = tty_softc(tp);
- if (sc == NULL || sc->sc_leaving || !sc->sc_opened)
+ if (sc == NULL || sc->sc_leaving || !sc->sc_opened)
return;
if (sc->sc_hwiflow)
@@ -169,7 +179,6 @@ uart_tty_close(struct tty *tp)
wakeup(sc);
sc->sc_opened = 0;
- return;
}
static void
@@ -215,7 +224,8 @@ uart_tty_inwakeup(struct tty *tp)
}
static int
-uart_tty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
+uart_tty_ioctl(struct tty *tp, u_long cmd, caddr_t data,
+ struct thread *td __unused)
{
struct uart_softc *sc;
@@ -262,8 +272,8 @@ uart_tty_param(struct tty *tp, struct termios *t)
}
stopbits = (t->c_cflag & CSTOPB) ? 2 : 1;
if (t->c_cflag & PARENB)
- parity = (t->c_cflag & PARODD) ? UART_PARITY_ODD
- : UART_PARITY_EVEN;
+ parity = (t->c_cflag & PARODD) ? UART_PARITY_ODD :
+ UART_PARITY_EVEN;
else
parity = UART_PARITY_NONE;
if (UART_PARAM(sc, t->c_ospeed, databits, stopbits, parity) != 0)
@@ -291,7 +301,7 @@ uart_tty_modem(struct tty *tp, int biton, int bitoff)
sc = tty_softc(tp);
if (biton != 0 || bitoff != 0)
- UART_SETSIG(sc, SER_DELTA(bitoff|biton) | biton);
+ UART_SETSIG(sc, SER_DELTA(bitoff | biton) | biton);
return (sc->sc_hwsig);
}
@@ -350,7 +360,7 @@ uart_tty_intr(void *arg)
}
static void
-uart_tty_free(void *arg)
+uart_tty_free(void *arg __unused)
{
/*
@@ -361,6 +371,18 @@ uart_tty_free(void *arg)
*/
}
+static bool
+uart_tty_busy(struct tty *tp)
+{
+ struct uart_softc *sc;
+
+ sc = tty_softc(tp);
+ if (sc == NULL || sc->sc_leaving)
+ return (FALSE);
+
+ return (sc->sc_txbusy);
+}
+
static struct ttydevsw uart_tty_class = {
.tsw_flags = TF_INITLOCK|TF_CALLOUT,
.tsw_open = uart_tty_open,
@@ -371,6 +393,7 @@ static struct ttydevsw uart_tty_class = {
.tsw_param = uart_tty_param,
.tsw_modem = uart_tty_modem,
.tsw_free = uart_tty_free,
+ .tsw_busy = uart_tty_busy,
};
int
OpenPOWER on IntegriCloud