コード例 #1
0
ファイル: uhidev.c プロジェクト: ryo/netbsd-src
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;
}
コード例 #2
0
static int
ohci_pci_detach(device_t self, int flags)
{
	struct ohci_pci_softc *sc = device_private(self);
	int rv;

	rv = ohci_detach(&sc->sc, flags);
	if (rv)
		return rv;

	pmf_device_deregister(self);

	ohci_shutdown(self, flags);

	if (sc->sc.sc_size) {
		/* Disable interrupts, so we don't get any spurious ones. */
		bus_space_write_4(sc->sc.iot, sc->sc.ioh,
				  OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
	}

	if (sc->sc_ih != NULL) {
		pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
		sc->sc_ih = NULL;
	}
	if (sc->sc.sc_size) {
		bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
		sc->sc.sc_size = 0;
	}
#if NEHCI > 0
	usb_pci_rem(&sc->sc_pci);
#endif
	return 0;
}
コード例 #3
0
ファイル: xhci_pci.c プロジェクト: ryoon/netbsd-xhci
static int
xhci_pci_detach(device_t self, int flags)
{
	struct xhci_pci_softc * const psc = device_private(self);
	struct xhci_softc * const sc = &psc->sc_xhci;
	int rv;

	rv = xhci_detach(sc, flags);
	if (rv)
		return rv;

	pmf_device_deregister(self);

	xhci_shutdown(self, flags);

	if (sc->sc_ios) {
#if 0
		/* Disable interrupts, so we don't get any spurious ones. */
		bus_space_write_4(sc->sc_iot, sc->sc_ioh,
				  OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
#endif
	}

	if (sc->sc_ih != NULL) {
		pci_intr_disestablish(psc->sc_pc, sc->sc_ih);
		sc->sc_ih = NULL;
	}
	if (sc->sc_ios) {
		bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
		sc->sc_ios = 0;
	}

	return 0;
}
コード例 #4
0
static int
nor_detach(device_t self, int flags)
{
	struct nor_softc * const sc = device_private(self);
	struct nor_chip * const chip = &sc->sc_chip;
	int error = 0;

	error = config_detach_children(self, flags);
	if (error) {
		return error;
	}

	flash_sync_thread_destroy(&sc->sc_flash_io);
#ifdef NOR_BBT
	nor_bbt_detach(self);
#endif
#ifdef NOTET
	/* free oob cache */
	kmem_free(chip->nc_oob_cache, chip->nc_spare_size);
#endif
	kmem_free(chip->nc_page_cache, chip->nc_page_size);

	mutex_destroy(&sc->sc_device_lock);

	pmf_device_deregister(sc->sc_dev);

	return error;
}
コード例 #5
0
static int
hdaudio_pci_detach(device_t self, int flags)
{
    struct hdaudio_pci_softc *sc = device_private(self);
    pcireg_t csr;

    hdaudio_detach(&sc->sc_hdaudio, flags);

    if (sc->sc_ih != NULL) {
        pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
        sc->sc_ih = NULL;
    }
    if (sc->sc_hdaudio.sc_memvalid == true) {
        bus_space_unmap(sc->sc_hdaudio.sc_memt,
                        sc->sc_hdaudio.sc_memh,
                        sc->sc_hdaudio.sc_memsize);
        sc->sc_hdaudio.sc_memvalid = false;
    }

    /* Disable busmastering and MMIO access */
    csr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG);
    csr &= ~(PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_BACKTOBACK_ENABLE);
    pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG, csr);

    pmf_device_deregister(self);

    return 0;
}
コード例 #6
0
ファイル: com_isa.c プロジェクト: ryo/netbsd-src
static int
com_isa_detach(device_t self, int flags)
{
	struct com_isa_softc *isc = device_private(self);
	struct com_softc *sc = &isc->sc_com;
	const struct com_regs *cr = &sc->sc_regs;
	int rc;

	if ((rc = com_detach(self, flags)) != 0)
		return rc;

	if (isc->sc_ih != NULL)
		isa_intr_disestablish(isc->sc_ic, isc->sc_ih);

	pmf_device_deregister(self);

	com_cleanup(self, 0);

#ifdef COM_HAYESP
	if (sc->sc_type == COM_TYPE_HAYESP)
		bus_space_unmap(cr->cr_iot, sc->sc_hayespioh, HAYESP_NPORTS);
#endif
	bus_space_unmap(cr->cr_iot, cr->cr_ioh, COM_NPORTS);

	return 0;
}
コード例 #7
0
static int
ralink_ohci_detach(device_t self, int flags)
{
	struct ralink_ohci_softc *sc = device_private(self);
	int rv;

	pmf_device_deregister(self);

	rv = ohci_detach(&sc->sc_ohci, flags);
	if (rv != 0)
		return rv;

	if (sc->sc_ih != NULL) {
		ra_intr_disestablish(sc->sc_ih);
		sc->sc_ih = NULL;
	}

	if (sc->sc_ohci.sc_size == 0) {
		bus_space_unmap(sc->sc_ohci.iot, sc->sc_ohci.ioh,
			sc->sc_ohci.sc_size);
		sc->sc_ohci.sc_size = 0;
	}

#if NEHCI > 0
	ralink_usb_hc_rem(&sc->sc_hc);
#endif

	return 0;
}
コード例 #8
0
ファイル: wmi_hp.c プロジェクト: eyberg/rumpkernel-netbsd-src
static int
wmi_hp_detach(device_t self, int flags)
{
	struct wmi_hp_softc *sc = device_private(self);
	device_t parent = sc->sc_parent;

	(void)acpi_wmi_event_deregister(parent);

	if (sc->sc_sme != NULL)
		sysmon_envsys_unregister(sc->sc_sme);

	if (sc->sc_sensor != NULL)
		kmem_free(sc->sc_sensor, WMI_HP_SENSOR_SIZE);

	if (sc->sc_arg != NULL)
		kmem_free(sc->sc_arg, WMI_HP_METHOD_ARG_SIZE);

	pmf_device_deregister(self);

	if (wmihp_sysctllog != NULL)
		sysctl_teardown(&wmihp_sysctllog);
	wmihp_sysctllog = NULL;
	wmi_hp_sc = NULL;

	return 0;
}
コード例 #9
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);
}
コード例 #10
0
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;
}
コード例 #11
0
int
pcppi_detach(device_t self, int flags)
{
	int rc;
	struct pcppi_softc *sc = device_private(self);

#if NATTIMER > 0
	pcppi_detach_speaker(sc);
#endif

	if ((rc = config_detach_children(sc->sc_dv, flags)) != 0)
		return rc;

	pmf_device_deregister(self);

#if NPCKBD > 0
	pckbd_unhook_bell(pcppi_pckbd_bell, sc);
#endif
	mutex_spin_enter(&tty_lock);
	pcppi_bell_stop(sc);
	mutex_spin_exit(&tty_lock);

	callout_halt(&sc->sc_bell_ch, NULL);
	callout_destroy(&sc->sc_bell_ch);

	cv_destroy(&sc->sc_slp);

	bus_space_unmap(sc->sc_iot, sc->sc_ppi_ioh, sc->sc_size);

	return 0;
}
コード例 #12
0
ファイル: uhci_pci.c プロジェクト: yazshel/netbsd-kernel
static int
uhci_pci_detach(device_t self, int flags)
{
	struct uhci_pci_softc *sc = device_private(self);
	int rv;

	if (sc->sc_initialized & SC_INIT_UHCI) {
		rv = uhci_detach(&sc->sc, flags);
		if (rv)
			return (rv);
	}

	if (sc->sc_initialized & SC_INIT_PMF)
		pmf_device_deregister(self);

	/* disable interrupts and acknowledge any pending */
	bus_space_write_2(sc->sc.iot, sc->sc.ioh, UHCI_INTR, 0);
	bus_space_write_2(sc->sc.iot, sc->sc.ioh, UHCI_STS,
	    bus_space_read_2(sc->sc.iot, sc->sc.ioh, UHCI_STS));

	if (sc->sc_ih != NULL) {
		pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
		sc->sc_ih = NULL;
	}
	if (sc->sc.sc_size) {
		bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
		sc->sc.sc_size = 0;
	}
#if NEHCI > 0
	usb_pci_rem(&sc->sc_pci);
#endif
	return (0);
}
コード例 #13
0
static int
radeondrm_detach(device_t self, int flags)
{
	pmf_device_deregister(self);

	return drm_detach(self, flags);
}
コード例 #14
0
int
re_cardbus_detach(device_t self, int flags)
{
	struct re_cardbus_softc *csc = device_private(self);
	struct rtk_softc *sc = &csc->sc_rtk;
	struct cardbus_devfunc *ct = csc->sc_ct;
	int rv;

#ifdef DIAGNOSTIC
	if (ct == NULL)
		panic("%s: cardbus softc, cardbus_devfunc NULL",
		      device_xname(self));
#endif

	rv = re_detach(sc);
	if (rv)
		return rv;

	pmf_device_deregister(self);

	/*
	 * Unhook the interrupt handler.
	 */
	if (csc->sc_ih != NULL)
		cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih);

	/*
	 * Release bus space and close window.
	 */
	if (csc->sc_bar_reg != 0)
		Cardbus_mapreg_unmap(ct, csc->sc_bar_reg,
		    sc->rtk_btag, sc->rtk_bhandle, csc->sc_mapsize);

	return 0;
}
コード例 #15
0
static int
bthub_detach(device_t self, int flags)
{

	pmf_device_deregister(self);

	return config_detach_children(self, flags);
}
コード例 #16
0
static int
spdmem_i2c_detach(device_t self, int flags)
{
	struct spdmem_i2c_softc *sc = device_private(self);

	pmf_device_deregister(self);

	return spdmem_common_detach(&sc->sc_base, self);
}
コード例 #17
0
ファイル: umodem.c プロジェクト: ryo/netbsd-src
int
umodem_detach(device_t self, int flags)
{
	struct umodem_softc *sc = device_private(self);

	pmf_device_deregister(self);

	return umodem_common_detach(sc, flags);
}
コード例 #18
0
ファイル: pci.c プロジェクト: yazshel/netbsd-kernel
int
pcidetach(device_t self, int flags)
{
	int rc;

	if ((rc = config_detach_children(self, flags)) != 0)
		return rc;
	pmf_device_deregister(self);
	return 0;
}
コード例 #19
0
static int
acpi_dalb_detach(device_t self, int flags)
{
	struct acpi_dalb_softc *sc = device_private(self);

	pmf_device_deregister(self);
	acpi_deregister_notify(sc->sc_node);
	sysmon_pswitch_unregister(&sc->sc_smpsw);

	return 0;
}
コード例 #20
0
/*
 * Detach a keyboard.  To keep track of users of the softc we keep
 * a reference count that's incremented while inside, e.g., read.
 * If the keyboard is active and the reference count is > 0 (0 is the
 * normal state) we post an event and then wait for the process
 * that had the reference to wake us up again.  Then we blow away the
 * vnode and return (which will deallocate the softc).
 */
