| @@ -1,33 +1,33 @@ | | | @@ -1,33 +1,33 @@ |
1 | /* $NetBSD: si70xx.c,v 1.5 2019/02/03 12:18:21 mrg Exp $ */ | | 1 | /* $NetBSD: si70xx.c,v 1.6 2020/12/05 14:50:33 jdc Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2017 Brad Spencer <brad@anduin.eldar.org> | | 4 | * Copyright (c) 2017 Brad Spencer <brad@anduin.eldar.org> |
5 | * | | 5 | * |
6 | * Permission to use, copy, modify, and distribute this software for any | | 6 | * Permission to use, copy, modify, and distribute this software for any |
7 | * purpose with or without fee is hereby granted, provided that the above | | 7 | * purpose with or without fee is hereby granted, provided that the above |
8 | * copyright notice and this permission notice appear in all copies. | | 8 | * copyright notice and this permission notice appear in all copies. |
9 | * | | 9 | * |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | */ | | 17 | */ |
18 | | | 18 | |
19 | #include <sys/cdefs.h> | | 19 | #include <sys/cdefs.h> |
20 | __KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.5 2019/02/03 12:18:21 mrg Exp $"); | | 20 | __KERNEL_RCSID(0, "$NetBSD: si70xx.c,v 1.6 2020/12/05 14:50:33 jdc Exp $"); |
21 | | | 21 | |
22 | /* | | 22 | /* |
23 | Driver for the Silicon Labs SI7013/SI7020/SI7021 | | 23 | Driver for the Silicon Labs SI7013/SI7020/SI7021 |
24 | */ | | 24 | */ |
25 | | | 25 | |
26 | #include <sys/param.h> | | 26 | #include <sys/param.h> |
27 | #include <sys/systm.h> | | 27 | #include <sys/systm.h> |
28 | #include <sys/kernel.h> | | 28 | #include <sys/kernel.h> |
29 | #include <sys/device.h> | | 29 | #include <sys/device.h> |
30 | #include <sys/module.h> | | 30 | #include <sys/module.h> |
31 | #include <sys/sysctl.h> | | 31 | #include <sys/sysctl.h> |
32 | #include <sys/mutex.h> | | 32 | #include <sys/mutex.h> |
33 | | | 33 | |
| @@ -708,26 +708,27 @@ si70xx_attach(device_t parent, device_t | | | @@ -708,26 +708,27 @@ si70xx_attach(device_t parent, device_t |
708 | sizeof(sc->sc_sensors[i].desc)); | | 708 | sizeof(sc->sc_sensors[i].desc)); |
709 | | | 709 | |
710 | sc->sc_sensors[i].units = si70xx_sensors[i].type; | | 710 | sc->sc_sensors[i].units = si70xx_sensors[i].type; |
711 | sc->sc_sensors[i].state = ENVSYS_SINVALID; | | 711 | sc->sc_sensors[i].state = ENVSYS_SINVALID; |
712 | | | 712 | |
713 | DPRINTF(sc, 2, ("%s: registering sensor %d (%s)\n", __func__, i, | | 713 | DPRINTF(sc, 2, ("%s: registering sensor %d (%s)\n", __func__, i, |
714 | sc->sc_sensors[i].desc)); | | 714 | sc->sc_sensors[i].desc)); |
715 | | | 715 | |
716 | error = sysmon_envsys_sensor_attach(sc->sc_sme, | | 716 | error = sysmon_envsys_sensor_attach(sc->sc_sme, |
717 | &sc->sc_sensors[i]); | | 717 | &sc->sc_sensors[i]); |
718 | if (error) { | | 718 | if (error) { |
719 | aprint_error_dev(self, | | 719 | aprint_error_dev(self, |
720 | "Unable to attach sensor %d: %d\n", i, error); | | 720 | "Unable to attach sensor %d: %d\n", i, error); |
| | | 721 | sc->sc_sme = NULL; |
721 | goto out; | | 722 | goto out; |
722 | } | | 723 | } |
723 | } | | 724 | } |
724 | | | 725 | |
725 | sc->sc_sme->sme_name = device_xname(sc->sc_dev); | | 726 | sc->sc_sme->sme_name = device_xname(sc->sc_dev); |
726 | sc->sc_sme->sme_cookie = sc; | | 727 | sc->sc_sme->sme_cookie = sc; |
727 | sc->sc_sme->sme_refresh = si70xx_refresh; | | 728 | sc->sc_sme->sme_refresh = si70xx_refresh; |
728 | | | 729 | |
729 | DPRINTF(sc, 2, ("si70xx_attach: registering with envsys\n")); | | 730 | DPRINTF(sc, 2, ("si70xx_attach: registering with envsys\n")); |
730 | | | 731 | |
731 | if (sysmon_envsys_register(sc->sc_sme)) { | | 732 | if (sysmon_envsys_register(sc->sc_sme)) { |
732 | aprint_error_dev(self, | | 733 | aprint_error_dev(self, |
733 | "unable to register with sysmon\n"); | | 734 | "unable to register with sysmon\n"); |