| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tsl256x.c,v 1.7 2019/07/25 04:25:40 thorpej Exp $ */ | | 1 | /* $NetBSD: tsl256x.c,v 1.8 2020/01/15 05:56:57 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2018 Jason R. Thorpe | | 4 | * Copyright (c) 2018 Jason R. Thorpe |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.7 2019/07/25 04:25:40 thorpej Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: tsl256x.c,v 1.8 2020/01/15 05:56:57 thorpej Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/systm.h> | | 33 | #include <sys/systm.h> |
34 | #include <sys/device.h> | | 34 | #include <sys/device.h> |
35 | #include <sys/conf.h> | | 35 | #include <sys/conf.h> |
36 | #include <sys/bus.h> | | 36 | #include <sys/bus.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
38 | #include <sys/kmem.h> | | 38 | #include <sys/kmem.h> |
39 | #include <sys/mutex.h> | | 39 | #include <sys/mutex.h> |
40 | #include <sys/proc.h> | | 40 | #include <sys/proc.h> |
41 | #include <sys/sysctl.h> | | 41 | #include <sys/sysctl.h> |
42 | | | 42 | |
43 | #include <dev/i2c/i2cvar.h> | | 43 | #include <dev/i2c/i2cvar.h> |
| @@ -642,28 +642,27 @@ tsllux_wait_for_adcs(struct tsllux_softc | | | @@ -642,28 +642,27 @@ tsllux_wait_for_adcs(struct tsllux_softc |
642 | | | 642 | |
643 | case TIMING_INTEG_402ms: | | 643 | case TIMING_INTEG_402ms: |
644 | default: | | 644 | default: |
645 | /* Wait 450ms for 402ms integration */ | | 645 | /* Wait 450ms for 402ms integration */ |
646 | ms = 450; | | 646 | ms = 450; |
647 | break; | | 647 | break; |
648 | } | | 648 | } |
649 | | | 649 | |
650 | if (ms < hztoms(1)) { | | 650 | if (ms < hztoms(1)) { |
651 | /* Just busy-wait if we want to wait for less than 1 tick. */ | | 651 | /* Just busy-wait if we want to wait for less than 1 tick. */ |
652 | delay(ms * 1000); | | 652 | delay(ms * 1000); |
653 | } else { | | 653 | } else { |
654 | /* Round up one tick for the case where we sleep. */ | | 654 | /* Round up one tick for the case where we sleep. */ |
655 | (void) tsleep(tsllux_wait_for_adcs, PWAIT, "tslluxwait", | | 655 | (void) kpause("tslluxwait", false, mstohz(ms) + 1, NULL); |
656 | mstohz(ms) + 1); | | | |
657 | } | | 656 | } |
658 | | | 657 | |
659 | return (0); | | 658 | return (0); |
660 | } | | 659 | } |
661 | | | 660 | |
662 | static int | | 661 | static int |
663 | tsllux_read_adcs(struct tsllux_softc *sc, uint16_t *adc0valp, | | 662 | tsllux_read_adcs(struct tsllux_softc *sc, uint16_t *adc0valp, |
664 | uint16_t *adc1valp) | | 663 | uint16_t *adc1valp) |
665 | { | | 664 | { |
666 | int error; | | 665 | int error; |
667 | | | 666 | |
668 | if ((error = tsllux_read2(sc, TSL256x_REG_DATA0LOW, adc0valp)) == 0) | | 667 | if ((error = tsllux_read2(sc, TSL256x_REG_DATA0LOW, adc0valp)) == 0) |
669 | error = tsllux_read2(sc, TSL256x_REG_DATA1LOW, adc1valp); | | 668 | error = tsllux_read2(sc, TSL256x_REG_DATA1LOW, adc1valp); |