int
wskbd_detach(device_t self, int flags)
{
	struct wskbd_softc *sc = device_private(self);
	struct wseventvar *evar;
	int maj, mn;
	int s;

#if NWSMUX > 0
	/* Tell parent mux we're leaving. */
	if (sc->sc_base.me_parent != NULL)
		wsmux_detach_sc(&sc->sc_base);
#endif

	callout_halt(&sc->sc_repeat_ch, NULL);
	callout_destroy(&sc->sc_repeat_ch);

	if (sc->sc_isconsole) {
		KASSERT(wskbd_console_device == sc);
		wskbd_console_device = NULL;
	}

	pmf_device_deregister(self);

	evar = sc->sc_base.me_evp;
	if (evar != NULL && evar->io != NULL) {
		s = spltty();
		if (--sc->sc_refcnt >= 0) {
			struct wscons_event event;

			/* Wake everyone by generating a dummy event. */
			event.type = 0;
			event.value = 0;
			if (wsevent_inject(evar, &event, 1) != 0)
				wsevent_wakeup(evar);

			/* Wait for processes to go away. */
			if (tsleep(sc, PZERO, "wskdet", hz * 60))
				aprint_error("wskbd_detach: %s didn't detach\n",
				       device_xname(self));
		}
		splx(s);
	}

	/* locate the major number */
	maj = cdevsw_lookup_major(&wskbd_cdevsw);

	/* Nuke the vnodes for any open instances. */
	mn = device_unit(self);
	vdevgone(maj, mn, mn, VCHR);

	return (0);
}
コード例 #21
0
int 
uberry_detach(device_t self, int flags)
{
	struct uberry_softc *sc = device_private(self);
	DPRINTF(("uberry_detach: sc=%p flags=%d\n", sc, flags));

	pmf_device_deregister(self);

	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);

	return (0);
}
コード例 #22
0
ファイル: adm1026.c プロジェクト: ryo/netbsd-src
static int
adm1026_detach(device_t self, int flags)
{
	struct adm1026_softc *sc = device_private(self);

	pmf_device_deregister(self);

	sysmon_envsys_unregister(sc->sc_sme);
	sc->sc_sme = NULL;

	return 0;
}
コード例 #23
0
ファイル: flash.c プロジェクト: goroutines/rumprun
int
flash_detach(device_t device, int flags)
{
	struct flash_softc * const sc = device_private(device);

	pmf_device_deregister(sc->sc_dev);

	/* freeing flash_if is our responsibility */
	kmem_free(sc->flash_if, sizeof(*sc->flash_if));

	return 0;
}
コード例 #24
0
ファイル: wbsio.c プロジェクト: ryo/netbsd-src
int
wbsio_detach(device_t self, int flags)
{
	struct wbsio_softc *sc = device_private(self);
	int rc;

	if ((rc = config_detach_children(self, flags)) != 0)
		return rc;
	bus_space_unmap(sc->sc_iot, sc->sc_ioh, WBSIO_IOSIZE);
	pmf_device_deregister(self);
	return 0;
}
コード例 #25
0
ファイル: btsco.c プロジェクト: goroutines/rumprun
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;
}
コード例 #26
0
int
attimer_detach(device_t self, int flags)
{
	struct attimer_softc *sc = device_private(self);
	
	if ((sc->sc_flags & ATT_ATTACHED) != 0)
		return EBUSY;

	pmf_device_deregister(self);
	sc->sc_flags &= ~ATT_CONFIGURED;
	bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size);
	return 0;
}
コード例 #27
0
void
mousebtn_disable(void *v)
{
	struct mousebtn_softc *sc = (struct mousebtn_softc *)v;

	if (!sc->sc_enabled)
		return;

	pmf_device_deregister(sc->sc_dev);

	sc->sc_enabled = 0;

	return;
}
コード例 #28
0
int
mididetach(device_t self, int flags)
{
	struct midi_softc *sc = device_private(self);
	int maj, mn;

	DPRINTFN(2,("%s: sc=%p flags=%d\n", __func__, sc, flags));

	pmf_device_deregister(self);

	mutex_enter(sc->lock);
	sc->dying = 1;
	cv_broadcast(&sc->wchan);
	cv_broadcast(&sc->rchan);
	mutex_exit(sc->lock);

	/* locate the major number */
	maj = cdevsw_lookup_major(&midi_cdevsw);

	/*
	 * Nuke the vnodes for any open instances (calls close).
	 * Will wait until any activity on the device nodes has ceased.
	 *
	 * XXXAD NOT YET.
	 *
	 * XXXAD NEED TO PREVENT NEW REFERENCES THROUGH AUDIO_ENTER().
	 */
	mn = device_unit(self);
	vdevgone(maj, mn, mn, VCHR);
	
	if (!(sc->props & MIDI_PROP_NO_OUTPUT)) {
		evcnt_detach(&sc->xmt.bytesDiscarded);
		evcnt_detach(&sc->xmt.incompleteMessages);
	}
	if (sc->props & MIDI_PROP_CAN_INPUT) {
		evcnt_detach(&sc->rcv.bytesDiscarded);
		evcnt_detach(&sc->rcv.incompleteMessages);
	}

	if (sc->sih != NULL) {
		softint_disestablish(sc->sih);
		sc->sih = NULL;
	}

	cv_destroy(&sc->wchan);
	cv_destroy(&sc->rchan);

	return (0);
}
コード例 #29
0
ファイル: btms.c プロジェクト: goroutines/rumprun
static int
btms_detach(device_t self, int flags)
{
	struct btms_softc *sc = device_private(self);
	int err = 0;

	pmf_device_deregister(self);

	if (sc->sc_wsmouse != NULL) {
		err = config_detach(sc->sc_wsmouse, flags);
		sc->sc_wsmouse = NULL;
	}

	return err;
}
コード例 #30
0
static int
n900prxmty_detach(device_t self, int flags)
{
	struct n900prxmty_softc *sc = device_private(self);

	if (sc->sc_intr != NULL) {
		intr_disestablish(sc->sc_intr);
	}

	gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
	pmf_device_deregister(self);
	sysmon_task_queue_fini();

	return 0;
}