From 395087ee438cd4c45b377bd224148284086f04fd Mon Sep 17 00:00:00 2001 From: Marcus Glocker Date: Wed, 8 May 2013 08:26:26 +0000 Subject: 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@ --- sys/dev/usb/uthum.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'sys') 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 @@ -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) -- cgit v1.2.3