diff options
author | Marc Balmer <mbalmer@cvs.openbsd.org> | 2006-05-27 18:22:05 +0000 |
---|---|---|
committer | Marc Balmer <mbalmer@cvs.openbsd.org> | 2006-05-27 18:22:05 +0000 |
commit | 4935fbdf5d5c47f114f9d1b2b6a47dbc7b75a582 (patch) | |
tree | 788a8149a9290f2eceebec6ef5b4634562c91b2f /sys/dev/usb/udcf.c | |
parent | 70afaa5e04789d762c8607cc30bd3a790e0be217 (diff) |
When the device is attached, immediately create the timedelta sensor with the
SENSOR_FINVALID flag set and without a description. We do not need a dummy
description as a sensor with the FINVALID flags set will not show up or be used
anyways. It's merely an indication to applications that there is a sensor that
will eventually have a correct value.
The SENSOR_FINVALID flag is removed and the description is set to the proper
clockname as soon as we have received the first valid time information.
This enables ntpd to check for hotplug events and rescan the list of timedelta
sensors after a hotplug event.
discussed with deraadt.
Diffstat (limited to 'sys/dev/usb/udcf.c')
-rw-r--r-- | sys/dev/usb/udcf.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/usb/udcf.c b/sys/dev/usb/udcf.c index 334d842dd60..7af7e938ed0 100644 --- a/sys/dev/usb/udcf.c +++ b/sys/dev/usb/udcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udcf.c,v 1.6 2006/04/27 08:22:56 mbalmer Exp $ */ +/* $OpenBSD: udcf.c,v 1.7 2006/05/27 18:22:04 mbalmer Exp $ */ /* * Copyright (c) 2006 Marc Balmer <mbalmer@openbsd.org> @@ -179,6 +179,8 @@ USB_ATTACH(udcf) sizeof(sc->sc_sensor.device)); sc->sc_sensor.type = SENSOR_TIMEDELTA; sc->sc_sensor.status = SENSOR_S_UNKNOWN; + sc->sc_sensor.flags = SENSOR_FINVALID; + sensor_add(&sc->sc_sensor); /* Prepare the USB request to probe the value */ @@ -401,7 +403,7 @@ udcf_probe(void *xsc) (now.tv_sec - sc->sc_current) * 1000000000 + now.tv_nsec; - /* set the clocktype */ + /* set the clocktype and make sensor valid */ if (sc->sc_sensor.status == SENSOR_S_UNKNOWN) { strlcpy(sc->sc_sensor.desc, @@ -411,7 +413,8 @@ udcf_probe(void *xsc) sizeof(sc->sc_sensor.desc)); DPRINTF(("add timedelta sensor for %s\n", sc->sc_sensor.desc)); - sensor_add(&sc->sc_sensor); + sc->sc_sensor.flags &= + ~SENSOR_FINVALID; } sc->sc_sensor.status = SENSOR_S_OK; |