本文整理汇总了C++中device_delete_child函数的典型用法代码示例。如果您正苦于以下问题:C++ device_delete_child函数的具体用法?C++ device_delete_child怎么用?C++ device_delete_child使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了device_delete_child函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ata_identify
int
ata_identify(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
struct ata_device *master = NULL, *slave = NULL;
device_t master_child = NULL, slave_child = NULL;
int master_unit = -1, slave_unit = -1;
if (ch->devices & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) {
if (!(master = kmalloc(sizeof(struct ata_device),
M_ATA, M_INTWAIT | M_ZERO))) {
device_printf(dev, "out of memory\n");
return ENOMEM;
}
master->unit = ATA_MASTER;
}
if (ch->devices & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) {
if (!(slave = kmalloc(sizeof(struct ata_device),
M_ATA, M_INTWAIT | M_ZERO))) {
kfree(master, M_ATA);
device_printf(dev, "out of memory\n");
return ENOMEM;
}
slave->unit = ATA_SLAVE;
}
#ifdef ATA_STATIC_ID
if (ch->devices & ATA_ATA_MASTER)
master_unit = (device_get_unit(dev) << 1);
#endif
if (master && !(master_child = ata_add_child(dev, master, master_unit))) {
kfree(master, M_ATA);
master = NULL;
}
#ifdef ATA_STATIC_ID
if (ch->devices & ATA_ATA_SLAVE)
slave_unit = (device_get_unit(dev) << 1) + 1;
#endif
if (slave && !(slave_child = ata_add_child(dev, slave, slave_unit))) {
kfree(slave, M_ATA);
slave = NULL;
}
if (slave && ata_getparam(slave, 1)) {
device_delete_child(dev, slave_child);
kfree(slave, M_ATA);
}
if (master && ata_getparam(master, 1)) {
device_delete_child(dev, master_child);
kfree(master, M_ATA);
}
bus_generic_probe(dev);
bus_generic_attach(dev);
return 0;
}
示例2: sbc_detach
static int
sbc_detach(device_t dev)
{
struct sbc_softc *scp = device_get_softc(dev);
sbc_lock(scp);
device_delete_child(dev, scp->child_midi2);
device_delete_child(dev, scp->child_midi1);
device_delete_child(dev, scp->child_pcm);
release_resource(scp);
sbc_lockdestroy(scp);
return bus_generic_detach(dev);
}
示例3: card_detect_task
static void
card_detect_task(void *arg, int pending)
{
struct fsl_sdhc_softc *sc = (struct fsl_sdhc_softc *)arg;
int err;
int insert;
insert = read4(sc, SDHC_PRSSTAT) & PRSSTAT_CINS;
mtx_lock(&sc->mtx);
if (insert) {
if (sc->child != NULL) {
mtx_unlock(&sc->mtx);
return;
}
sc->child = device_add_child(sc->self, "mmc", -1);
if (sc->child == NULL) {
device_printf(sc->self, "Couldn't add MMC bus!\n");
mtx_unlock(&sc->mtx);
return;
}
/* Initialize MMC bus host structure. */
init_mmc_host_struct(sc);
device_set_ivars(sc->child, &sc->mmc_host);
} else {
if (sc->child == NULL) {
mtx_unlock(&sc->mtx);
return;
}
}
mtx_unlock(&sc->mtx);
if (insert) {
if ((err = device_probe_and_attach(sc->child)) != 0) {
device_printf(sc->self, "MMC bus failed on probe "
"and attach! error %d\n", err);
device_delete_child(sc->self, sc->child);
sc->child = NULL;
}
} else {
if (device_delete_child(sc->self, sc->child) != 0)
device_printf(sc->self, "Could not delete MMC bus!\n");
sc->child = NULL;
}
}
示例4: ata_detach
int
ata_detach(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
device_t *children;
int nchildren, i;
/* check that we have a valid channel to detach */
if (!ch->r_irq)
return ENXIO;
/* grap the channel lock so no new requests gets launched */
mtx_lock(&ch->state_mtx);
ch->state |= ATA_STALL_QUEUE;
mtx_unlock(&ch->state_mtx);
/* detach & delete all children */
if (!device_get_children(dev, &children, &nchildren)) {
for (i = 0; i < nchildren; i++)
if (children[i])
device_delete_child(dev, children[i]);
free(children, M_TEMP);
}
/* release resources */
bus_teardown_intr(dev, ch->r_irq, ch->ih);
bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
ch->r_irq = NULL;
mtx_destroy(&ch->state_mtx);
mtx_destroy(&ch->queue_mtx);
return 0;
}
示例5: vtpci_detach
static int
vtpci_detach(device_t dev)
{
struct vtpci_softc *sc;
device_t child;
int error;
sc = device_get_softc(dev);
if ((child = sc->vtpci_child_dev) != NULL) {
error = device_delete_child(dev, child);
if (error)
return (error);
sc->vtpci_child_dev = NULL;
}
vtpci_reset(sc);
if (sc->vtpci_msix_res != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(1),
sc->vtpci_msix_res);
sc->vtpci_msix_res = NULL;
}
if (sc->vtpci_res != NULL) {
bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(0),
sc->vtpci_res);
sc->vtpci_res = NULL;
}
return (0);
}
示例6: nandsim_stop_ctrl
static int
nandsim_stop_ctrl(int num)
{
device_t nexus;
devclass_t nexus_devclass;
int ret = 0;
nand_debug(NDBG_SIM,"stop controller num:%d", num);
if (num >= MAX_SIM_DEV) {
return (EINVAL);
}
if (!ctrls[num].created || !ctrls[num].running) {
return (ENODEV);
}
/* We will add our device as a child of the nexus0 device */
if (!(nexus_devclass = devclass_find("nexus")) ||
!(nexus = devclass_get_device(nexus_devclass, 0))) {
return (ENODEV);
}
mtx_lock(&Giant);
if (ctrls[num].sim_ctrl_dev) {
ret = device_delete_child(nexus, ctrls[num].sim_ctrl_dev);
ctrls[num].sim_ctrl_dev = NULL;
}
mtx_unlock(&Giant);
ctrls[num].running = 0;
return (ret);
}
示例7: zy7_ehci_detach
static int
zy7_ehci_detach(device_t dev)
{
ehci_softc_t *sc = device_get_softc(dev);
sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
if (device_is_attached(dev))
bus_generic_detach(dev);
if (sc->sc_irq_res && sc->sc_intr_hdl)
/* call ehci_detach() after ehci_init() called after
* successful bus_setup_intr().
*/
ehci_detach(sc);
if (sc->sc_bus.bdev) {
device_detach(sc->sc_bus.bdev);
device_delete_child(dev, sc->sc_bus.bdev);
}
if (sc->sc_irq_res) {
if (sc->sc_intr_hdl != NULL)
bus_teardown_intr(dev, sc->sc_irq_res,
sc->sc_intr_hdl);
bus_release_resource(dev, SYS_RES_IRQ,
rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
}
if (sc->sc_io_res)
bus_release_resource(dev, SYS_RES_MEMORY,
rman_get_rid(sc->sc_io_res), sc->sc_io_res);
usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
return (0);
}
示例8: ig4iic_detach
int
ig4iic_detach(ig4iic_softc_t *sc)
{
int error;
if (device_is_attached(sc->dev)) {
error = bus_generic_detach(sc->dev);
if (error)
return (error);
}
if (sc->smb)
device_delete_child(sc->dev, sc->smb);
if (sc->intr_handle)
bus_teardown_intr(sc->dev, sc->intr_res, sc->intr_handle);
sx_xlock(&sc->call_lock);
mtx_lock(&sc->io_lock);
sc->smb = NULL;
sc->intr_handle = NULL;
reg_write(sc, IG4_REG_INTR_MASK, 0);
reg_read(sc, IG4_REG_CLR_INTR);
set_controller(sc, 0);
mtx_unlock(&sc->io_lock);
sx_xunlock(&sc->call_lock);
return (0);
}
示例9: ed_detach
/*
* Detach the driver from the hardware and other systems in the kernel.
*/
int
ed_detach(device_t dev)
{
struct ed_softc *sc = device_get_softc(dev);
struct ifnet *ifp = sc->ifp;
if (mtx_initialized(ED_MUTEX(sc)))
ED_ASSERT_UNLOCKED(sc);
if (ifp) {
ED_LOCK(sc);
if (bus_child_present(dev))
ed_stop(sc);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
ED_UNLOCK(sc);
ether_ifdetach(ifp);
callout_drain(&sc->tick_ch);
}
if (sc->irq_res != NULL && sc->irq_handle)
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
ed_release_resources(dev);
if (sc->miibus)
device_delete_child(dev, sc->miibus);
if (mtx_initialized(ED_MUTEX(sc)))
ED_LOCK_DESTROY(sc);
bus_generic_detach(dev);
return (0);
}
示例10: ohci_pci_detach
static int
ohci_pci_detach(device_t self)
{
ohci_softc_t *sc = device_get_softc(self);
if (sc->sc_flags & OHCI_SCFLG_DONEINIT) {
ohci_detach(sc, 0);
sc->sc_flags &= ~OHCI_SCFLG_DONEINIT;
}
if (sc->irq_res && sc->ih) {
int err = bus_teardown_intr(self, sc->irq_res, sc->ih);
if (err)
/* XXX or should we panic? */
device_printf(self, "Could not tear down irq, %d\n",
err);
sc->ih = NULL;
}
if (sc->sc_bus.bdev) {
device_delete_child(self, sc->sc_bus.bdev);
sc->sc_bus.bdev = NULL;
}
if (sc->irq_res) {
bus_release_resource(self, SYS_RES_IRQ, 0, sc->irq_res);
sc->irq_res = NULL;
}
if (sc->io_res) {
bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, sc->io_res);
sc->io_res = NULL;
sc->iot = 0;
sc->ioh = 0;
}
return 0;
}
示例11: exynos_xhci_detach
static int
exynos_xhci_detach(device_t dev)
{
struct exynos_xhci_softc *esc = device_get_softc(dev);
device_t bdev;
int err;
if (esc->base.sc_bus.bdev != NULL) {
bdev = esc->base.sc_bus.bdev;
device_detach(bdev);
device_delete_child(dev, bdev);
}
/* During module unload there are lots of children leftover */
device_delete_children(dev);
xhci_halt_controller(&esc->base);
if (esc->res[2] && esc->base.sc_intr_hdl) {
err = bus_teardown_intr(dev, esc->res[2],
esc->base.sc_intr_hdl);
if (err) {
device_printf(dev, "Could not tear down IRQ,"
" %d\n", err);
return (err);
}
}
bus_release_resources(dev, exynos_xhci_spec, esc->res);
xhci_uninit(&esc->base);
return (0);
}
示例12: ig4iic_detach
int
ig4iic_detach(ig4iic_softc_t *sc)
{
int error;
mtx_lock(&sc->mtx);
reg_write(sc, IG4_REG_INTR_MASK, 0);
reg_read(sc, IG4_REG_CLR_INTR);
set_controller(sc, 0);
if (sc->generic_attached) {
error = bus_generic_detach(sc->dev);
if (error)
goto done;
sc->generic_attached = 0;
}
if (sc->smb) {
device_delete_child(sc->dev, sc->smb);
sc->smb = NULL;
}
if (sc->intr_handle) {
bus_teardown_intr(sc->dev, sc->intr_res, sc->intr_handle);
sc->intr_handle = NULL;
}
error = 0;
done:
mtx_unlock(&sc->mtx);
return error;
}
示例13: imx_ehci_detach
static int
imx_ehci_detach(device_t dev)
{
struct imx_ehci_softc *sc;
ehci_softc_t *esc;
sc = device_get_softc(dev);
esc = &sc->ehci_softc;
if (esc->sc_bus.bdev != NULL)
device_delete_child(dev, esc->sc_bus.bdev);
if (esc->sc_flags & EHCI_SCFLG_DONEINIT)
ehci_detach(esc);
if (esc->sc_intr_hdl != NULL)
bus_teardown_intr(dev, esc->sc_irq_res,
esc->sc_intr_hdl);
if (sc->ehci_irq_res != NULL)
bus_release_resource(dev, SYS_RES_IRQ, 0,
sc->ehci_irq_res);
if (sc->ehci_mem_res != NULL)
bus_release_resource(dev, SYS_RES_MEMORY, 0,
sc->ehci_mem_res);
usb_bus_mem_free_all(&esc->sc_bus, &ehci_iterate_hw_softc);
/* During module unload there are lots of children leftover */
device_delete_children(dev);
return (0);
}
示例14: fm801_pci_detach
static int
fm801_pci_detach(device_t dev)
{
int r;
struct fm801_info *fm801;
DPRINT("Forte Media FM801 detach\n");
fm801 = pcm_getdevinfo(dev);
r = bus_generic_detach(dev);
if (r)
return r;
if (fm801->radio != NULL) {
r = device_delete_child(dev, fm801->radio);
if (r)
return r;
fm801->radio = NULL;
}
r = pcm_unregister(dev);
if (r)
return r;
bus_release_resource(dev, fm801->regtype, fm801->regid, fm801->reg);
bus_teardown_intr(dev, fm801->irq, fm801->ih);
bus_release_resource(dev, SYS_RES_IRQ, fm801->irqid, fm801->irq);
bus_dma_tag_destroy(fm801->parent_dmat);
kfree(fm801, M_DEVBUF);
return 0;
}
示例15: a10_ehci_detach
static int
a10_ehci_detach(device_t self)
{
ehci_softc_t *sc = device_get_softc(self);
device_t bdev;
int err;
uint32_t reg_value = 0;
if (sc->sc_bus.bdev) {
bdev = sc->sc_bus.bdev;
device_detach(bdev);
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
device_delete_children(self);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
/*
* only call ehci_detach() after ehci_init()
*/
ehci_detach(sc);
err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
if (err)
/* XXX or should we panic? */
device_printf(self, "Could not tear down irq, %d\n",
err);
sc->sc_intr_hdl = NULL;
}
if (sc->sc_irq_res) {
bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
sc->sc_irq_res = NULL;
}
if (sc->sc_io_res) {
bus_release_resource(self, SYS_RES_MEMORY, 0,
sc->sc_io_res);
sc->sc_io_res = NULL;
}
usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
/* Disable configure port */
reg_value = A10_READ_4(sc, SW_SDRAM_REG_HPCR_USB2);
reg_value &= ~SW_SDRAM_BP_HPCR_ACCESS;
A10_WRITE_4(sc, SW_SDRAM_REG_HPCR_USB2, reg_value);
/* Disable passby */
reg_value = A10_READ_4(sc, SW_USB_PMU_IRQ_ENABLE);
reg_value &= ~SW_AHB_INCR8; /* AHB INCR8 disable */
reg_value &= ~SW_AHB_INCR4; /* AHB burst type INCR4 disable */
reg_value &= ~SW_AHB_INCRX_ALIGN; /* AHB INCRX align disable */
reg_value &= ~SW_ULPI_BYPASS; /* ULPI bypass disable */
A10_WRITE_4(sc, SW_USB_PMU_IRQ_ENABLE, reg_value);
/* Disable clock for USB */
a10_clk_usb_deactivate();
return (0);
}