summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2011-07-06 15:55:25 +0000
committerjsing <jsing@openbsd.org>2011-07-06 15:55:25 +0000
commit70c5e82104bd2adf27645dfc90dd5ae94e147a5a (patch)
tree7c927944d9a7e2648829694f945046edcbb89b50
parentRetain a reference to the registered sensor task so that we can unregister (diff)
downloadwireguard-openbsd-70c5e82104bd2adf27645dfc90dd5ae94e147a5a.tar.xz
wireguard-openbsd-70c5e82104bd2adf27645dfc90dd5ae94e147a5a.zip
Actually make sr_detach() work. At this stage we never detach softraid(4),
however since this code exists it still should work correctly.
-rw-r--r--sys/dev/softraid.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index bc7cf0c4c54..6e304470e1f 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.238 2011/07/06 15:44:11 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.239 2011/07/06 15:55:25 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -1679,7 +1679,20 @@ int
sr_detach(struct device *self, int flags)
{
struct sr_softc *sc = (void *)self;
- int rv;
+ int i, rv;
+
+ DNPRINTF(SR_D_MISC, "%s: sr_detach\n", DEVNAME(sc));
+
+ /* XXX this will not work when we stagger disciplines */
+ for (i = 0; i < SR_MAX_LD; i++)
+ if (sc->sc_dis[i])
+ sr_discipline_shutdown(sc->sc_dis[i], 1);
+
+#ifndef SMALL_KERNEL
+ if (sc->sc_sensor_task != NULL)
+ sensor_task_unregister(sc->sc_sensor_task);
+ sensordev_deinstall(&sc->sc_sensordev);
+#endif /* SMALL_KERNEL */
if (sc->sc_scsibus != NULL) {
rv = config_detach((struct device *)sc->sc_scsibus, flags);
@@ -1688,11 +1701,7 @@ sr_detach(struct device *self, int flags)
sc->sc_scsibus = NULL;
}
-#ifndef SMALL_KERNEL
- sensordev_deinstall(&sc->sc_sensordev);
-#endif /* SMALL_KERNEL */
-
- return (0);
+ return (rv);
}
void