int scsi_detach_lun(struct scsibus_softc *sc, int target, int lun, int flags) { struct scsi_link *alink = sc->adapter_link; struct scsi_link *link; int rv; if (target < 0 || target >= alink->adapter_buswidth || target == alink->adapter_target || lun < 0 || lun >= alink->luns) return (ENXIO); if (sc->sc_link[target] == NULL) return (ENXIO); link = sc->sc_link[target][lun]; if (link == NULL) return (ENXIO); if (((flags & DETACH_FORCE) == 0) && (link->flags & SDEV_OPEN)) return (EBUSY); /* detaching a device from scsibus is a two step process... */ /* 1. detach the device */ rv = config_detach(link->device_softc, flags); if (rv != 0) return (rv); /* 2. free up its state in the midlayer */ free(link, M_DEVBUF); sc->sc_link[target][lun] = NULL; return (0); }
static int u3g_detach(device_t self, int flags) { struct u3g_softc *sc = device_private(self); int rv; if (sc->sc_dying) return 0; pmf_device_deregister(self); if (sc->sc_ucom != NULL) { rv = config_detach(sc->sc_ucom, flags); if (rv != 0) { aprint_verbose_dev(self, "Can't deallocate " "port (%d)", rv); } } if (sc->sc_intr_pipe != NULL) { (void) usbd_abort_pipe(sc->sc_intr_pipe); (void) usbd_close_pipe(sc->sc_intr_pipe); sc->sc_intr_pipe = NULL; } if (sc->sc_intr_buff != NULL) { free(sc->sc_intr_buff, M_USBDEV); sc->sc_intr_buff = NULL; } return (0); }
int uhidev_detach(struct device *self, int flags) { struct uhidev_softc *sc = (struct uhidev_softc *)self; int i, rv; DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags)); sc->sc_dying = 1; if (sc->sc_ipipe != NULL) usbd_abort_pipe(sc->sc_ipipe); if (sc->sc_repdesc != NULL) free(sc->sc_repdesc, M_USBDEV); rv = 0; for (i = 0; i < sc->sc_nrepid; i++) { if (sc->sc_subdevs[i] != NULL) { rv |= config_detach(&sc->sc_subdevs[i]->sc_dev, flags); sc->sc_subdevs[i] = NULL; } } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, &sc->sc_dev); return (rv); }
int uticom_detach(struct device *self, int flags) { struct uticom_softc *sc = (struct uticom_softc *)self; DPRINTF(("%s: uticom_detach: sc = %p\n", sc->sc_dev.dv_xname, sc)); sc->sc_dying = 1; if (sc->sc_subdev != NULL) { config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } if (sc->sc_intr_pipe != NULL) { usbd_abort_pipe(sc->sc_intr_pipe); usbd_close_pipe(sc->sc_intr_pipe); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, &sc->sc_dev); return (0); }
int uhidev_detach(device_t self, int flags) { struct uhidev_softc *sc = device_private(self); int i, rv; struct uhidev *csc; DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags)); sc->sc_dying = 1; if (sc->sc_ipipe != NULL) usbd_abort_pipe(sc->sc_ipipe); if (sc->sc_repdesc != NULL) kmem_free(sc->sc_repdesc, sc->sc_repdesc_size); rv = 0; for (i = 0; i < sc->sc_nrepid; i++) { if (sc->sc_subdevs[i] != NULL) { csc = device_private(sc->sc_subdevs[i]); rnd_detach_source(&csc->rnd_source); rv |= config_detach(sc->sc_subdevs[i], flags); } } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); pmf_device_deregister(self); mutex_destroy(&sc->sc_lock); return rv; }
void mii_detach(struct mii_data *mii, int phyloc, int offloc) { struct mii_softc *child, *nchild; if (phyloc != MII_PHY_ANY && offloc != MII_PHY_ANY) panic("mii_detach: phyloc and offloc specified"); if ((mii->mii_flags & MIIF_INITDONE) == 0) return; for (child = LIST_FIRST(&mii->mii_phys); child != NULL; child = nchild) { nchild = LIST_NEXT(child, mii_list); if (phyloc != MII_PHY_ANY || offloc != MII_OFFSET_ANY) { if (phyloc != MII_PHY_ANY && phyloc != child->mii_phy) continue; if (offloc != MII_OFFSET_ANY && offloc != child->mii_offset) continue; } LIST_REMOVE(child, mii_list); (void) config_detach(&child->mii_dev, DETACH_FORCE); } }
int ubsa_detach(device_t self, int flags) { struct ubsa_softc *sc = device_private(self); int i; int rv = 0; DPRINTF(("ubsa_detach: sc = %p\n", sc)); if (sc->sc_intr_pipe != NULL) { usbd_abort_pipe(sc->sc_intr_pipe); usbd_close_pipe(sc->sc_intr_pipe); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } sc->sc_dying = 1; for (i = 0; i < sc->sc_numif; i++) { if (sc->sc_subdevs[i] != NULL) rv |= config_detach(sc->sc_subdevs[i], flags); } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); return (rv); }
static int coram_detach(device_t self, int flags) { struct coram_softc *sc = device_private(self); struct coram_iic_softc *cic; unsigned int i; int error; error = coram_mpeg_detach(sc, flags); if (error) return error; if (sc->sc_tuner) mt2131_close(sc->sc_tuner); if (sc->sc_demod) cx24227_close(sc->sc_demod); for (i = 0; i < I2C_NUM; i++) { cic = &sc->sc_iic[i]; if (cic->cic_i2cdev) config_detach(cic->cic_i2cdev, flags); mutex_destroy(&cic->cic_busmutex); } pmf_device_deregister(self); if (sc->sc_mems) bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_mems); if (sc->sc_ih) pci_intr_disestablish(sc->sc_pc, sc->sc_ih); return 0; }
static int auich_detach(device_t self, int flags) { struct auich_softc *sc = device_private(self); /* audio */ if (sc->sc_audiodev != NULL) config_detach(sc->sc_audiodev, flags); /* sysctl */ sysctl_teardown(&sc->sc_log); mutex_enter(&sc->sc_lock); /* audio_encoding_set */ auconv_delete_encodings(sc->sc_encodings); auconv_delete_encodings(sc->sc_spdif_encodings); /* ac97 */ if (sc->codec_if != NULL) sc->codec_if->vtbl->detach(sc->codec_if); mutex_exit(&sc->sc_lock); mutex_destroy(&sc->sc_lock); mutex_destroy(&sc->sc_intr_lock); /* PCI */ if (sc->sc_ih != NULL) pci_intr_disestablish(sc->sc_pc, sc->sc_ih); if (sc->mix_size != 0) bus_space_unmap(sc->iot, sc->mix_ioh, sc->mix_size); if (sc->aud_size != 0) bus_space_unmap(sc->iot, sc->aud_ioh, sc->aud_size); return 0; }
int puc_cardbus_detach(struct device *self, int flags) { struct puc_cardbus_softc *sc = (struct puc_cardbus_softc *)self; struct puc_softc *psc = &sc->sc_psc; struct cardbus_devfunc *ct = sc->ct; int i, rv; for (i = PUC_MAX_PORTS; i--; ) { if (psc->sc_ports[i].intrhand) cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, psc->sc_ports[i].intrhand); if (psc->sc_ports[i].dev) if ((rv = config_detach(psc->sc_ports[i].dev, flags))) return (rv); } for (i = PUC_NBARS; i--; ) if (psc->sc_bar_mappings[i].mapped) Cardbus_mapreg_unmap(ct, psc->sc_bar_mappings[i].type, psc->sc_bar_mappings[i].t, psc->sc_bar_mappings[i].h, psc->sc_bar_mappings[i].s); return (0); }
int umct_detach(struct device *self, int flags) { struct umct_softc *sc = (struct umct_softc *)self; int rv = 0; DPRINTF(("umct_detach: sc=%p flags=%d\n", sc, flags)); if (sc->sc_intr_pipe != NULL) { usbd_abort_pipe(sc->sc_intr_pipe); usbd_close_pipe(sc->sc_intr_pipe); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } sc->sc_dying = 1; if (sc->sc_subdev != NULL) { rv = config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, &sc->sc_dev); return (rv); }
int hilmsdetach(struct device *self, int flags) { struct hilms_softc *sc = (void *)self; if (sc->sc_wsmousedev != NULL) return config_detach(sc->sc_wsmousedev, flags); return (0); }
int auvitek_video_detach(struct auvitek_softc *sc, int flags) { if (sc->sc_videodev != NULL) { config_detach(sc->sc_videodev, flags); sc->sc_videodev = NULL; } return 0; }
int hilmsdetach(device_t self, int flags) { struct hilms_softc *sc = device_private(self); if (sc->sc_wsmousedev != NULL) return config_detach(sc->sc_wsmousedev, flags); return 0; }
/* * Called after the loop has been unplugged. We simply force detach of * all our children. */ void hilempty(struct hil_softc *sc) { u_int8_t db; int id, s; u_int oldmaxdev; s = splhil(); /* * Wait for the loop to be stable. */ for (;;) { if (send_hil_cmd(sc, HIL_READLPSTAT, NULL, 0, &db) == 0) { if (db & (LPS_CONFFAIL | LPS_CONFGOOD)) break; } else { db = LPS_CONFFAIL; break; } } if (db & LPS_CONFFAIL) { sc->sc_maxdev = 0; } else { db = 0; send_hil_cmd(sc, HIL_READLPSTAT, NULL, 0, &db); oldmaxdev = sc->sc_maxdev; sc->sc_maxdev = db & LPS_DEVMASK; if (sc->sc_maxdev != 0) { /* * The loop was not unplugged after all, but its * configuration has changed. */ hilconfig(sc, oldmaxdev); return; } } /* * Now detach all hil devices. */ for (id = sc->sc_maxdev + 1; id < NHILD; id++) { if (sc->sc_devices[id] != NULL) config_detach((struct device *)sc->sc_devices[id], DETACH_FORCE); sc->sc_devices[id] = NULL; } sc->sc_cmdbp = sc->sc_cmdbuf; splx(s); }
int ubcmtp_detach(struct device *self, int flags) { struct ubcmtp_softc *sc = (struct ubcmtp_softc *)self; int ret = 0; if (sc->sc_wsmousedev != NULL) ret = config_detach(sc->sc_wsmousedev, flags); return (ret); }
int uhidev_detach(struct device *self, int flags) { struct uhidev_softc *sc = (struct uhidev_softc *)self; int i, rv = 0; DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags)); if (sc->sc_opipe != NULL) { usbd_abort_pipe(sc->sc_opipe); usbd_close_pipe(sc->sc_opipe); sc->sc_opipe = NULL; } if (sc->sc_ipipe != NULL) { usbd_abort_pipe(sc->sc_ipipe); usbd_close_pipe(sc->sc_ipipe); sc->sc_ipipe = NULL; } if (sc->sc_repdesc != NULL) free(sc->sc_repdesc, M_USBDEV); /* * XXX Check if we have only one children claiming all the Report * IDs, this is a hack since we need a dev -> Report ID mapping * for uhidev_intr(). */ if (sc->sc_nrepid > 1 && sc->sc_subdevs[0] != NULL && sc->sc_subdevs[0] == sc->sc_subdevs[1]) return (config_detach(&sc->sc_subdevs[0]->sc_dev, flags)); for (i = 0; i < sc->sc_nrepid; i++) { if (sc->sc_subdevs[i] != NULL) { rv |= config_detach(&sc->sc_subdevs[i]->sc_dev, flags); sc->sc_subdevs[i] = NULL; } } return (rv); }
int bthidev_detach(struct device *self, int flags) { struct bthidev_softc *sc = (struct bthidev_softc *)self; struct bthidev *hidev; mutex_enter(&bt_lock); sc->sc_flags = 0; /* disable reconnecting */ /* release interrupt listen */ if (sc->sc_int_l != NULL) { l2cap_detach(&sc->sc_int_l); sc->sc_int_l = NULL; } /* release control listen */ if (sc->sc_ctl_l != NULL) { l2cap_detach(&sc->sc_ctl_l); sc->sc_ctl_l = NULL; } /* close interrupt channel */ if (sc->sc_int != NULL) { l2cap_disconnect(sc->sc_int, 0); l2cap_detach(&sc->sc_int); sc->sc_int = NULL; } /* close control channel */ if (sc->sc_ctl != NULL) { l2cap_disconnect(sc->sc_ctl, 0); l2cap_detach(&sc->sc_ctl); sc->sc_ctl = NULL; } /* remove timeout */ timeout_del(&sc->sc_reconnect); mutex_exit(&bt_lock); /* detach children */ while ((hidev = LIST_FIRST(&sc->sc_list)) != NULL) { LIST_REMOVE(hidev, sc_next); config_detach(&hidev->sc_dev, flags); } /* release descriptor */ if (sc->sc_desc != NULL) { free(sc->sc_desc, M_BTHIDEV); sc->sc_desc = NULL; } return 0; }
int tap_clone_destroyer(device_t dev) { cfdata_t cf = device_cfdata(dev); int error; if ((error = config_detach(dev, 0)) != 0) aprint_error_dev(dev, "unable to detach instance\n"); free(cf, M_DEVBUF); return (error); }
int utpms_detach(struct device *self, int flags) { struct utpms_softc *sc = (struct utpms_softc *)self; int ret = 0; /* The wsmouse driver does all the work. */ if (sc->sc_wsmousedev != NULL) ret = config_detach(sc->sc_wsmousedev, flags); return (ret); }
static int btsco_detach(device_t self, int flags) { struct btsco_softc *sc = device_private(self); DPRINTF("sc=%p\n", sc); pmf_device_deregister(self); mutex_enter(bt_lock); if (sc->sc_sco != NULL) { DPRINTF("sc_sco=%p\n", sc->sc_sco); sco_disconnect_pcb(sc->sc_sco, 0); sco_detach_pcb(&sc->sc_sco); sc->sc_sco = NULL; } if (sc->sc_sco_l != NULL) { DPRINTF("sc_sco_l=%p\n", sc->sc_sco_l); sco_detach_pcb(&sc->sc_sco_l); sc->sc_sco_l = NULL; } mutex_exit(bt_lock); if (sc->sc_audio != NULL) { DPRINTF("sc_audio=%p\n", sc->sc_audio); config_detach(sc->sc_audio, flags); sc->sc_audio = NULL; } if (sc->sc_intr != NULL) { softint_disestablish(sc->sc_intr); sc->sc_intr = NULL; } if (sc->sc_rx_mbuf != NULL) { m_freem(sc->sc_rx_mbuf); sc->sc_rx_mbuf = NULL; } if (sc->sc_tx_refcnt > 0) { aprint_error_dev(self, "tx_refcnt=%d!\n", sc->sc_tx_refcnt); if ((flags & DETACH_FORCE) == 0) return EAGAIN; } cv_destroy(&sc->sc_connect); mutex_destroy(&sc->sc_intr_lock); return 0; }
int hidms_detach(struct hidms *ms, int flags) { int rv = 0; DPRINTF(("hidms_detach: ms=%p flags=%d\n", ms, flags)); /* No need to do reference counting of hidms, wsmouse has all the goo */ if (ms->sc_wsmousedev != NULL) rv = config_detach(ms->sc_wsmousedev, flags); return (rv); }
static int btms_detach(device_t self, int flags) { struct btms_softc *sc = device_private(self); int err = 0; if (sc->sc_wsmouse != NULL) { err = config_detach(sc->sc_wsmouse, flags); sc->sc_wsmouse = NULL; } return err; }
int uftdi_detach(struct device *self, int flags) { struct uftdi_softc *sc = (struct uftdi_softc *)self; DPRINTF(("uftdi_detach: sc=%p flags=%d\n", sc, flags)); if (sc->sc_subdev != NULL) { config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } return (0); }
int gpioow_detach(struct device *self, int flags) { struct gpioow_softc *sc = (struct gpioow_softc *)self; int rv = 0; gpio_pin_unmap(sc->sc_gpio, &sc->sc_map); if (sc->sc_ow_dev != NULL) rv = config_detach(sc->sc_ow_dev, flags); return (rv); }
static int cgd_destroy(device_t dev) { int error; cfdata_t cf; cf = device_cfdata(dev); error = config_detach(dev, DETACH_QUIET); if (error) return error; free(cf, M_DEVBUF); return 0; }
int uslcom_detach(struct device *self, int flags) { struct uslcom_softc *sc = (struct uslcom_softc *)self; int rv = 0; if (sc->sc_subdev != NULL) { rv = config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } return (rv); }
int ums_detach(struct device *self, int flags) { struct ums_softc *sc = (struct ums_softc *)self; int rv = 0; DPRINTF(("ums_detach: sc=%p flags=%d\n", sc, flags)); /* No need to do reference counting of ums, wsmouse has all the goo. */ if (sc->sc_wsmousedev != NULL) rv = config_detach(sc->sc_wsmousedev, flags); return (rv); }
int radeondrm_forcedetach(struct radeon_device *rdev) { struct pci_softc *sc = (struct pci_softc *)rdev->dev.dv_parent; pcitag_t tag = rdev->pa_tag; #if NVGA > 0 if (rdev->console) vga_console_attached = 0; #endif config_detach(&rdev->dev, 0); return pci_probe_device(sc, tag, NULL, NULL); }
static int bthidev_detach(device_t self, int flags) { struct bthidev_softc *sc = device_private(self); struct bthidev *hidev; mutex_enter(bt_lock); sc->sc_flags = 0; /* disable reconnecting */ /* release interrupt listen */ if (sc->sc_int_l != NULL) { l2cap_detach(&sc->sc_int_l); sc->sc_int_l = NULL; } /* release control listen */ if (sc->sc_ctl_l != NULL) { l2cap_detach(&sc->sc_ctl_l); sc->sc_ctl_l = NULL; } /* close interrupt channel */ if (sc->sc_int != NULL) { l2cap_disconnect(sc->sc_int, 0); l2cap_detach(&sc->sc_int); sc->sc_int = NULL; } /* close control channel */ if (sc->sc_ctl != NULL) { l2cap_disconnect(sc->sc_ctl, 0); l2cap_detach(&sc->sc_ctl); sc->sc_ctl = NULL; } callout_halt(&sc->sc_reconnect, bt_lock); callout_destroy(&sc->sc_reconnect); mutex_exit(bt_lock); /* detach children */ while ((hidev = LIST_FIRST(&sc->sc_list)) != NULL) { LIST_REMOVE(hidev, sc_next); config_detach(hidev->sc_dev, flags); } sockopt_destroy(&sc->sc_mode); return 0; }