summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2011-07-07 15:24:59 +0000
committerjsing <jsing@openbsd.org>2011-07-07 15:24:59 +0000
commit2054f6b3b49c75e3a0213585e02ff24811de1b71 (patch)
treee8751677cb8c76b6eec5d6fa9173eba0cc892b3c
parentSync comments with reality. (diff)
downloadwireguard-openbsd-2054f6b3b49c75e3a0213585e02ff24811de1b71.tar.xz
wireguard-openbsd-2054f6b3b49c75e3a0213585e02ff24811de1b71.zip
Make sr_shutdown() a general function and use this from sr_detach() to
avoid duplication. Implement a sr_shutdownhook() function that simply calls sr_shutdown() and use this for the shutdown hook. ok marco@
-rw-r--r--sys/dev/softraid.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index e99b8f50cf4..1f2d298f75e 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.241 2011/07/06 17:37:22 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.242 2011/07/07 15:24:59 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -114,7 +114,8 @@ void sr_discipline_shutdown(struct sr_discipline *, int);
int sr_discipline_init(struct sr_discipline *, int);
/* utility functions */
-void sr_shutdown(void *);
+void sr_shutdown(struct sr_softc *);
+void sr_shutdownhook(void *);
void sr_uuid_get(struct sr_uuid *);
void sr_uuid_print(struct sr_uuid *, int);
void sr_checksum_print(u_int8_t *);
@@ -1672,7 +1673,7 @@ sr_attach(struct device *parent, struct device *self, void *aux)
softraid_disk_attach = sr_disk_attach;
- sc->sc_shutdownhook = shutdownhook_establish(sr_shutdown, sc);
+ sc->sc_shutdownhook = shutdownhook_establish(sr_shutdownhook, sc);
sr_boot_assembly(sc);
}
@@ -1681,17 +1682,14 @@ int
sr_detach(struct device *self, int flags)
{
struct sr_softc *sc = (void *)self;
- int i, rv;
+ int rv;
DNPRINTF(SR_D_MISC, "%s: sr_detach\n", DEVNAME(sc));
if (sc->sc_shutdownhook)
shutdownhook_disestablish(sc->sc_shutdownhook);
- /* 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);
+ sr_shutdown(sc);
#ifndef SMALL_KERNEL
if (sc->sc_sensor_task != NULL)
@@ -3800,9 +3798,14 @@ sr_validate_stripsize(u_int32_t b)
}
void
-sr_shutdown(void *arg)
+sr_shutdownhook(void *arg)
+{
+ sr_shutdown((struct sr_softc *)arg);
+}
+
+void
+sr_shutdown(struct sr_softc *sc)
{
- struct sr_softc *sc = arg;
int i;
DNPRINTF(SR_D_MISC, "%s: sr_shutdown\n", DEVNAME(sc));