summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2013-05-08 08:26:26 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2013-05-08 08:26:26 +0000
commit395087ee438cd4c45b377bd224148284086f04fd (patch)
tree1e624a2178ec3f33663c0d3c7a537f55b45894f9 /sys
parent2f7761667674393d6c92fe71f745c5593f434b9a (diff)
Move reset commands from that attach path to an own function.
Reset device on detach (required for planed usb device claiming). Tested with my uthum(4) device "TEMPer sensor(0x660c), Ten X Technology, Inc.(0x1130)". ok yuo@, mpi@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/uthum.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/sys/dev/usb/uthum.c b/sys/dev/usb/uthum.c
index 3fa05155935..43bad7c18f3 100644
--- a/sys/dev/usb/uthum.c
+++ b/sys/dev/usb/uthum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthum.c,v 1.22 2013/05/08 01:06:34 sthen Exp $ */
+/* $OpenBSD: uthum.c,v 1.23 2013/05/08 08:26:25 mglocker Exp $ */
/*
* Copyright (c) 2009, 2010 Yojiro UO <yuo@nui.org>
@@ -140,6 +140,7 @@ int uthum_detach(struct device *, int);
int uthum_issue_cmd(struct uthum_softc *, uint8_t, int);
int uthum_read_data(struct uthum_softc *, uint8_t, uint8_t *, size_t, int);
int uthum_check_device_info(struct uthum_softc *);
+void uthum_reset_device(struct uthum_softc *);
void uthum_setup_sensors(struct uthum_softc *);
void uthum_intr(struct uhidev *, void *, u_int);
@@ -272,6 +273,8 @@ uthum_detach(struct device *self, int flags)
sensor_task_unregister(sc->sc_sensortask);
}
+ uthum_reset_device(sc);
+
return (rv);
}
@@ -403,6 +406,20 @@ uthum_check_device_info(struct uthum_softc *sc)
/* device specific init process */
switch (dev_type) {
+ case UTHUM_TYPE_TEMPERHUM:
+ sc->sc_sensor[UTHUM_TEMPER_NTC].cur_state = 0;
+ break;
+ };
+
+ uthum_reset_device(sc);
+
+ return 0;
+};
+
+void
+uthum_reset_device(struct uthum_softc *sc)
+{
+ switch (sc->sc_device_type) {
case UTHUM_TYPE_TEMPER1:
case UTHUM_TYPE_TEMPERNTC:
uthum_issue_cmd(sc, CMD_RESET0, 200);
@@ -411,13 +428,8 @@ uthum_check_device_info(struct uthum_softc *sc)
uthum_issue_cmd(sc, CMD_RESET0, 200);
uthum_issue_cmd(sc, CMD_RESET1, 200);
break;
- case UTHUM_TYPE_TEMPERHUM:
- sc->sc_sensor[UTHUM_TEMPER_NTC].cur_state = 0;
- break;
- };
-
- return 0;
-};
+ }
+}
void
uthum_setup_sensors(struct uthum_softc *sc)