示例#1
0
/*
 * Bus independant device detachment routine.  Makes sure all
 * allocated resources are freed, callouts disabled and waiting
 * processes unblocked.
 */
int
cmx_detach(device_t dev)
{
	struct cmx_softc *sc = device_get_softc(dev);

	DEBUG_printf(dev, "called\n");

	sc->dying = 1;

	CMX_LOCK(sc);
	if (sc->polling) {
		DEBUG_printf(sc->dev, "disabling polling\n");
		callout_stop(&sc->ch);
		sc->polling = 0;
		CMX_UNLOCK(sc);
		callout_drain(&sc->ch);
		selwakeuppri(&sc->sel, PZERO);
	} else {
		CMX_UNLOCK(sc);
	}

	wakeup(sc);
	destroy_dev(sc->cdev);

	DEBUG_printf(dev, "releasing resources\n");
	cmx_release_resources(dev);
	return 0;
}
示例#2
0
/*
 * Bus independant device detachment routine.  Makes sure all
 * allocated resources are freed, callouts disabled and waiting
 * processes unblocked.
 */
int
cmx_detach(device_t dev)
{
	struct cmx_softc *sc = device_get_softc(dev);

	DEBUG_printf(dev, "called\n");

	sc->dying = 1;

	CMX_LOCK(sc);
	if (sc->polling) {
		DEBUG_printf(sc->dev, "disabling polling\n");
		callout_stop(&sc->ch);
		sc->polling = 0;
		CMX_UNLOCK(sc);
		KNOTE(&sc->kq.ki_note, 0);
	} else {
		CMX_UNLOCK(sc);
	}

	wakeup(sc);
	DEBUG_printf(dev, "releasing resources\n");
	cmx_release_resources(dev);
	dev_ops_remove_minor(&cmx_ops, device_get_unit(dev));

	return 0;
}
示例#3
0
/*
 * Attach to the pccard, and call bus independant attach and
 * resource allocation routines.
 */
static int
cmx_pccard_attach(device_t dev)
{
	int rv = 0;
	cmx_init_softc(dev);

	if ((rv = cmx_alloc_resources(dev)) != 0) {
		device_printf(dev, "cmx_alloc_resources() failed!\n");
		cmx_release_resources(dev);
		return rv;
	}

	if ((rv = cmx_attach(dev)) != 0) {
		device_printf(dev, "cmx_attach() failed!\n");
		cmx_release_resources(dev);
		return rv;
	}

	device_printf(dev, "attached\n");
	return 0;
}