Deleted Added
full compact
gpiobus.c (215142) gpiobus.c (227701)
1/*-
2 * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/gpio/gpiobus.c 215142 2010-11-11 20:18:33Z thompsa $");
28__FBSDID("$FreeBSD: head/sys/dev/gpio/gpiobus.c 227701 2011-11-19 10:11:50Z hselasky $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/malloc.h>
33#include <sys/module.h>
34#include <sys/kernel.h>
35#include <sys/queue.h>
36#include <sys/sysctl.h>

--- 177 unchanged lines hidden (view full) ---

214/*
215 * Since this is not a self-enumerating bus, and since we always add
216 * children in attach, we have to always delete children here.
217 */
218static int
219gpiobus_detach(device_t dev)
220{
221 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/malloc.h>
33#include <sys/module.h>
34#include <sys/kernel.h>
35#include <sys/queue.h>
36#include <sys/sysctl.h>

--- 177 unchanged lines hidden (view full) ---

214/*
215 * Since this is not a self-enumerating bus, and since we always add
216 * children in attach, we have to always delete children here.
217 */
218static int
219gpiobus_detach(device_t dev)
220{
221 struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
222 int err, ndevs, i;
223 device_t *devlist;
222 int err;
224
225 KASSERT(mtx_initialized(&sc->sc_mtx),
226 ("gpiobus mutex not initialized"));
227 GPIOBUS_LOCK_DESTROY(sc);
228
229 if ((err = bus_generic_detach(dev)) != 0)
230 return (err);
223
224 KASSERT(mtx_initialized(&sc->sc_mtx),
225 ("gpiobus mutex not initialized"));
226 GPIOBUS_LOCK_DESTROY(sc);
227
228 if ((err = bus_generic_detach(dev)) != 0)
229 return (err);
231 if ((err = device_get_children(dev, &devlist, &ndevs)) != 0)
232 return (err);
233 for (i = 0; i < ndevs; i++)
234 device_delete_child(dev, devlist[i]);
235
230
231 /* detach and delete all children */
232 device_delete_all_children(dev);
233
236 if (sc->sc_pins_mapped) {
237 free(sc->sc_pins_mapped, M_DEVBUF);
238 sc->sc_pins_mapped = NULL;
239 }
234 if (sc->sc_pins_mapped) {
235 free(sc->sc_pins_mapped, M_DEVBUF);
236 sc->sc_pins_mapped = NULL;
237 }
240 free(devlist, M_TEMP);
241
242 return (0);
243}
244
245static int
246gpiobus_suspend(device_t dev)
247{
248

--- 245 unchanged lines hidden ---
238
239 return (0);
240}
241
242static int
243gpiobus_suspend(device_t dev)
244{
245

--- 245 unchanged lines hidden ---