diff options
author | ian <ian@FreeBSD.org> | 2015-08-08 20:11:47 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2015-08-08 20:11:47 +0000 |
commit | ba466d645c77cf6a6520a3cad4d779bdd62191dc (patch) | |
tree | 4ad72abf0ba55fa1c56dca04ef4319c4f23b78b9 /sys/dev/uart/uart_core.c | |
parent | c2259f45df1012dfba5d3714c8d789be6fc7e4fb (diff) | |
download | FreeBSD-src-ba466d645c77cf6a6520a3cad4d779bdd62191dc.zip FreeBSD-src-ba466d645c77cf6a6520a3cad4d779bdd62191dc.tar.gz |
Provide the tty-layer mutex when initializing the pps api. This allows
time_pps_fetch() to be used in blocking mode.
Also, don't init the pps api for system devices (consoles) that provide a
custom attach routine. The device may actually be a keyboard or other non-
tty device. If it wants to do pps processing (unlikely) it must handle
everything for itself. (In reality, only a sun keyboard uses a custom
attach routine, and it doesn't make a good pps device.)
Diffstat (limited to 'sys/dev/uart/uart_core.c')
-rw-r--r-- | sys/dev/uart/uart_core.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/dev/uart/uart_core.c b/sys/dev/uart/uart_core.c index 191244a..a2895b1 100644 --- a/sys/dev/uart/uart_core.c +++ b/sys/dev/uart/uart_core.c @@ -511,9 +511,6 @@ uart_bus_attach(device_t dev) sc->sc_sysdev->stopbits); } - sc->sc_pps.ppscap = PPS_CAPTUREBOTH; - pps_init(&sc->sc_pps); - sc->sc_leaving = 0; sc->sc_testintr = 1; filt = uart_intr(sc); @@ -568,10 +565,17 @@ uart_bus_attach(device_t dev) printf("\n"); } - error = (sc->sc_sysdev != NULL && sc->sc_sysdev->attach != NULL) - ? (*sc->sc_sysdev->attach)(sc) : uart_tty_attach(sc); - if (error) - goto fail; + if (sc->sc_sysdev != NULL && sc->sc_sysdev->attach != NULL) { + if ((error = sc->sc_sysdev->attach(sc)) != 0) + goto fail; + } else { + if ((error = uart_tty_attach(sc)) != 0) + goto fail; + sc->sc_pps.ppscap = PPS_CAPTUREBOTH; + sc->sc_pps.driver_mtx = uart_tty_getlock(sc); + sc->sc_pps.driver_abi = PPS_ABI_VERSION; + pps_init_abi(&sc->sc_pps); + } if (sc->sc_sysdev != NULL) sc->sc_sysdev->hwmtx = sc->sc_hwmtx; |