diff options
author | Marc Balmer <mbalmer@cvs.openbsd.org> | 2007-11-23 16:23:12 +0000 |
---|---|---|
committer | Marc Balmer <mbalmer@cvs.openbsd.org> | 2007-11-23 16:23:12 +0000 |
commit | 485c9918dfd32c765224a2fba6ce1b4d5d5d9146 (patch) | |
tree | db9af3433dc1d9ce611f43b0a292719e9fb58130 /sys/dev/usb/udcf.c | |
parent | d4f99ce89118679f44fddf530eba65c40bb0f3ee (diff) |
Make sure that variables used during detach are initialized during attach.
Discussed with dlg.
Diffstat (limited to 'sys/dev/usb/udcf.c')
-rw-r--r-- | sys/dev/usb/udcf.c | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/sys/dev/usb/udcf.c b/sys/dev/usb/udcf.c index a63d9669b7d..52079234dc5 100644 --- a/sys/dev/usb/udcf.c +++ b/sys/dev/usb/udcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udcf.c,v 1.40 2007/11/23 12:16:17 mbalmer Exp $ */ +/* $OpenBSD: udcf.c,v 1.41 2007/11/23 16:23:11 mbalmer Exp $ */ /* * Copyright (c) 2006, 2007 Marc Balmer <mbalmer@openbsd.org> @@ -169,12 +169,47 @@ udcf_attach(struct device *parent, struct device *self, void *aux) usbd_device_handle dev = uaa->device; usbd_interface_handle iface; struct timeval t; - usb_interface_descriptor_t *id; usbd_status err; usb_device_request_t req; uWord result; int actlen; + usb_init_task(&sc->sc_task, udcf_probe, sc); + usb_init_task(&sc->sc_bv_task, udcf_bv_probe, sc); + usb_init_task(&sc->sc_mg_task, udcf_mg_probe, sc); + usb_init_task(&sc->sc_sl_task, udcf_sl_probe, sc); + usb_init_task(&sc->sc_ct_task, udcf_ct_probe, sc); + + timeout_set(&sc->sc_to, udcf_intr, sc); + timeout_set(&sc->sc_bv_to, udcf_bv_intr, sc); + timeout_set(&sc->sc_mg_to, udcf_mg_intr, sc); + timeout_set(&sc->sc_sl_to, udcf_sl_intr, sc); + timeout_set(&sc->sc_it_to, udcf_it_intr, sc); + timeout_set(&sc->sc_ct_to, udcf_ct_intr, sc); + + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + + sc->sc_sensor.type = SENSOR_TIMEDELTA; + sc->sc_sensor.status = SENSOR_S_UNKNOWN; + sc->sc_sensor.value = 0LL; + sc->sc_sensor.flags = 0; + strlcpy(sc->sc_sensor.desc, "Unknown", sizeof(sc->sc_sensor.desc)); + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor); + +#ifdef UDCF_DEBUG + sc->sc_skew.type = SENSOR_TIMEDELTA; + sc->sc_skew.status = SENSOR_S_UNKNOWN; + sc->sc_skew.value = 0LL; + sc->sc_skew.flags = 0; + strlcpy(sc->sc_skew.desc, "local clock skew", + sizeof(sc->sc_skew.desc)); + sensor_attach(&sc->sc_sensordev, &sc->sc_skew); +#endif + sensordev_install(&sc->sc_sensordev); + + + sc->sc_udev = dev; if ((err = usbd_set_config_index(dev, 0, 1))) { DPRINTF(("%s: failed to set configuration, err=%s\n", sc->sc_dev.dv_xname, usbd_errstr(err))); @@ -187,9 +222,6 @@ udcf_attach(struct device *parent, struct device *self, void *aux) goto fishy; } - id = usbd_get_interface_descriptor(iface); - - sc->sc_udev = dev; sc->sc_iface = iface; sc->sc_clocktype = -1; @@ -205,28 +237,6 @@ udcf_attach(struct device *parent, struct device *self, void *aux) sc->sc_last = 0L; sc->sc_last_tv.tv_sec = 0L; - strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, - sizeof(sc->sc_sensordev.xname)); - - sc->sc_sensor.type = SENSOR_TIMEDELTA; - sc->sc_sensor.status = SENSOR_S_UNKNOWN; - sc->sc_sensor.value = 0LL; - sc->sc_sensor.flags = 0; - strlcpy(sc->sc_sensor.desc, "Unknown", sizeof(sc->sc_sensor.desc)); - sensor_attach(&sc->sc_sensordev, &sc->sc_sensor); - -#ifdef UDCF_DEBUG - sc->sc_skew.type = SENSOR_TIMEDELTA; - sc->sc_skew.status = SENSOR_S_UNKNOWN; - sc->sc_skew.value = 0LL; - sc->sc_skew.flags = 0; - strlcpy(sc->sc_skew.desc, "local clock skew", - sizeof(sc->sc_skew.desc)); - sensor_attach(&sc->sc_sensordev, &sc->sc_skew); -#endif - - sensordev_install(&sc->sc_sensordev); - /* Prepare the USB request to probe the value */ sc->sc_req.bmRequestType = UDCF_READ_REQ; sc->sc_req.bRequest = 1; @@ -259,19 +269,6 @@ udcf_attach(struct device *parent, struct device *self, void *aux) usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, &sc->sc_dev); - usb_init_task(&sc->sc_task, udcf_probe, sc); - usb_init_task(&sc->sc_bv_task, udcf_bv_probe, sc); - usb_init_task(&sc->sc_mg_task, udcf_mg_probe, sc); - usb_init_task(&sc->sc_sl_task, udcf_sl_probe, sc); - usb_init_task(&sc->sc_ct_task, udcf_ct_probe, sc); - - timeout_set(&sc->sc_to, udcf_intr, sc); - timeout_set(&sc->sc_bv_to, udcf_bv_intr, sc); - timeout_set(&sc->sc_mg_to, udcf_mg_intr, sc); - timeout_set(&sc->sc_sl_to, udcf_sl_intr, sc); - timeout_set(&sc->sc_it_to, udcf_it_intr, sc); - timeout_set(&sc->sc_ct_to, udcf_ct_intr, sc); - /* convert timevals to hz */ t.tv_sec = 0L; t.tv_usec = 150000L; |