summaryrefslogtreecommitdiffstats
path: root/sys/sys
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/sys
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/sys')
-rw-r--r--sys/sys/ttydevsw.h41
1 files changed, 33 insertions, 8 deletions
diff --git a/sys/sys/ttydevsw.h b/sys/sys/ttydevsw.h
index 748ae0b..98bebca 100644
--- a/sys/sys/ttydevsw.h
+++ b/sys/sys/ttydevsw.h
@@ -54,6 +54,7 @@ typedef int tsw_mmap_t(struct tty *tp, vm_ooffset_t offset,
vm_paddr_t * paddr, int nprot, vm_memattr_t *memattr);
typedef void tsw_pktnotify_t(struct tty *tp, char event);
typedef void tsw_free_t(void *softc);
+typedef bool tsw_busy_t(struct tty *tp);
struct ttydevsw {
unsigned int tsw_flags; /* Default TTY flags. */
@@ -74,21 +75,25 @@ struct ttydevsw {
tsw_free_t *tsw_free; /* Destructor. */
- void *tsw_spare[4]; /* For future use. */
+ tsw_busy_t *tsw_busy; /* Draining output. */
+
+ void *tsw_spare[3]; /* For future use. */
};
static __inline int
ttydevsw_open(struct tty *tp)
{
+
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
- return tp->t_devsw->tsw_open(tp);
+ return (tp->t_devsw->tsw_open(tp));
}
static __inline void
ttydevsw_close(struct tty *tp)
{
+
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
@@ -98,6 +103,7 @@ ttydevsw_close(struct tty *tp)
static __inline void
ttydevsw_outwakeup(struct tty *tp)
{
+
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
@@ -111,6 +117,7 @@ ttydevsw_outwakeup(struct tty *tp)
static __inline void
ttydevsw_inwakeup(struct tty *tp)
{
+
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
@@ -124,49 +131,56 @@ ttydevsw_inwakeup(struct tty *tp)
static __inline int
ttydevsw_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
{
+
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
- return tp->t_devsw->tsw_ioctl(tp, cmd, data, td);
+ return (tp->t_devsw->tsw_ioctl(tp, cmd, data, td));
}
static __inline int
-ttydevsw_cioctl(struct tty *tp, int unit, u_long cmd, caddr_t data, struct thread *td)
+ttydevsw_cioctl(struct tty *tp, int unit, u_long cmd, caddr_t data,
+ struct thread *td)
{
+
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
- return tp->t_devsw->tsw_cioctl(tp, unit, cmd, data, td);
+ return (tp->t_devsw->tsw_cioctl(tp, unit, cmd, data, td));
}
static __inline int
ttydevsw_param(struct tty *tp, struct termios *t)
{
+
MPASS(!tty_gone(tp));
- return tp->t_devsw->tsw_param(tp, t);
+ return (tp->t_devsw->tsw_param(tp, t));
}
static __inline int
ttydevsw_modem(struct tty *tp, int sigon, int sigoff)
{
+
MPASS(!tty_gone(tp));
- return tp->t_devsw->tsw_modem(tp, sigon, sigoff);
+ return (tp->t_devsw->tsw_modem(tp, sigon, sigoff));
}
static __inline int
ttydevsw_mmap(struct tty *tp, vm_ooffset_t offset, vm_paddr_t *paddr,
int nprot, vm_memattr_t *memattr)
{
+
MPASS(!tty_gone(tp));
- return tp->t_devsw->tsw_mmap(tp, offset, paddr, nprot, memattr);
+ return (tp->t_devsw->tsw_mmap(tp, offset, paddr, nprot, memattr));
}
static __inline void
ttydevsw_pktnotify(struct tty *tp, char event)
{
+
tty_lock_assert(tp, MA_OWNED);
MPASS(!tty_gone(tp));
@@ -176,9 +190,20 @@ ttydevsw_pktnotify(struct tty *tp, char event)
static __inline void
ttydevsw_free(struct tty *tp)
{
+
MPASS(tty_gone(tp));
tp->t_devsw->tsw_free(tty_softc(tp));
}
+static __inline bool
+ttydevsw_busy(struct tty *tp)
+{
+
+ tty_lock_assert(tp, MA_OWNED);
+ MPASS(!tty_gone(tp));
+
+ return (tp->t_devsw->tsw_busy(tp));
+}
+
#endif /* !_SYS_TTYDEVSW_H_ */
OpenPOWER on IntegriCloud