| @@ -1,38 +1,38 @@ | | | @@ -1,38 +1,38 @@ |
1 | /* $NetBSD: uthum.c,v 1.10.14.8 2016/12/05 10:55:20 skrll Exp $ */ | | 1 | /* $NetBSD: uthum.c,v 1.10.14.9 2017/01/28 10:10:15 skrll Exp $ */ |
2 | /* $OpenBSD: uthum.c,v 1.6 2010/01/03 18:43:02 deraadt Exp $ */ | | 2 | /* $OpenBSD: uthum.c,v 1.6 2010/01/03 18:43:02 deraadt Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2009 Yojiro UO <yuo@nui.org> | | 5 | * Copyright (c) 2009 Yojiro UO <yuo@nui.org> |
6 | * | | 6 | * |
7 | * Permission to use, copy, modify, and distribute this software for any | | 7 | * Permission to use, copy, modify, and distribute this software for any |
8 | * purpose with or without fee is hereby granted, provided that the above | | 8 | * purpose with or without fee is hereby granted, provided that the above |
9 | * copyright notice and this permission notice appear in all copies. | | 9 | * copyright notice and this permission notice appear in all copies. |
10 | * | | 10 | * |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCAIMS ALL WARRANTIES | | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCAIMS ALL WARRANTIES |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
18 | */ | | 18 | */ |
19 | | | 19 | |
20 | /* | | 20 | /* |
21 | * Driver for TEMPer and TEMPerHUM HID | | 21 | * Driver for TEMPer and TEMPerHUM HID |
22 | */ | | 22 | */ |
23 | | | 23 | |
24 | #include <sys/cdefs.h> | | 24 | #include <sys/cdefs.h> |
25 | __KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.10.14.8 2016/12/05 10:55:20 skrll Exp $"); | | 25 | __KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.10.14.9 2017/01/28 10:10:15 skrll Exp $"); |
26 | | | 26 | |
27 | #ifdef _KERNEL_OPT | | 27 | #ifdef _KERNEL_OPT |
28 | #include "opt_usb.h" | | 28 | #include "opt_usb.h" |
29 | #endif | | 29 | #endif |
30 | | | 30 | |
31 | #include <sys/param.h> | | 31 | #include <sys/param.h> |
32 | #include <sys/proc.h> | | 32 | #include <sys/proc.h> |
33 | #include <sys/systm.h> | | 33 | #include <sys/systm.h> |
34 | #include <sys/kernel.h> | | 34 | #include <sys/kernel.h> |
35 | #include <sys/device.h> | | 35 | #include <sys/device.h> |
36 | #include <sys/conf.h> | | 36 | #include <sys/conf.h> |
37 | | | 37 | |
38 | #include <dev/sysmon/sysmonvar.h> | | 38 | #include <dev/sysmon/sysmonvar.h> |
| @@ -284,27 +284,27 @@ uthum_read_data(struct uthum_softc *sc, | | | @@ -284,27 +284,27 @@ uthum_read_data(struct uthum_softc *sc, |
284 | memset(cmdbuf, 0, sizeof(cmdbuf)); | | 284 | memset(cmdbuf, 0, sizeof(cmdbuf)); |
285 | for (i = 0; i < 7; i++) { | | 285 | for (i = 0; i < 7; i++) { |
286 | if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, | | 286 | if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, |
287 | cmdbuf, sc->sc_olen)) | | 287 | cmdbuf, sc->sc_olen)) |
288 | return EIO; | | 288 | return EIO; |
289 | } | | 289 | } |
290 | memcpy(cmdbuf, cmd_end, sizeof(cmd_end)); | | 290 | memcpy(cmdbuf, cmd_end, sizeof(cmd_end)); |
291 | if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, | | 291 | if (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, |
292 | cmdbuf, sc->sc_olen)) | | 292 | cmdbuf, sc->sc_olen)) |
293 | return EIO; | | 293 | return EIO; |
294 | | | 294 | |
295 | /* wait if required */ | | 295 | /* wait if required */ |
296 | if (need_delay > 1) | | 296 | if (need_delay > 1) |
297 | tsleep(&sc->sc_sme, 0, "uthum", (need_delay*hz+999)/1000 + 1); | | 297 | kpause("uthum", false, (need_delay*hz+999)/1000 + 1, NULL); |
298 | | | 298 | |
299 | /* get answer */ | | 299 | /* get answer */ |
300 | if (uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, | | 300 | if (uhidev_get_report(&sc->sc_hdev, UHID_FEATURE_REPORT, |
301 | report, sc->sc_flen)) | | 301 | report, sc->sc_flen)) |
302 | return EIO; | | 302 | return EIO; |
303 | memcpy(buf, report, len); | | 303 | memcpy(buf, report, len); |
304 | return 0; | | 304 | return 0; |
305 | } | | 305 | } |
306 | | | 306 | |
307 | int | | 307 | int |
308 | uthum_check_sensortype(struct uthum_softc *sc) | | 308 | uthum_check_sensortype(struct uthum_softc *sc) |
309 | { | | 309 | { |
310 | uint8_t buf[8]; | | 310 | uint8_t buf[8]; |