summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2005-11-12 15:12:11 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2005-11-12 15:12:11 +0000
commit8182414fe18c676ec044cb3226012c3e6825a31c (patch)
tree75d35a883ef01a28b1e1b903c9436097e7abad32 /sys
parent0d0712d63e871518d8cfc3cdf4bbe64233f12b61 (diff)
there are two things that safte does: update sensors and blink lights. if
attach figures out that we cant do either of them, then free up all the resources.
Diffstat (limited to 'sys')
-rw-r--r--sys/scsi/safte.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/scsi/safte.c b/sys/scsi/safte.c
index 0d3e8645f5c..6e0a8dc232f 100644
--- a/sys/scsi/safte.c
+++ b/sys/scsi/safte.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safte.c,v 1.20 2005/11/11 01:19:47 fgsch Exp $ */
+/* $OpenBSD: safte.c,v 1.21 2005/11/12 15:12:10 dlg Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -155,7 +155,7 @@ safte_attach(struct device *parent, struct device *self, void *aux)
{
struct safte_softc *sc = (struct safte_softc *)self;
struct scsibus_attach_args *sa = aux;
- int i;
+ int i = 0;
sc->sc_link = sa->sa_sc_link;
sa->sa_sc_link->device_softc = sc;
@@ -177,7 +177,8 @@ safte_attach(struct device *parent, struct device *self, void *aux)
if (sc->sc_nsensors > 0 &&
sensor_task_register(sc, safte_read_encstat, 10) != 0) {
printf("%s: unable to register update task\n", DEVNAME(sc));
- sc->sc_nsensors = 0;
+ sc->sc_nsensors = sc->sc_ntemps = 0;
+ free(sc->sc_sensors, M_DEVBUF);
} else {
for (i = 0; i < sc->sc_nsensors; i++)
SENSOR_ADD(&sc->sc_sensors[i].se_sensor);
@@ -188,8 +189,16 @@ safte_attach(struct device *parent, struct device *self, void *aux)
bio_register(self, safte_ioctl) != 0) {
printf("%s: unable to register ioctl with bio\n", DEVNAME(sc));
sc->sc_nslots = 0;
- }
+ } else
+ i++;
#endif
+
+ if (i) /* if we're doing something, then preinit encbuf and sensors */
+ safte_read_encstat(sc);
+ else {
+ free(sc->sc_encbuf, M_DEVBUF);
+ sc->sc_encbuf = NULL;
+ }
}
int
@@ -198,7 +207,6 @@ safte_detach(struct device *self, int flags)
struct safte_softc *sc = (struct safte_softc *)self;
int i;
-
#if NBIO > 0
if (sc->sc_nslots > 0)
bio_unregister(self);