| 793 | } |
| 794 | |
| 795 | static int |
| 796 | zy7_devcfg_detach(device_t dev) |
| 797 | { |
| 798 | struct zy7_devcfg_softc *sc = device_get_softc(dev); |
| 799 | |
| 800 | if (sc->sysctl_tree_top != NULL) { |
| 801 | sysctl_ctx_free(&sc->sysctl_tree); |
| 802 | sc->sysctl_tree_top = NULL; |
| 803 | } |
| 804 | |
| 805 | if (device_is_attached(dev)) |
| 806 | bus_generic_detach(dev); |
| 807 | |
| 808 | /* Get rid of /dev/devcfg0. */ |
| 809 | if (sc->sc_ctl_dev != NULL) |
| 810 | destroy_dev(sc->sc_ctl_dev); |
| 811 | |
| 812 | /* Teardown and release interrupt. */ |
| 813 | if (sc->irq_res != NULL) { |
| 814 | if (sc->intrhandle) |
| 815 | bus_teardown_intr(dev, sc->irq_res, sc->intrhandle); |
| 816 | bus_release_resource(dev, SYS_RES_IRQ, |
| 817 | rman_get_rid(sc->irq_res), sc->irq_res); |
| 818 | } |
| 819 | |
| 820 | /* Release memory resource. */ |
| 821 | if (sc->mem_res != NULL) |
| 822 | bus_release_resource(dev, SYS_RES_MEMORY, |
| 823 | rman_get_rid(sc->mem_res), sc->mem_res); |
| 824 | |
| 825 | zy7_devcfg_softc_p = NULL; |
| 826 | |
| 827 | DEVCFG_SC_LOCK_DESTROY(sc); |
| 828 | |
| 829 | return (0); |
| 830 | } |
| 831 | |
| 832 | static device_method_t zy7_devcfg_methods[] = { |
| 833 | /* device_if */ |
no test coverage detected