FreeBSD/sys/dev/sio/sio.c
/*
 *	Unload the driver and clear the table.
 *	XXX this is mostly wrong.
 *	XXX TODO:
 *	This is usually called when the card is ejected, but
 *	can be caused by a kldunload of a controller driver.
 *	The idea is to reset the driver's view of the device
 *	and ensure that any driver entry points such as
 *	read and write do not hang.
 */
Unload the driver and clear the table.
XXX this is mostly wrong.
XXX TODO:
This is usually called when the card is ejected, but
can be caused by a kldunload of a controller driver.
The idea is to reset the driver's view of the device
and ensure that any driver entry points such as
read and write do not hang.
Unload the driver and clear the table . XXX this is mostly wrong . XXX TODO : This is usually called when the card is ejected but can be caused by a kldunload of a controller driver . The idea is to reset the driver ' s view of the device and ensure that any driver entry points such as read and write do not hang .
int
siodetach(device_t dev)
{
	struct com_s	*com;
	com = (struct com_s *) device_get_softc(dev);
	if (com == NULL) {
		device_printf(dev, "NULL com in siounload\n");
		return (0);
	}
	com->gone = TRUE;
	if (com->tp)
		ttyfree(com->tp);
	if (com->irqres) {
		bus_teardown_intr(dev, com->irqres, com->cookie);
		bus_release_resource(dev, SYS_RES_IRQ, 0, com->irqres);
	}
	if (com->ioportres)
		bus_release_resource(dev, SYS_RES_IOPORT, com->ioportrid,
				     com->ioportres);
	if (com->ibuf != NULL)
		free(com->ibuf, M_DEVBUF);
	device_set_softc(dev, NULL);
	free(com, M_DEVBUF);
	return (0);
}
int siodetach ( device_t dev ) { struct com_s * com ; com = ( struct com_s * ) device_get_softc ( dev ) ; if ( com == NULL ) { device_printf ( dev , " \n " ) ; return ( 0 ) ; } com -> gone = TRUE ; if ( com -> tp ) ttyfree ( com -> tp ) ; if ( com -> irqres ) { bus_teardown_intr ( dev , com -> irqres , com -> cookie ) ; bus_release_resource ( dev , SYS_RES_IRQ , 0 , com -> irqres ) ; } if ( com -> ioportres ) bus_release_resource ( dev , SYS_RES_IOPORT , com -> ioportrid , com -> ioportres ) ; if ( com -> ibuf != NULL ) free ( com -> ibuf , M_DEVBUF ) ; device_set_softc ( dev , NULL ) ; free ( com , M_DEVBUF ) ; return ( 0 ) ; }
Unload the driver and clear the table.
Unload the driver and clear the table .