From cd401f6732e8849ebd763413c6d53b1126b61a05 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 20 Apr 2010 20:49:37 +0000 Subject: Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled by returning ENXIO instead of ENOENT, to essentially indicate hotplug sensor that has gone away. Accessing beyond the end of the sensordev list still returns ENOENT, so that you can see there are no further devices. ok kettenis oga --- sys/arch/sparc64/dev/tda.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/sparc64/dev/tda.c b/sys/arch/sparc64/dev/tda.c index 6de04c4eae2..f856b971f85 100644 --- a/sys/arch/sparc64/dev/tda.c +++ b/sys/arch/sparc64/dev/tda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */ +/* $OpenBSD: tda.c,v 1.5 2010/04/20 20:49:34 deraadt Exp $ */ /* * Copyright (c) 2008 Robert Nagy @@ -99,6 +99,7 @@ tda_attach(struct device *parent, struct device *self, void *aux) { struct tda_softc *sc = (struct tda_softc *)self; struct i2c_attach_args *ia = aux; + struct ksensordev *ksens; int i; sc->sc_tag = ia->ia_tag; @@ -114,8 +115,8 @@ tda_attach(struct device *parent, struct device *self, void *aux) tda_setspeed(sc); /* Get the number of sensor devices. */ - for (i = 0; i < MAXSENSORDEVICES; i++) { - if (sensordev_get(i) == NULL) + for (i = 0; ; i++) { + if (sensordev_get(i, &ksens) == ENOENT) break; } sc->sc_nsensors = i; @@ -184,23 +185,23 @@ tda_adjust(void *v) struct tda_softc *sc = v; struct ksensor *ks; u_int64_t ctemp, stemp; - int i; + int i, err; /* Default to running the fans at maximum speed. */ sc->sc_cfan_speed = sc->sc_sfan_speed = TDA_FANSPEED_MAX; ctemp = stemp = 0; for (i = 0; i < sc->sc_nsensors; i++) { - ks = sensor_find(i, SENSOR_TEMP, SENSOR_TEMP_EXT); - if (ks == NULL) { + err = sensor_find(i, SENSOR_TEMP, SENSOR_TEMP_EXT, &ks); + if (err) { printf("%s: failed to get external sensor\n", DEVNAME(sc)); goto out; } ctemp = MAX(ctemp, ks->value); - ks = sensor_find(i, SENSOR_TEMP, SENSOR_TEMP_INT); - if (ks == NULL) { + err = sensor_find(i, SENSOR_TEMP, SENSOR_TEMP_INT, &ks); + if (err) { printf("%s: failed to get internal sensors\n", DEVNAME(sc)); goto out; -- cgit v1.2.3