Thu Aug 6 13:16:49 2009 UTC ()
For the sake of correctness, call pmf_device_deregister() in the detach
function.


(mbalmer)
diff -r1.4 -r1.5 src/sys/dev/gpio/gpiosim.c

cvs diff -r1.4 -r1.5 src/sys/dev/gpio/gpiosim.c (expand / switch to unified diff)

--- src/sys/dev/gpio/gpiosim.c 2009/07/28 15:28:24 1.4
+++ src/sys/dev/gpio/gpiosim.c 2009/08/06 13:16:49 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gpiosim.c,v 1.4 2009/07/28 15:28:24 drochner Exp $ */ 1/* $NetBSD: gpiosim.c,v 1.5 2009/08/06 13:16:49 mbalmer Exp $ */
2/* $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $ */ 2/* $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2007, 2008, 2009 Marc Balmer <marc@msys.ch> 5 * Copyright (c) 2007, 2008, 2009 Marc Balmer <marc@msys.ch>
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@@ -143,26 +143,27 @@ gpiosim_attach(device_t parent, device_t @@ -143,26 +143,27 @@ gpiosim_attach(device_t parent, device_t
143 gpiosim_sysctl, 0, sc, 0, 143 gpiosim_sysctl, 0, sc, 0,
144 CTL_CREATE, CTL_EOL); 144 CTL_CREATE, CTL_EOL);
145 145
146 printf(": simulating %d pins\n", GPIOSIM_NPINS); 146 printf(": simulating %d pins\n", GPIOSIM_NPINS);
147 config_found_ia(self, "gpiobus", &gba, gpiobus_print); 147 config_found_ia(self, "gpiobus", &gba, gpiobus_print);
148} 148}
149 149
150int 150int
151gpiosim_detach(device_t self, int flags) 151gpiosim_detach(device_t self, int flags)
152{ 152{
153 struct gpiosim_softc *sc = device_private(self); 153 struct gpiosim_softc *sc = device_private(self);
154 struct sysctlnode node; 154 struct sysctlnode node;
155 155
 156 pmf_device_deregister(self);
156 if (sc->sc_node != NULL) { 157 if (sc->sc_node != NULL) {
157 node = *sc->sc_node; 158 node = *sc->sc_node;
158 sysctl_destroyv(&node, CTL_EOL); 159 sysctl_destroyv(&node, CTL_EOL);
159 sc->sc_node = NULL; 160 sc->sc_node = NULL;
160 } 161 }
161 162
162 return 0; 163 return 0;
163} 164}
164 165
165int 166int
166gpiosim_activate(device_t self, enum devact act) 167gpiosim_activate(device_t self, enum devact act)
167{ 168{
168 switch (act) { 169 switch (act) {