If we're going to keep a reference on the "props" dictionary from the i2c_attach_args, we should retain it.diff -r1.26 -r1.27 src/sys/dev/i2c/adm1021.c
(thorpej)
--- src/sys/dev/i2c/adm1021.c 2021/01/28 14:35:11 1.26
+++ src/sys/dev/i2c/adm1021.c 2021/01/30 01:22:06 1.27
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: adm1021.c,v 1.26 2021/01/28 14:35:11 thorpej Exp $ */ | 1 | /* $NetBSD: adm1021.c,v 1.27 2021/01/30 01:22:06 thorpej Exp $ */ | |
2 | /* $OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $ */ | 2 | /* $OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2005 Theo de Raadt | 5 | * Copyright (c) 2005 Theo de Raadt | |
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 DISCLAIMS ALL WARRANTIES | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS 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 | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * no negative temps X X X X | 28 | * no negative temps X X X X | |
29 | * 11-bit remote temp X X X X | 29 | * 11-bit remote temp X X X X | |
30 | * no low limits X X | 30 | * no low limits X X | |
31 | * therm (high) limits X X X | 31 | * therm (high) limits X X X | |
32 | * | 32 | * | |
33 | * Registers 0x00 to 0x0f have separate read/write addresses, but | 33 | * Registers 0x00 to 0x0f have separate read/write addresses, but | |
34 | * registers 0x10 and above have the same read/write address. | 34 | * registers 0x10 and above have the same read/write address. | |
35 | * The 11-bit (extended) temperature consists of a separate register with | 35 | * The 11-bit (extended) temperature consists of a separate register with | |
36 | * 3 valid bits that are always added to the external temperature (even if | 36 | * 3 valid bits that are always added to the external temperature (even if | |
37 | * the temperature is negative). | 37 | * the temperature is negative). | |
38 | */ | 38 | */ | |
39 | 39 | |||
40 | #include <sys/cdefs.h> | 40 | #include <sys/cdefs.h> | |
41 | __KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.26 2021/01/28 14:35:11 thorpej Exp $"); | 41 | __KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.27 2021/01/30 01:22:06 thorpej Exp $"); | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | #include <sys/device.h> | 45 | #include <sys/device.h> | |
46 | #include <dev/sysmon/sysmonvar.h> | 46 | #include <dev/sysmon/sysmonvar.h> | |
47 | 47 | |||
48 | #include <dev/i2c/i2cvar.h> | 48 | #include <dev/i2c/i2cvar.h> | |
49 | 49 | |||
50 | /* Registers */ | 50 | /* Registers */ | |
51 | #define ADM1021_INT_TEMP 0x00 /* Internal temperature value */ | 51 | #define ADM1021_INT_TEMP 0x00 /* Internal temperature value */ | |
52 | #define ADM1021_EXT_TEMP 0x01 /* External temperature value */ | 52 | #define ADM1021_EXT_TEMP 0x01 /* External temperature value */ | |
53 | #define ADM1021_STATUS 0x02 /* Status */ | 53 | #define ADM1021_STATUS 0x02 /* Status */ | |
54 | #define ADM1021_CONFIG_READ 0x03 /* Read configuration */ | 54 | #define ADM1021_CONFIG_READ 0x03 /* Read configuration */ | |
@@ -332,26 +332,27 @@ admtemp_setflags(struct admtemp_softc *s | @@ -332,26 +332,27 @@ admtemp_setflags(struct admtemp_softc *s | |||
332 | void | 332 | void | |
333 | admtemp_attach(device_t parent, device_t self, void *aux) | 333 | admtemp_attach(device_t parent, device_t self, void *aux) | |
334 | { | 334 | { | |
335 | struct admtemp_softc *sc = device_private(self); | 335 | struct admtemp_softc *sc = device_private(self); | |
336 | struct i2c_attach_args *ia = aux; | 336 | struct i2c_attach_args *ia = aux; | |
337 | uint8_t cmd, data, stat, comp, rev; | 337 | uint8_t cmd, data, stat, comp, rev; | |
338 | char name[ADMTEMP_NAMELEN]; | 338 | char name[ADMTEMP_NAMELEN]; | |
339 | char ename[64] = "external", iname[64] = "internal"; | 339 | char ename[64] = "external", iname[64] = "internal"; | |
340 | const char *desc; | 340 | const char *desc; | |
341 | 341 | |||
342 | sc->sc_tag = ia->ia_tag; | 342 | sc->sc_tag = ia->ia_tag; | |
343 | sc->sc_addr = ia->ia_addr; | 343 | sc->sc_addr = ia->ia_addr; | |
344 | sc->sc_prop = ia->ia_prop; | 344 | sc->sc_prop = ia->ia_prop; | |
345 | prop_object_retain(sc->sc_prop); | |||
345 | 346 | |||
346 | iic_acquire_bus(sc->sc_tag, 0); | 347 | iic_acquire_bus(sc->sc_tag, 0); | |
347 | cmd = ADM1021_CONFIG_READ; | 348 | cmd = ADM1021_CONFIG_READ; | |
348 | if (admtemp_exec(sc, I2C_OP_READ_WITH_STOP, &cmd, &data) != 0) { | 349 | if (admtemp_exec(sc, I2C_OP_READ_WITH_STOP, &cmd, &data) != 0) { | |
349 | iic_release_bus(sc->sc_tag, 0); | 350 | iic_release_bus(sc->sc_tag, 0); | |
350 | aprint_error_dev(self, "cannot get control register\n"); | 351 | aprint_error_dev(self, "cannot get control register\n"); | |
351 | return; | 352 | return; | |
352 | } | 353 | } | |
353 | if (data & ADM1021_CONFIG_RUN) { | 354 | if (data & ADM1021_CONFIG_RUN) { | |
354 | cmd = ADM1021_STATUS; | 355 | cmd = ADM1021_STATUS; | |
355 | if (admtemp_exec(sc, I2C_OP_READ_WITH_STOP, &cmd, &stat)) { | 356 | if (admtemp_exec(sc, I2C_OP_READ_WITH_STOP, &cmd, &stat)) { | |
356 | iic_release_bus(sc->sc_tag, 0); | 357 | iic_release_bus(sc->sc_tag, 0); | |
357 | aprint_error_dev(self, | 358 | aprint_error_dev(self, |
--- src/sys/dev/i2c/dbcool.c 2021/01/27 02:29:48 1.59
+++ src/sys/dev/i2c/dbcool.c 2021/01/30 01:22:06 1.60
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dbcool.c,v 1.59 2021/01/27 02:29:48 thorpej Exp $ */ | 1 | /* $NetBSD: dbcool.c,v 1.60 2021/01/30 01:22:06 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Goyette | 8 | * by Paul Goyette | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -40,27 +40,27 @@ | @@ -40,27 +40,27 @@ | |||
40 | * http://www.onsemi.com/pub/Collateral/ADT7466.PDF | 40 | * http://www.onsemi.com/pub/Collateral/ADT7466.PDF | |
41 | * http://www.onsemi.com/pub/Collateral/ADT7467-D.PDF | 41 | * http://www.onsemi.com/pub/Collateral/ADT7467-D.PDF | |
42 | * http://www.onsemi.com/pub/Collateral/ADT7468-D.PDF | 42 | * http://www.onsemi.com/pub/Collateral/ADT7468-D.PDF | |
43 | * http://www.onsemi.com/pub/Collateral/ADT7473-D.PDF | 43 | * http://www.onsemi.com/pub/Collateral/ADT7473-D.PDF | |
44 | * http://www.onsemi.com/pub/Collateral/ADT7475-D.PDF | 44 | * http://www.onsemi.com/pub/Collateral/ADT7475-D.PDF | |
45 | * http://www.onsemi.com/pub/Collateral/ADT7476-D.PDF | 45 | * http://www.onsemi.com/pub/Collateral/ADT7476-D.PDF | |
46 | * http://www.onsemi.com/pub/Collateral/ADT7490-D.PDF | 46 | * http://www.onsemi.com/pub/Collateral/ADT7490-D.PDF | |
47 | * http://www.smsc.com/media/Downloads_Public/Data_Sheets/6d103s.pdf | 47 | * http://www.smsc.com/media/Downloads_Public/Data_Sheets/6d103s.pdf | |
48 | * | 48 | * | |
49 | * (URLs are correct as of October 5, 2008) | 49 | * (URLs are correct as of October 5, 2008) | |
50 | */ | 50 | */ | |
51 | 51 | |||
52 | #include <sys/cdefs.h> | 52 | #include <sys/cdefs.h> | |
53 | __KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.59 2021/01/27 02:29:48 thorpej Exp $"); | 53 | __KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.60 2021/01/30 01:22:06 thorpej Exp $"); | |
54 | 54 | |||
55 | #include <sys/param.h> | 55 | #include <sys/param.h> | |
56 | #include <sys/systm.h> | 56 | #include <sys/systm.h> | |
57 | #include <sys/kernel.h> | 57 | #include <sys/kernel.h> | |
58 | #include <sys/device.h> | 58 | #include <sys/device.h> | |
59 | #include <sys/malloc.h> | 59 | #include <sys/malloc.h> | |
60 | #include <sys/sysctl.h> | 60 | #include <sys/sysctl.h> | |
61 | #include <sys/module.h> | 61 | #include <sys/module.h> | |
62 | 62 | |||
63 | #include <dev/i2c/dbcool_var.h> | 63 | #include <dev/i2c/dbcool_var.h> | |
64 | #include <dev/i2c/dbcool_reg.h> | 64 | #include <dev/i2c/dbcool_reg.h> | |
65 | 65 | |||
66 | /* Config interface */ | 66 | /* Config interface */ | |
@@ -766,26 +766,27 @@ void | @@ -766,26 +766,27 @@ void | |||
766 | dbcool_attach(device_t parent, device_t self, void *aux) | 766 | dbcool_attach(device_t parent, device_t self, void *aux) | |
767 | { | 767 | { | |
768 | struct dbcool_softc *sc = device_private(self); | 768 | struct dbcool_softc *sc = device_private(self); | |
769 | struct i2c_attach_args *args = aux; | 769 | struct i2c_attach_args *args = aux; | |
770 | uint8_t ver; | 770 | uint8_t ver; | |
771 | 771 | |||
772 | sc->sc_dc.dc_addr = args->ia_addr; | 772 | sc->sc_dc.dc_addr = args->ia_addr; | |
773 | sc->sc_dc.dc_tag = args->ia_tag; | 773 | sc->sc_dc.dc_tag = args->ia_tag; | |
774 | sc->sc_dc.dc_chip = NULL; | 774 | sc->sc_dc.dc_chip = NULL; | |
775 | sc->sc_dc.dc_readreg = dbcool_readreg; | 775 | sc->sc_dc.dc_readreg = dbcool_readreg; | |
776 | sc->sc_dc.dc_writereg = dbcool_writereg; | 776 | sc->sc_dc.dc_writereg = dbcool_writereg; | |
777 | sc->sc_dev = self; | 777 | sc->sc_dev = self; | |
778 | sc->sc_prop = args->ia_prop; | 778 | sc->sc_prop = args->ia_prop; | |
779 | prop_object_retain(sc->sc_prop); | |||
779 | 780 | |||
780 | if (dbcool_chip_ident(&sc->sc_dc) < 0 || sc->sc_dc.dc_chip == NULL) | 781 | if (dbcool_chip_ident(&sc->sc_dc) < 0 || sc->sc_dc.dc_chip == NULL) | |
781 | panic("could not identify chip at addr %d", args->ia_addr); | 782 | panic("could not identify chip at addr %d", args->ia_addr); | |
782 | 783 | |||
783 | aprint_naive("\n"); | 784 | aprint_naive("\n"); | |
784 | aprint_normal("\n"); | 785 | aprint_normal("\n"); | |
785 | 786 | |||
786 | ver = sc->sc_dc.dc_readreg(&sc->sc_dc, DBCOOL_REVISION_REG); | 787 | ver = sc->sc_dc.dc_readreg(&sc->sc_dc, DBCOOL_REVISION_REG); | |
787 | if (sc->sc_dc.dc_chip->flags & DBCFLAG_4BIT_VER) | 788 | if (sc->sc_dc.dc_chip->flags & DBCFLAG_4BIT_VER) | |
788 | if (sc->sc_dc.dc_chip->company == SMSC_COMPANYID) | 789 | if (sc->sc_dc.dc_chip->company == SMSC_COMPANYID) | |
789 | { | 790 | { | |
790 | aprint_normal_dev(self, "SMSC %s Controller " | 791 | aprint_normal_dev(self, "SMSC %s Controller " | |
791 | "(rev 0x%02x, stepping 0x%02x)\n", | 792 | "(rev 0x%02x, stepping 0x%02x)\n", |
--- src/sys/dev/i2c/dstemp.c 2021/01/27 02:29:48 1.9
+++ src/sys/dev/i2c/dstemp.c 2021/01/30 01:22:06 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dstemp.c,v 1.9 2021/01/27 02:29:48 thorpej Exp $ */ | 1 | /* $NetBSD: dstemp.c,v 1.10 2021/01/30 01:22:06 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 Michael Lorenz | 4 | * Copyright (c) 2018 Michael Lorenz | |
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: dstemp.c,v 1.9 2021/01/27 02:29:48 thorpej Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: dstemp.c,v 1.10 2021/01/30 01:22:06 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 | 37 | |||
38 | #include <dev/i2c/i2cvar.h> | 38 | #include <dev/i2c/i2cvar.h> | |
39 | 39 | |||
40 | #include <dev/sysmon/sysmonvar.h> | 40 | #include <dev/sysmon/sysmonvar.h> | |
41 | 41 | |||
42 | #define DSTEMP_CMD_START 0x51 /* command, no data */ | 42 | #define DSTEMP_CMD_START 0x51 /* command, no data */ | |
43 | #define DSTEMP_CMD_POR 0x54 /* command, no data */ | 43 | #define DSTEMP_CMD_POR 0x54 /* command, no data */ | |
@@ -99,26 +99,27 @@ dstemp_match(device_t parent, cfdata_t m | @@ -99,26 +99,27 @@ dstemp_match(device_t parent, cfdata_t m | |||
99 | 99 | |||
100 | static void | 100 | static void | |
101 | dstemp_attach(device_t parent, device_t self, void *aux) | 101 | dstemp_attach(device_t parent, device_t self, void *aux) | |
102 | { | 102 | { | |
103 | struct dstemp_softc *sc = device_private(self); | 103 | struct dstemp_softc *sc = device_private(self); | |
104 | struct i2c_attach_args *ia = aux; | 104 | struct i2c_attach_args *ia = aux; | |
105 | char name[64] = "temperature"; | 105 | char name[64] = "temperature"; | |
106 | const char *desc; | 106 | const char *desc; | |
107 | 107 | |||
108 | sc->sc_dev = self; | 108 | sc->sc_dev = self; | |
109 | sc->sc_i2c = ia->ia_tag; | 109 | sc->sc_i2c = ia->ia_tag; | |
110 | sc->sc_addr = ia->ia_addr; | 110 | sc->sc_addr = ia->ia_addr; | |
111 | sc->sc_prop = ia->ia_prop; | 111 | sc->sc_prop = ia->ia_prop; | |
112 | prop_object_retain(sc->sc_prop); | |||
112 | 113 | |||
113 | aprint_naive("\n"); | 114 | aprint_naive("\n"); | |
114 | aprint_normal(": DS1361\n"); | 115 | aprint_normal(": DS1361\n"); | |
115 | 116 | |||
116 | dstemp_init(sc); | 117 | dstemp_init(sc); | |
117 | 118 | |||
118 | sc->sc_sme = sysmon_envsys_create(); | 119 | sc->sc_sme = sysmon_envsys_create(); | |
119 | sc->sc_sme->sme_name = device_xname(self); | 120 | sc->sc_sme->sme_name = device_xname(self); | |
120 | sc->sc_sme->sme_cookie = sc; | 121 | sc->sc_sme->sme_cookie = sc; | |
121 | sc->sc_sme->sme_refresh = dstemp_sensors_refresh; | 122 | sc->sc_sme->sme_refresh = dstemp_sensors_refresh; | |
122 | 123 | |||
123 | sc->sc_sensor_temp.units = ENVSYS_STEMP; | 124 | sc->sc_sensor_temp.units = ENVSYS_STEMP; | |
124 | sc->sc_sensor_temp.state = ENVSYS_SINVALID; | 125 | sc->sc_sensor_temp.state = ENVSYS_SINVALID; |
--- src/sys/dev/i2c/lm75.c 2021/01/27 02:29:48 1.39
+++ src/sys/dev/i2c/lm75.c 2021/01/30 01:22:06 1.40
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lm75.c,v 1.39 2021/01/27 02:29:48 thorpej Exp $ */ | 1 | /* $NetBSD: lm75.c,v 1.40 2021/01/30 01:22:06 thorpej Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.39 2021/01/27 02:29:48 thorpej Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: lm75.c,v 1.40 2021/01/30 01:22:06 thorpej Exp $"); | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/device.h> | 43 | #include <sys/device.h> | |
44 | #include <sys/kernel.h> | 44 | #include <sys/kernel.h> | |
45 | #include <sys/sysctl.h> | 45 | #include <sys/sysctl.h> | |
46 | 46 | |||
47 | #include <dev/sysmon/sysmonvar.h> | 47 | #include <dev/sysmon/sysmonvar.h> | |
48 | 48 | |||
49 | #include <dev/i2c/i2cvar.h> | 49 | #include <dev/i2c/i2cvar.h> | |
50 | #include <dev/i2c/lm75reg.h> | 50 | #include <dev/i2c/lm75reg.h> | |
51 | 51 | |||
52 | struct lmtemp_softc { | 52 | struct lmtemp_softc { | |
@@ -178,26 +178,27 @@ lmtemp_attach(device_t parent, device_t | @@ -178,26 +178,27 @@ lmtemp_attach(device_t parent, device_t | |||
178 | break; | 178 | break; | |
179 | } else { | 179 | } else { | |
180 | if (strcmp(ia->ia_name, "ds1775") == 0) { | 180 | if (strcmp(ia->ia_name, "ds1775") == 0) { | |
181 | i = 1; /* LMTYPE_DS75 */ | 181 | i = 1; /* LMTYPE_DS75 */ | |
182 | } else { | 182 | } else { | |
183 | /* XXX - add code when adding other direct matches! */ | 183 | /* XXX - add code when adding other direct matches! */ | |
184 | i = 0; | 184 | i = 0; | |
185 | } | 185 | } | |
186 | } | 186 | } | |
187 | 187 | |||
188 | sc->sc_tag = ia->ia_tag; | 188 | sc->sc_tag = ia->ia_tag; | |
189 | sc->sc_address = ia->ia_addr; | 189 | sc->sc_address = ia->ia_addr; | |
190 | sc->sc_prop = ia->ia_prop; | 190 | sc->sc_prop = ia->ia_prop; | |
191 | prop_object_retain(sc->sc_prop); | |||
191 | 192 | |||
192 | aprint_naive(": Temperature Sensor\n"); | 193 | aprint_naive(": Temperature Sensor\n"); | |
193 | if (ia->ia_name) { | 194 | if (ia->ia_name) { | |
194 | aprint_normal(": %s %s Temperature Sensor\n", ia->ia_name, | 195 | aprint_normal(": %s %s Temperature Sensor\n", ia->ia_name, | |
195 | lmtemptbl[i].lmtemp_name); | 196 | lmtemptbl[i].lmtemp_name); | |
196 | } else { | 197 | } else { | |
197 | aprint_normal(": %s Temperature Sensor\n", | 198 | aprint_normal(": %s Temperature Sensor\n", | |
198 | lmtemptbl[i].lmtemp_name); | 199 | lmtemptbl[i].lmtemp_name); | |
199 | } | 200 | } | |
200 | 201 | |||
201 | sc->sc_lmtemp_decode = lmtemptbl[i].lmtemp_decode; | 202 | sc->sc_lmtemp_decode = lmtemptbl[i].lmtemp_decode; | |
202 | sc->sc_lmtemp_encode = lmtemptbl[i].lmtemp_encode; | 203 | sc->sc_lmtemp_encode = lmtemptbl[i].lmtemp_encode; | |
203 | 204 |