Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c Handle failing to acquire the iic bus.
details: https://anonhg.NetBSD.org/src/rev/708206be3b5d
branches: trunk
changeset: 946822:708206be3b5d
user: jdc <jdc%NetBSD.org@localhost>
date: Thu Dec 10 17:02:51 2020 +0000
description:
Handle failing to acquire the iic bus.
Better handle errors when attaching sysmon sensors.
diffstat:
sys/dev/i2c/adm1021.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diffs (114 lines):
diff -r 29e446620712 -r 708206be3b5d sys/dev/i2c/adm1021.c
--- a/sys/dev/i2c/adm1021.c Thu Dec 10 16:47:42 2020 +0000
+++ b/sys/dev/i2c/adm1021.c Thu Dec 10 17:02:51 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: adm1021.c,v 1.20 2020/08/21 20:44:38 macallan Exp $ */
+/* $NetBSD: adm1021.c,v 1.21 2020/12/10 17:02:51 jdc Exp $ */
/* $OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $ */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.20 2020/08/21 20:44:38 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.21 2020/12/10 17:02:51 jdc Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -396,6 +396,7 @@
if (sysmon_envsys_sensor_attach(
sc->sc_sme, &sc->sc_sensor[ADMTEMP_INT])) {
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
aprint_error_dev(self,
"unable to attach internal at sysmon\n");
return;
@@ -404,6 +405,7 @@
sysmon_envsys_sensor_attach(
sc->sc_sme, &sc->sc_sensor[ADMTEMP_EXT])) {
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
aprint_error_dev(self,
"unable to attach external at sysmon\n");
return;
@@ -425,6 +427,7 @@
aprint_error_dev(self,
"unable to register with sysmon\n");
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
return;
}
}
@@ -437,7 +440,10 @@
uint8_t cmd, xdata;
int8_t sdata;
- iic_acquire_bus(sc->sc_tag, 0);
+ if (iic_acquire_bus(sc->sc_tag, 0)) {
+ edata->state = ENVSYS_SINVALID;
+ return;
+ }
if (edata->sensor == ADMTEMP_INT)
cmd = ADM1021_INT_TEMP;
@@ -472,7 +478,8 @@
*props &= ~(PROP_CRITMAX | PROP_CRITMIN);
- iic_acquire_bus(sc->sc_tag, 0);
+ if (iic_acquire_bus(sc->sc_tag, 0))
+ return;
if (edata->sensor == ADMTEMP_INT)
cmd = ADM1021_INT_HIGH_READ;
@@ -521,7 +528,8 @@
*props &= ~(PROP_CRITMAX | PROP_CRITMIN);
- iic_acquire_bus(sc->sc_tag, 0);
+ if (iic_acquire_bus(sc->sc_tag, 0))
+ return;
if (edata->sensor == ADMTEMP_INT)
cmd = ADM1021_INT_HIGH_READ;
@@ -585,7 +593,8 @@
*props &= ~(PROP_WARNMAX | PROP_CRITMAX | PROP_WARNMIN);
- iic_acquire_bus(sc->sc_tag, 0);
+ if (iic_acquire_bus(sc->sc_tag, 0))
+ return;
if (edata->sensor == ADMTEMP_INT)
cmd = ADM1032_INT_THERM;
@@ -660,7 +669,8 @@
int tmp;
int8_t sdata;
- iic_acquire_bus(sc->sc_tag, 0);
+ if (iic_acquire_bus(sc->sc_tag, 0))
+ return;
if (*props & PROP_CRITMAX) {
if (edata->sensor == ADMTEMP_INT)
@@ -746,7 +756,8 @@
else
ext11 = 1;
- iic_acquire_bus(sc->sc_tag, 0);
+ if (iic_acquire_bus(sc->sc_tag, 0))
+ return;
if (*props & PROP_CRITMAX) {
if (edata->sensor == ADMTEMP_INT)
@@ -803,7 +814,8 @@
else
ext11 = 1;
- iic_acquire_bus(sc->sc_tag, 0);
+ if (iic_acquire_bus(sc->sc_tag, 0))
+ return;
if (*props & PROP_CRITMAX) {
if (edata->sensor == ADMTEMP_INT)
Home |
Main Index |
Thread Index |
Old Index