gpiobus.c (0c21a60cf61c61c3a136a803b9c7645c128c6982) gpiobus.c (11bcf702f4200a351f06b549e14bc9ea4fc76dcc)
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

--- 205 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);
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

--- 205 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 ---